Ice Bear Soft GARICAM (गाड़ीकैम): GPS player for CEL-TEC N5 in Linux

Garicam The GARICAM program plays the videos from the CEL-TEC N5 camera and shows the route on the map. It makes use of Google Maps services, internet connection is therefore necessary. The program is written in PHP and JavaScript and is developed for the Linux operating system. It will hardly work in other systems because it requires components that are available in Linux distributions.

The software is currently available in English and Czech only.

The current program version is 1.1.

1. The name of the game
2. New features in version 1.1
3. Program overview
4. Known problems and limitations
5. Installation of prerequisites
  5.1. ffmpeg
  5.2. jwplayer
  5.3. Google Maps API key
  5.4. Web server
6. Garicam installation and configuration
  6.1. Installing the files on the web server
  6.2. Preparing the directory for videos
  6.3. Preparing the working directory for temporary files
  6.4. Garicam configuration
  6.5. Apache web server configuration
  6.6. Apache and SELinux
  6.7. Deleting temporary files from working directory
7. Setting the language
8. Copying the files from the camera
9. License
10. Download
11. Acknowledgement

1. The name of the game

GARICAM (in Devanāgarī गाड़ीकैम) comes from Hindi words गाड़ी का कैमरा meaning the car camera.

2. New features in version 1.1

  1. The program is available in English and Czech, the language is selected by the standard mechanism of content negotiation.
  2. A slider is used to show the running time of the playback. The slider serves also to fast navigation and may be used even during video playback. The feature requires an HTML5 capable browser.
  3. The Go button shifts the video player to the nearest moment when the car starts running. The function is implemented in such a way that tries to overcome problems caused by imprecision of GPS location. The function is useful if a car waits for a long time for instance at a railway crossing. The button works properly only if the GPS data are available.

3. Program overview

The program plays the videos from the CEL-TEC N5 camera and shows the route on the map using data from the GPS module. It is possible to play both single files and sequences. Due to the route display it is suggested to play continuous file sequences only. Synchronization of the video with the map is preserved even if the video position is moved quickly or another video is selected in the playlist. By clicking on the route the video is set to the corresponding position. By using the button below the video a snapshot in the full video resolution can be taken.

Version 1.1 offers two new controls displayed below the player.

A slider shows the running time cumulatively for all video files. The total time is displayed at the right edge of the slider, the actual time is shown at the left edge. When sliding by mouse, the selected time position is shown which enables easy finding of the place to which we want to shift. The video player will select the proper video file to be played and the location on the map will be synchronized. This function requires an HTML5 capable browser.

The second new control is the Go button. If you push it when the car is standing, the player will be moved forward to the nearest moment when the car starts running. The values of the speed are stored in the GPS data. The function may thus work properly only if the GPS data are available.

In addition to drawing the route the actual speed and heading are displayed below the map. These values are retrieved from the data obtained from the GPS module. Total distance is calculated using the Google Maps API functions and the average speed is evaluated as a ratio of the distance and time.

You can view the program demonstration in the video below. Explanation is given in Czech and English subtitles (select them by using the icon in the lower right corner of the video). The video demonstrates version 1.0beta.

Safari for iPad cannot display subtitles, you have to use directly the YouTube application for iPad. I did not manage to display subtitles in the YouTube application for Android but Chrome for Android displays them.

4. Known problems and limitations

5. Installation of prerequisites

The program requires other components that must be acquired and installed separately. The instructions are given below.

5.1. ffmpeg
5.2. jwplayer
5.3. Google Maps API key
5.4. Web server

5.1. ffmpeg

ffmpeg is a program for operations with video files from the command prompt. It is used for extraction of subtitles into a text file that contains information from the GPS module in the GPRMC format. The program need not be contained in the default installation but an installable package should be available. In the worst case you will have to compile it from the sources.

5.2. jwplayer

jwplayer is a video player written in JavaScript. It offers functions needed for developing a program for synchronization of the video and the map. You can freely download it from www.jwplayer.com/.

5.3. Google Maps API key

The route is displayed on the map using the Google Maps API. The API requires authorization by means of a user key. The free version allows 25 thousand accesses daily. It is impossible to reach this limit by personal use. However, if I published my key, other users might exceed my limit and I would have to pey for their access. That's why each user must have his or her own key. Obtaining the key is described in this tutorial. You must have a Google account.

If you choose Edit allowed referers, remember that referer is not a public IP address of the server but its name used to access it. If you use a URL such as http://localhost/garicam, the referer is localhost. Such a limitation does not provide any protection because all computers may be locally accessed as localhost with an IP address of 127.0.0.1 or ::1. There are other mean how to overcome the allowed referer. The best way is therefore usage of the https protocol and securing the access with a usename and a password.

5.4. Web server

As already written, jwplayer is unable to play a video using the file: protocol, a web server must be used. Any web server supporting PHP is sufficient. The author of this program chose Apache merely because he has been using Apache for other projects for many years. Installation of Apache in Linux systems is easy and configuration file for use of the Garicam program is distributed in the package. It is enough to edit the directory names, place the file to directory /etc/httpd/conf.d, and restart Apache. The structure of the configuration file will be explained later.

6. Garicam installation and configuration

The distribution package contains two directories. The garicam directory contains files that have to be installed on the web server. The tools directory contains useful tools and templates of the configuration files.

6.1. Installing the files on the web server
6.2. Preparing the directory for videos
6.3. Preparing the working directory for temporary files
6.4. Garicam configuration
6.5. Apache web server configuration
6.6. Apache and SELinux
6.7. Deleting temporary files from working directory

6.1. Installing the files on the web server

Installation of the server files is straightforward. The whole directory garicam should be copied to the directory from which the web server reads its file. In case of Apache it is usually /var/www/html but it may differ in some distributions. The files should therefore be copied to arbitrary subdirectory.

In thsi directory a subdirectory with the name jwplayer must be created and the files of the javascript video player should be placed there. These are the following files from the distribution of jwplayer: jwplayer.js, jwplayer.flash.js, jwplayer.html5.js.

All files must be readable by a user under which the web server runs. The easiest way is to make them readable by everybody using the following commands (assuming the default location of Apache document root):

cd /var/www/html
chmod +rx garicam garicam/jwplayer
chmod +r --recursive garicam/*

6.2. Preparing the directory for videos

As already written, the videos must be served by the web server. The files must therefore be stored in a directory accessible by the server. However, the camera records contain time and location whis is information that the user need not wish to share. The program therefore requires the videos directory be the subdirectory of the program directory. In such a case it bay be difficult to insert files. It is therefore possible to create a symbolic link to a directory located in the home directory:

cd /var/www/garicam
ln -s ~/path/to/camera/files videos

Later we make this directory unbrowsable over the web.

6.3. Preparing the working directory for temporary files

Unix systems use /tmp or /var/tmp for temporary files. The link to this directory may be present in the TMPDIR environment variable. However, the directory has a special property. For the security reasons the name of the file created in it is mangled so that it is accessible by the creating process only. However, the Garicam program needs to create a file by one process and read and delete it by another process. This is the reason why we need another working directory, its default name is /GaricamTMP. The owner of this directory must be the user under which the web server runs.

6.4. Garicam configuration

Garicam configuration settings are present in two files. Both of them are in the garicam directory that you have copied to the web server document tree.

Replace the text YOUR_KEY_HERE in file key.php with your actual key that you ackquired following the instructions in section Google Maps API key.

File incl_all.php allows setting various parameters but you should change only some of them.

VideosRoot
is the name of the directory for videos created in section Preparing the directory for videos.
TMPDIR
is the full path of the directory for temporary files that you created in section Preparing the working directory for temporary files.
IfconfigMe
specifies whether the public IP address (if you use NAT) should be found. It is disabled by default because it is often slow and as a result the map frame will time out and will not work.
Latitude, Longitude
are default GPS coordinates. They are used only in case that within the whole route the GPS signal was never detected. The program first tries to find the location for the IP address by means of the geo_ip module. If the module is not installed or the location for the IP address is unavailable, the default location is used. It is a location in Prague selected randomly so that it were “nice numbers”.

6.5. Apache web server configuration

The basic configuration is set in file garicam.conf that is present in directory tools. Its contents is as follows:

<Location /garicam>
  Options FolloSymLinks
  SSLRequireSSL
  Include auth/auth.conf
  AuthType Basic
  AuthName "Garicam"
  Require ... # user or group
</Location> 

Location specifies where the directory with the program is located in the web server document tree. The Options command is the only mandatory one. Value FolloSymLinks allows following the symbolic links even outside the server document tree. It is important not to set Indexes. Since personal information will be transferred over the network, it is better to request encryption using the SSLRequireSSL parameters. Protocol https will be allowed even without this parameter but using it will enforce encryption.

The remaining lines server for setting the access y user names and password. Let's assume that in a more complex configuration the same files with user names and passwords will be used to control access to several directories. We will then read the auth/auth.conf in all such directories but the result will be the same as if the contents of this file were present here. Notice thet its name is relative to the /etc/httpd directory, not to the location of the garicam.conf file. The paths to the user and group definition files are absolute.

In the groups file each line starts with the group name and after a colon space separated user names are given. A user may be a member of several groups as in the following sample:

family:myself mywife myson mybrother mygirlfriend
friends:John Jim Jack Jane Judy Jessie
beer:myself John Jim Tom Jerry Jameson

Parameter AuthName specifies the text that will be shown in the login dialogue. Parameter Require specifies who will have access to the directory. Three possibilities are available:

Require group family
Access will be granted to all members of group family.
Require user Tom Jessie mygirlfriend
Access will be granted to named users.
Require valid-user
Access will be granted to each valid user.

The file containing user names and passwords is created and maintained by the htpasswd program. Each line contains the user name followed by a colon and password hash. It might look as:

myself:$apr1$DKyOFQ.G$QEgnHSolx0IoJ20xN78fF.
mygirlfriend:$apr1$qIkobQi2$UFjdyUuyGfb4kFGLILVPf/
Jessie:$apr1$GHISaAwA$eYuPX1.0vDlL7TOCT4Mpu/

Put garicam.conf to /etc/httpd/conf.d, other files to directories listed in the configuration file mentioned and restart Apache. If Apache does not work, read the next section.

6.6. Apache and SELinux

If SELinux is activated, the files must not be in arbitrary directories but only in directories with proper context. If this condition is not fulfilled, Apache will not start. I had always problems that something did not work, therefore I have disabled SELinux by writing SELINUX=disabled in /etc/selinux/config and rebooted. If you want to use SELinux without getting mad, you have to read its documentation thoroughfully.

6.7. Deleting temporary files from working directory

Under normal conditions the temporary files are deleted almost immediatelly after creation. They remain in the directory only if the program is interrupted. They can be automatically deleted by the garicamtmpclean.sh script. Copy it to the /etc/cron.daily directory. Do not forget to change the directory name to the value set in section Preparing the working directory for temporary files.

7. Setting the language

The language of the application is set in the web browser. Each web browser offers setting preferred languages for content presentation as well as selection of the preferred order. The setting is browser dependent. The application is presented in a language chosen according to these preferences. If no language supported by the application is found, the application will use the English language.

8. Copying the files from the camera

At first it should be noted that the USB port of the camera is very slow. It is better to copy the files by using a memory card reader even if you have USB2 only.

The files in the camera are stored in two subdirectories of the DCIM directory. Probably one of the directories is reserved for the files protected against overwriting but such an information in the camera manual is missing. It is usefule to create a subdirectory for each route in the directory for videos and copy the files from both directories into it. If you wish to copy the route from 21st August 2014, you can achieve it by the following commands:

cd /path/to/my/video/files
mkdir Route-2014-08-21
cp -v /media/camera/DCIM/*/20140821* Route-2014-08-21/
chmod +rx Route-2014-08-21
chmod +r Route-2014-08-21/*

Commands chmod will set visibility of the files and directories for the web server. Remember that +rx mst be set for all parent directories on the path, otherwise the web server will not be able to use the files.

9. License

The program can be used and redistributed under GPL.

10. Download

garicam-1.1.tar.gz, 1.3 MiB

11. Acknowledgement

I would like to thank to the Czech distributer of CEL-TEC cameras who kindly sent me a sample file so that I could develop the first alpha version before buying the camera.


I am forced to sponsor musicians and other copyright organisations by my programming work because I store my software, input data as well as the results of calculation on CD and DVD media.