It's currently best to build Pivid from source. Please open an issue if these instructions don't work!
-
Use a Raspberry Pi (4B recommended) with a fully updated bookworm install, 2G+ RAM, and 10G+ free space on the SD card.
-
Install
git-lfs
:sudo apt update && sudo apt install git-lfs
-
Clone this repository. Make sure you install
git-lfs
first, or you'll get placeholders instead of media files! -
Change (
cd
) to the repository root and run./dev_setup.py
. -
Run
ninja -C build
to build Pivid. (Add-j2
to limit build parallelism if you only have 2GB RAM.) -
Binaries (eg.
pivid_server
) are created inbuild/
. They are statically linked and may be copied elsewhere if desired. -
To reset the build, start over with
./dev_setup.py --clean
.
- Edit
/boot/config.txt
(as root), comment out existingdtoverlay=vc4
... andgpu_mem=
... lines, and add these options:
# Use full KMS and H.265 (HEVC) decoding, reserve 512M CMA for frames
dtoverlay=vc4-kms-v3d,cma-512
dtoverlay=rpivid-v4l2
# Reserve 256M for the GPU (mostly for H.264 decoding)
gpu_mem=256
-
Run
sudo servicectl stop lightdm
to stop the X windows desktop. (You may want to log in to the Pi from another computer now, unless you like using the text mode Linux console.) -
Test playing a video file:
build/pivid_play --media test_media/jellyfish-3-mbps-hd-hevc.mkv
If all goes well, 1080p video of blorping jellyfish should play on the Pi's HDMI output for 30 seconds.
The main pivid_server
program listens for HTTP requests, serves the
REST API, and plays content on screen as requested.
Notable arguments:
--media_root=«directory»
(required) - give location of media files--port=«port»
- change the listening port (default 31415)--trust_network
- listen on all interfaces (default localhost only)--help
- see a full list of arguments
For a quick test, run the server from the repository root:
build/pivid_server --media_root test_media
At the same time, run this script, also from the repository root:
test_media/rickroll_drop.py
If all goes well, you should be able to press keys 0-9 to
add falling Rick Astley videos on top of a jellyfish scene.
(The rickroll_drop.py
script sends API requests to the server
running on the default port. You will find other example scripts
in the test_media
directory, along with media files.)
A production setup would start pivid_server
on boot with appropriate
--media_root
and other options, and disable X windows desktop autostart.
Doing so is left as an exercise for the reader
(details will depend on local needs and preferences).
The pivid_play
utility is a self-contained player mainly used
for testing and development.
Notable arguments:
--media=«media file»
- play this video (or image)--script=«script file»
- execute this play script--help
- see a full list of arguments
The pivid build also includes other testing and exploration tools:
pivid_scan_displays
- lists video drivers, connectors, and available modespivid_scan_media
- lists media file metadata, and optionally dumps framespivid_inspect_avformat
- lists low level video file detailspivid_inspect_kms
- lists low level KMS/DRM driver detailspivid_inspect_kmsg
- lists kernel logs with better timestamps than dmesgpivid_inspect_v4l2
- lists low level V4L2 driver details
Use --help
(and/or read the source) to see usage for each tool.
Next: Architecture overview