Playing with the Pi Camera V2

The Raspberry Pi Camera V2 8MP.

I recently purchased a Pi camera V2 module for my Raspberry Pi 3. I was pleasantly surprised, it actually takes pretty good quality pictures and video (though with no sound)! I have been experimenting with it to try and sort of make it work, like a touch screen digital camera, on my 5″ HDMI touch screen.

Here is a series of bad (and goofy) videos I made with all the stuff I have done so far!

 

 

Playlist link Here

I learned how to connect the camera to the Pi and the code I used to make it work, from the raspberry pi foundation website here. I will update this post later with a little more details on how I modified some of the code and other things to get it to do what I wanted or something like that.

Here is the resource link to how I made the desktop buttons/shortcuts: http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/gui/desktop-shortcuts

To convert from .h264 to Mp4, you need to install MP4 Box on the pi.

sudo apt-get install gpac.

Then you type this in the terminal: MP4Box – add /filepath/filename.h264 and then add where you want the file to be saved after it’s converted: /filepath/filename.mp4

Example in terminal: pi@raspberrypi:~$ MP4Box -add /home/pi/Videos/dancingalien.h264 /home/pi/Videos/dancingalien.mp4

To remove the .h264 file, put in the terminal: pi@raspberrypi:~$ rm /home/pi/Videos/dancingalien.h264

To make a bash script that runs it all including a time stamp:

Open the terminal and type:  pi@raspberrypi:~$ sudo nano

This opens a text editor and you add this with out the beginning and ending brackets []:

[#!/bin/bash

DATE=$(date +”%Y-%m-%d_%H%M”) <-time stamp code

raspivid -o /filepath/$DATE.h264 -t 999999
#convert to mp4
MP4Box -add /samefilepathasabove/$DATE.h264 (space)/filepathyouwantitcovertedto/$DATE.mp4
#remove raw file
rm /samefileinthe1stline/$DATE.h264]

Note: after the -t you can set your own recording time. Zero will go on until you stop it with a kill command or something like that. I used 999999. 30000 = 30 seconds.

Then control x and give it a file name and add.sh to the end and y to save and close it.

Then make the video.sh executable with:

pi@raspberrypi:~$ sudo chmod +x filepath/video.sh 

and hit enter.

Desktop Shortcut Code Launcher

You can just type ./video.sh to run the file and it will take the video or make a desktop shortcut to do it.

Right click in the desktop area and click create new and choose Empty File.

Name the file, something.dektop. It will add a new empty file on the desktop.

Now right click it and choose, Text Editor.

You can copy and paste this in it, and just change things to suite what you want it to do. Then save it.

Example:

[Desktop Entry]
Name=Video
Comment=records video
Icon=/file/path/icon.png
Exec=./video.sh
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;

I am enabling comments on this post, for anyone who has questions or other ideas I might try with the camera. If you spam it, you will be blocked!

About Robby 86 Articles
I am just your Friendly Neighborhood Computer Nerd ready to lend a keyboard to others who need IT help without the IT cost! I also love to cook, play golf and try to make people laugh!

Be the first to comment

Leave a Reply

Your email address will not be published.


*