[Dprglist] Streaming video from a Raspberry Pi
Murray Altheim
murray18 at altheim.com
Wed Mar 24 07:41:42 PST 2021
Hi,
As promised, I've fixed up and re-posted my Raspberry Pi streaming class.
This uses a standard Pi camera and has a few features I didn't mention in
today's VTC. It provides a video-to-file and optional video-to-stream
(web page) functionality, with options for dynamically altering the camera
settings to account for light levels based on a Pimoroni LTR-559 lux sensor
(at 0x23), as well as automatic and manual controls for camera lighting
using either one or two Pimoroni Matrix 11x7 displays (at 0x75 and 0x77).
The camera image size, title and timestamp annotation and other properties
are set in the YAML configuration file (config.yaml). The output filename
is timestamped and written to a './videos' directory in H.264 video format.
I would have preferred MPEG output but transcoding live on the Pi would
take a fair bit of horsepower, so I do that after downloading the file.
I've actually got an option to convert to MP4 built into the code but if
I remember right there was some problem with the output (like it wasn't a
compliant format and would cause VLC to freeze, or something like that). A
bug in any case.
Note that the lux sensor and 11x7 lighting are optional -- if you don't
have them the video will still operate.
# Usage
This requires Python 3. You'll also need to enable your Pi camera via
raspi-config.
You can download the code via:
% git clone https://github.com/ifurusato/ros.git
Once downloaded, navigate to the 'ros' directory and start the video test:
% cd ros
% video_test.py
You may need to install various Python libraries. Hopefully for most you'll
be prompted to install via error messages. This includes colorama, tzlocal,
ffmpeg and hopefully not too many others. If you have any trouble please
reply to the list and I'll post solutions here.
BTW, this is the means by which the on-board video from my YouTube video
was captured:
KR01 Telerobotic Joyride
https://youtu.be/Lw5Hz95IyBk
Enjoy!
Murray
...........................................................................
Murray Altheim <murray18 at altheim dot com> = = ===
http://www.altheim.com/murray/ === ===
= = ===
In the evening
The rice leaves in the garden
Rustle in the autumn wind
That blows through my reed hut.
-- Minamoto no Tsunenobu
More information about the DPRGlist
mailing list