User Tools

Site Tools


Writing /var/lib/dokuwiki/data/meta/teaching/ie0117/proyectos/2012/i/linux_2013/camberry/implementacion.meta failed
teaching:ie0117:proyectos:2012:i:linux_2013:camberry:implementacion

Implementation

Here are the instructions to implement the necesary packages to run a Raspberry Pi as a portable video camera and to setup a FTP server in a local network in order to transfer the video files from the Raspberry Pi to a computer via Internet.

Configuring the Raspberry Pi

  • We want to install Raspbian on the Raspberry Pi. In an other computer download the OS image available here. This is a .zip package, to decompress execute in a linux console:
unzip [.zip folder address]
  • Copy the image into a SD card (2GB or more), first install dd package (diskdump), that package is recommended by the Raspberry Pi official web page. Next conect the SD card and write in the console:
df -h
  • The /dev/sdb1 or /dev/sdb2 etc, is the SD image. You can see the available space (option -h), be carefull and choose the right unit.
  • Now copy the Raspbian image to the SD card:
sudo dd bs=4M if=[image address] of=/dev/sdbX 

bs is the number of bytes written and read. The process take a while.

  • Next, put the SD card in the Raspberry Pi and plug it. The sistem start automatically. We recommend use the official install notes. The Raspi configuration looks like this:

  • In “boot_behaviour - Start desktop on boot?” please tipe NO, that option let start manually the desktop environment with:
startx
  • The OS configuration is done.
  • Update the system repositories:
sudo apt-get update
sudo apt-get upgrade

That take a long time, please be patient.

Recording video

  • To record video we need the packages:
sudo apt-get install streamer ffmpeg mjpegtools vlc
  • Where streamer is a tool to record video and images from the console. FFmpeg allows edit and record video with many options available in console. MJPEG Tools are a set of tools that can do recording of videos and playback, simple cut-and-paste editing and the MPEG compression of audio and video under Linux. And VLC is a open source media player only available with a desktop environment. Streamer and ffmpeg are capables to record video from a webcam, however streamer is light and does not consume too much system resources.
  • A important point is the webcam configuration, the camera used in this project is a generic model and we dont have any problem, but if you use another model please look this page and read about the compatibility. In the web you can see a lot of tutorials to configure your camera on a Raspberry Pi. To check the correct operation of the camera and other peripheral type in the console:
lsusb
  • Here you can see the list of the usb peripherals, including your camera model, otherwise is configured incorrectly. In our case we obtained:

  • Where “Chicony Electronics Co., Ltd Gateway Webcam” its our webcam.
  • Now we are ready to record video, put in the console (wthout the desktop environment):
streamer -q -c /dev/video0 -f jpeg -s 480x360 -r 8 -t 00:00:05 -o out.avi
  • Where -c is the webcam reference, -f force the input or output video to a specific format, -s is the video size, -r means the number of frames per second, -t the video lenght and -o the name and format, in this case out.avi. Note that this line does not contain an audio option, since for this application we consider is optional.
  • Also we can edit video with some basic commands. To joint two diferents videos with ffmpeg:
ffmpeg -i "concat:input1.avi|input2.avi" -c copy output.avi
  • In this case “input1.avi” is the start and “input2.av” the finish of the output video “output.avi”.
  • To remove a particular piece of video from the start of the video write:
ffmpeg -i input.avi -vcodec copy -acodec copy -ss HH:MM:SS output.avi
  • Where vcodec and acodec are the codecs used in the process, “input.avi” the original video, “HH:MM:SS” the time to delete in the start of “input.avi” and “output.avi” the final video.

Setting up the FTP server

In this section it is shown how to setup a FTP server for use in a local network.

  • Install vsftpd (Very Secure FTP Daemon):
sudo apt-get install vsftpd
  • Create a new user, this will be the user that will login remotely to the FTP server.
sudo adduser <ftpuser>
  • Now, modify the vsftp configuration file located in /etc, but first create a backup of this file. Then access the file.
cd /etc
sudo cp vsftpd.conf vsftpd.conf.save
sudo nano vsftpd.conf
  • When you access the configuration file for first time it will look like this:

  • Erase all the content in the file and write the following lines:
listen=YES
ftpd_banner=Welcome to my FTP server.
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=007
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
connect_from_port_20=YES
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

Now the vsftpd configuration file should look like this:

A brief explanation of some of the parameters in the configuration file:

  • listen: If “listen” is set to YES, then vsftpd will run in standalone mode. This means that vsftpd doesn't have to be started manually.
  • ftpd_banner: Is the greeting banner displayed by vsftpd when a connection comes in.
  • anonymous_enable: Controls whether anonymous logins are permitted or not.
  • local_enable: Controls whether local logins are permitted or not.
  • local_umask: Is the umask set to the files created by local users.
  • chroot_local_user: If set to YES, local users will be (by default) placed in a chroot() jail in their home directory after login.
  • chroot_list_enable: If activated, you may provide a list of local users who are placed in a chroot() jail in their home directory upon login.

The next step is to login as the “ftpuser”, and apply an umask on the ftpuser home directory and to add your usual user to the ftpuser group:

su <ftpuser>
cd
umask 0007
exit
sudo adduser <myuser> <ftpuser>
su - <myuser>
  • The final step is to restart the FTP daemon:
sudo /etc/init.d/vsftpd restart

After this, your personal FTP server is now ready to use.

Accessing the FTP server

  • First of all, install the ftp client:
sudo apt-get install ftp
  • Then access the FTP server with the IP address of the server:
ftp 192.168.XXX.XXX
  • After this, login with the previously created user and password. You should get a command prompt like this, then you will be able to transfer files from your computer to the FTP server and vice versa:

Some commands in the ftp client command line:

  • cd remote-directory: Change the working directory on the remote machine to remote-directory.
  • chmod mode file-name: Change the permission modes of the file file-name on the remote system to mode.
  • delete remote-file: Delete the file remote-file on the remote machine.
  • get remote-file local-file: Retrieve the remote-file and store it on the local machine. If the local file name is not specified, it is given the same name it has on the remote machine.
  • help command: Print an informative message about the meaning of command. If no argument is given, ftp prints a list the commands.
  • lcd directory: Change the working directory on the local machine.
  • ls remote-directory: Print a listing of the contents of a directory on the remote machine.
  • mkdir directory-name: Make a directory on the remote machine.
  • put local-file remote-file: Store a local file on the remote machine.
  • pwd: Print the name of the current working directory on the remote machine.
  • quit: Terminate the FTP session with the remote server and exit ftp.

Back to index

Previous section

Next section

teaching/ie0117/proyectos/2012/i/linux_2013/camberry/implementacion.txt · Last modified: 2022/09/20 00:08 (external edit)