Issue recording videos using Raspberry Pi Camera, photos work fine

Hi there, as title states I’m having issues recording videos using the raspberry pi camera.

I have a custom menu item on the default skin with two submenu options - Photo and Video

When you select photo, this runs a python script with the following:
import os
os.system(’/opt/vc/bin/raspistill -t 3000 -o /home/osmc/Pictures/date +%d%m%Y_%H%M-%S.png --annotate 12’)

This saves a photo in a specific folder with the name formatted as the date and time. This works perfectly by both using the menu item and executing the python script in the terminal and via ssh.

The video option runs a similar script:
import os
os.system(’/opt/vc/bin/raspivid -t 60000 -rot 90 -hf -o /home/osmc/Videos/date +%d%m%Y_%H%M.mp4 --annotate 12’)

This script works perfectly when executing via ssh and the terminal, but when executed via the menu item two strange things happen:
1 - The video doesn’t save a file
2 - The bottom left of the camera view on-screen is jittery, and kind of lags behind the rest of the view. Kind of like a rolling shutter effect.

I understand this might be a strange issue but I’d really like to use OSMC for this project so I don’t want to have to use some other OS, none are as smooth or as well tuned as OSMC.

Python threads from Kodi may be running with a lower priority.
I would suggest making a systemd one shot unit and invoking that via systemctl

And can I do that from a submenu option yeah?

Also I don’t know if this is of note but I don’t experience the weird bottom left jitteriness on the photo script


Do you always see the video artefacts?

Always. It’s incredibly consistent. Also when I run the script manually the annotated time at the top of the frame updates in real time but when running it from the OSMC submenu option it stays at whatever time the video started.

What I mean, is: is video ok from command line?

Video from command line is perfect, no artefacts, the file saves perfectly and the annotated time updates in real time.

Then the systemctl approach should work for you.

Thanks Sam, you’re the best.

PS. Any good posts on here about systemctl and systemd?

Just search for one shot unit

1 Like