Compile and install Gstreamer to the target version 1.22.9 with C3V Codec supported:
1 . Install building package
sudo apt update sudo apt install -y build-essential meson ninja-build python3-pip bison libglib2.0-dev flex git sudo apt install -y libx264-dev pip3 install --upgrade meson sudo pip3 install --upgrade meson
2 . Build Gstreamer and install it:
Gst source and check out to be version 1.20.1.
mkdir code cd ~/code git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git cd gstreamer git checkout -b 1.22.9 1.22.9
3 . Apply code patch for supporting C3V codec
Patch files are below. Please download files and copy files to root ~/code folder in C3V rootfs.
Extract patch files: patch files will be extracted in ~/code/gstreamer1
7z x gstreamer-1.22.9-patch.7z
Apply patch
cp ~/code/gstreamer1/gst1-plugins-bad/0001-h264-parser-pts-add.patch ~/code/gstreamer/subprojects/gst-plugins-bad/ cp ~/code/gstreamer1/gst1-plugins-bad/0001-webrtcdsp-Update-code-for-webrtc-audio-processing-1.patch ~/code/gstreamer/subprojects/gst-plugins-bad/ cd ~/code/gstreamer/subprojects/gst-plugins-bad patch -p1 < 0001-h264-parser-pts-add.patch patch -p1 < 0001-webrtcdsp-Update-code-for-webrtc-audio-processing-1.patch cp ~/code/gstreamer1/gst1-plugins-good/0001-v4l2-codec-support.patch ~/code/gstreamer/subprojects/gst-plugins-good/ cp ~/code/gstreamer1/gst1-plugins-good/0002-support-jpeg-dec-4k.patch ~/code/gstreamer/subprojects/gst-plugins-good/ cp ~/code/gstreamer1/gst1-plugins-good/0003-fixed-get-v4l2-codec-failed.patch ~/code/gstreamer/subprojects/gst-plugins-good/ cd ~/code/gstreamer/subprojects/gst-plugins-good patch -p1 < 0001-v4l2-codec-support.patch patch -p1 < 0002-support-jpeg-dec-4k.patch patch -p1 < 0003-fixed-get-v4l2-codec-failed.patch
4. Configure ,build and install in prefix path “/home/sunplus/code/install-gstreamer
"
Configure:
cd ~/code/gstreamer meson setup build --prefix=/home/sunplus/code/install-gstreamer -Dgpl=enabled
Build:
ninja -C build
Install: gstreamer install path is/home/sunplus/code/install-gstreamer
ninja -C build install
5 . Setting up a development environment while keeping the distribution package
You can use gst-env tool to setup development environment for gstreamer.
cd ~/code/gstreamer python3 gst-env.py
Check if V4L2 codec elements are created successfully: v4l2h264dec, v4l2h264enc, v4l2jpegdec, v4l2jpegenc
gst-inspect-1.0 | grep v4l2
6 . Running cmd example:
H.264 Encode
Fake live stream:
gst-launch-1.0 -v videotestsrc horizontal-speed=15 num_buffers=100 ! "video/x-raw,width=1920,height=1080,format=NV12,framerate=30/1" ! timeoverlay ! v4l2h264enc ! "video/x-h264,level=(string)4" ! filesink location=gstv4l2h264enc.h264
H.264 Decode
gst-launch-1.0 -v filesrc location=gstv4l2h264enc.h264 ! h264parse ! v4l2h264dec ! filesink location=gstv4l2h264dec.yuv
JPEG Encode
gst-launch-1.0 -v videotestsrc num_buffers=100 horizontal-speed=15 ! "video/x-raw,width=1920,height=1080,format=NV12" ! v4l2jpegenc ! filesink location=1080p.jpg
JPEG Decode
gst-launch-1.0 -v filesrc location=1080p.jpg ! jpegparse ! v4l2jpegdec ! "video/x-raw,colorimetry=bt601" ! filesink location=og_1080p.yuv