How to record video

Hi , is there a way to use the raspberry pi camera for recording instead of streaming ? So after the flight , it would be saved in the SD card .
I have seen in the forums 2 suggestions :
1> Write a python script using dronekit that triggers the camera when quadcopter is armed .
2> Stream the video and screen record it on your ground station .
The first won’t work because dronekit no longer works with navio’s raspbian image.
The second won’t give me the video quality i need .
Is there any other methods ? Thanks .


the easiest way would be to simply start recording each time the vehicle is powered on, but it would require to shutdown the RPi properly so the video file gets saved correctly.

Or you could try to use a RC controlled on/off switch connected to a GPIO pin and read it with a python script.

Hi , thanks . But how would i do it , and where will the video be saved exactly ?

You can save the video anywhere you like. If you start raspivid with a filename and no path, the video will be written to the home/pi/ directory.

How you do it depends on what option you want to use. Recording a video everytime the vehicle is powered on, requires no additional hardware. You will have to write a script (bash/python etc.) that is started by a systemd service at boot and terminated when raspbian is shutdown/halted. In that script you call raspivid with the options you need (path, resolution, bitrate, etc.).
The other option would be to use an external signal through a GPIO pin to start/stop recording. You could connect a simple pushbutton or a rc controlled switch. The script would still be loaded at boot, but recording would start/stop when the script detects a change of the pin state.

I really appreciate your help. Thank you .

Hey bro,

did someone write the referenced script? I am quite practical of electronics but a little less of programming so if you can share the script you would do me a great pleasure.

Hi , do you mean a script just to record and save a video ? If yes then this is my script
where mypics_and_vids is the directory i use to save all my recorded videos

This script should be launched when you turn on your navio board . But if you are searching for a script to allow you to control your raspberry pi camera in flight , i tried doing that by reading the channel 5 <that varries between 1000 and 2000> output of my transmitter and make it control whether to stop recording or not this way :

But it only works when apm is off since it turned out i can’t read rc input while apm is running .
Do as @schuermannsebastian said by using the free gpio pin 37 as the controlling input . You can use this reference for raspberry pi camera commands and python scripts

Note : install picamera before using it on navio2 … $ sudo apt-get install python-picamera

Thank you @mohammadsaab for the information you provided me.

I’m searching for the second script solution. Now that I have a track to follow I will try to work on it.

Let’s keep up to date.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.