Introductory
Currently, the C3V Ubuntu rootfs has included the GStreamer 1.22.9 prebuild by default. It carries the commonly used elements and hardware media codec functions. Users can use gst-inspect-1.0 to check the installed elements directly. If you don’t want to use it, you can disable the install in the file <C3V_PRJ>/linux/rootfs/initramfs/build_disk.sh before running make config.
Info |
---|
To use hardware media codecs, please run the command |
...
Code Block |
---|
//test V4L2 h264 encoder test-lanuchlaunch --gst-debug-level=1 "videotestsrc ! video/x-raw,width=1280,height=720 ! v4l2h264enc ! h264parse ! rtph264pay pt=96 name=pay0" //test V4L2 jpeg encode test-lanuchlaunch --gst-debug-level=1 "videotestsrc ! video/x-raw,width=1280,height=720 ! v4l2jpegenc ! jpegparse ! rtpjpegpay pt=26 name=pay0" |
If successful, the screen can be viewed with the RTSP tool with the address rtsp://x.x.x.x:8554/test. The x.x.x.x is the IP address of your C3V board.
Info |
---|
The |
The prebuilt GStreamer is in the path <C3V_PRJ>/linux/rootfs/initramfs/ubuntu/prebuilt-app-xxx. If your C3V system doesn’t have the GStreamer it or you feel that the provided GStreamer does not meet your needs, you can recompile one of the plugins or the entire GStreamer as below.
...
Code Block |
---|
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 libgl-dev libjpeg-dev libsdl2-dev sudo apt install --reinstall libx11-dev libx11-xcb-dev libxext-dev libxrender-dev libxv-dev libxrandr-dev libxi-dev pip3 install --upgrade meson sudo pip3 install --upgrade meson |
...
Patch files are below. Please download files and copy files to the root ~/code folder in C3V rootfs.
View file | ||
---|---|---|
|
Extract patch files: patch files will be extracted in ~/code/gstreamer1
Code Block |
---|
7ztar xzxvf gstreamer-1.22.9-patch.tar.7zgz |
Info |
---|
The patch package in this document may not be up to date, if you are using the latest code of C3V, you can get the latest newest patch in the subdirectories of <C3V_PRJ>/linux/rootfs/initramfs/buildroot/package/gstreamer1 directly. |
Apply patch
Code Block |
---|
cp ~/code/gstreamer1/gst1-plugins-bad/0001-h264-parser-pts-add-webrtcdsp-Update-code-for-webrtc-audio-processing-1.patch ~/code/gstreamer/subprojects/gst-plugins-bad/ cp ~/code/gstreamer1/gst1-plugins-bad/00010002-webrtcdsph264-Updateparser-code-for-webrtc-audio-processing-1pts-add.patch ~/code/gstreamer/subprojects/gst-plugins-bad/ cd ~/code/gstreamer/subprojects/gst-plugins-bad patch -p1 < 0001-h264-parser-pts-addwebrtcdsp-Update-code-for-webrtc-audio-processing-1.patch patch -p1 < 00010002-webrtcdsph264-Updateparser-code-for-webrtc-audio-processing-1pts-add.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/ cp ~/code/gstreamer1/gst1-plugins-good/0004-add-options-for-IBBP-decoder.patch ~/code/gstreamer/subprojects/gst-plugins-good/ cp ~/code/gstreamer1/gst1-plugins-good/0005-fixed-rtsp-failed-with-v4l2codec.patch ~/code/gstreamer/subprojects/gst-plugins-good/ cp ~/code/gstreamer1/gst1-plugins-good/0006-dma-copy-and-remap-option-to-codec.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 patch -p1 < 0004-add-options-for-IBBP-decoder.patch patch -p1 < 0005-fixed-rtsp-failed-with-v4l2codec.patch patch -p1 < 0006-dma-copy-and-remap-option-to-codec.patch |
4. Configure, build and install in prefix path “/home/sunplus/code/install-gstreamer
"
Configure:
Code Block |
---|
cd ~/code/gstreamer meson setup build --prefix=/home/sunplus/code/install-gstreamer -Dgpl=enabled |
...
5 . Setting up a development environment while keeping the distribution package
You can use the gst-env tool to setup set the development environment for gstreamerGStreamer.
Code Block |
---|
cd ~/code/gstreamer python3 gst-env.py |
...
Code Block |
---|
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,format=YUY2,framerate=30/1 ! videoconvert ! ximagesink or gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,format=YUY2,framerate=30/1 ! videoconvert ! glimagesink |