In Part 1 and Part 2 of this set of articles I explained how I made a simple video recording device with the Raspberry Pi, a camera module and a plastic case. It’s simple enough to be mounted wherever you need a video camera.
In this final part I will explain how I extract the resulting video files from the unit and convert them to MP4 files. This makes them easier to play on other devices and media software.
Converting The Files Directly On The Pi
To convert the files using the Pi you can use the “prepare_mp4.sh” script. Plug the Pi into a network and power it up. We do not want the Pi to start recording video but the main script will not run if a network connection is detected.
The script uses MP4Box to do the conversion. If you haven’t installed it previously you can do so using :
sudo apt-get install gpac
Now you can navigate to the location where your video files are and check a copy of the script is present. Run the “prepare_mp4.sh” script using :
It may take a while but the h264 files in the directory will be converted to MP4. You will need to make sure there is sufficient space available to do this as you will end up with a h264 and MP4 file for each clip.
Once the script has finished you can transfer the resulting video files via SSH or FTP to another computer.
Converting On A Windows PC
My preferred method is to write the video to a USB drive. This can then be plugged into a PC and the “prepare_mp4.bat” script will then convert the h264 files and give you a set of MP4s. In order to use this method you will need to :
- Install MP4Box from http://gpac.wp.mines-telecom.fr/downloads/gpac-nightly-builds/
- Create a “d:\temp” temporary directory for the video files
- Insert the USB drive into your PC
- Run (double click) the “prepare_mp4.bat” script
Your MP4 files will be prepared and saved in the “d:\temp” directory. You can use a different directory but you will need to update the batch file appropriately.
Your video capture unit is now ready for another adventure!
Example Video Footage
Here is a two minute compilation I created from footage I filmed while the camera was attached to my windscreen :
The camera resolution was set to 1280×720 although the YouTube video was exported as 1920×1080. The video isn’t very exciting but shows how the camera deals with the varying daytime lighting conditions it comes across.