-
Notifications
You must be signed in to change notification settings - Fork 18
GStreamer setup for Yocto Project
This page includes the procedure involved in setting up the Yocto build to fetch the necessary contents required to support the GStreamer framework within the Yocto project. Once the build is successful with the GStreamer packages and plugins installed, it can be verified with some command-line examples and scripts provided in the test section of the page.
GStreamer is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.
GStreamer is released under the LGPL. The 1. x series is API and ABI stable and supersedes the previous stable 0.10 series. Both can be installed in parallel.
It works with all major operating systems like Linux, Windows, Android, and iOS. GStreamer uses its plug-ins to provide codecs, support for multiple container formats, filters, etc.
This page content is related to the build and use of GStreamer in Yocto Project distribution running on an ARM hardware architecture i.e, Raspberry Pi 3B+
This example deals with:
- Yocto Project (kirkstone)
- GStreamer 1.0
Since we already have a Yocto build environment setup from Assignment-6, we'll just clone the working Assignment-6 repository locally or continue with the Assignment-6 local repository (if there is no modifications have occurred later Assignment-6)
License:
#This is required so that gstreamer1.0-plugins-ugly can be added to the image
LICENCE="LICENSE_FLAGS_ACCEPTED = \"commercial commercial_gstreamer1.0-plugins-ugly\""
cat conf/local.conf | grep "${LICENCE}" > /dev/null
local_licn_info=$?
if [ $local_licn_info -ne 0 ];then
echo "Append ${LICENCE} in the local.conf file"
echo ${LICENCE} >> conf/local.conf
else
echo "${LICENCE} already exists in the local.conf file"
fi
TODO: All PACKAGECONFIG changes here should ideally go in a .bbappend
on gstreamer
recipes instead of local.conf
Most of the plugins required for the basic video transmission pipelines are in gst-plugins-good and gst-plugins-ugly package.
Read more about plugins here.
If any plugins are missing from the packages we installed above.
The individual plugins can be installed as below.
Here we are installing three such plugins required for our pipeline i.e., x264, voaacenc, and RTMP.
x264:
# Adding required gstreamer Package_configs for x264 to local.conf file
cat conf/local.conf | grep "x264" > /dev/null
local_licn_info=$?
if [ $local_licn_info -ne 0 ];then
echo "Append x264 PACKAGECONFIG to local.conf file"
echo "PACKAGECONFIG:append:pn-gstreamer1.0-plugins-ugly = \" x264\"" >> conf/local.conf
else
echo " x264 package configurations already exist in local.conf"
fi
VOAACENC:
# Adding required Gstreamer Package_configs for voaacenc to local.conf file
cat conf/local.conf | grep " voaacenc" > /dev/null
local_licn_info=$?
if [ $local_licn_info -ne 0 ];then
echo "Append voaacenc PACKAGECONFIG to local.conf file"
echo "PACKAGECONFIG:append:pn-gstreamer1.0-plugins-bad = \" voaacenc\"" >> conf/local.conf
else
echo " voaacenc package configurations already exist in local.conf"
fi
RTMP:
# Adding required Gstreamer Package_configs for rtmp to local.conf file
cat conf/local.conf | grep " rtmp" > /dev/null
local_licn_info=$?
if [ $local_licn_info -ne 0 ];then
echo "Append rtmp PACKAGECONFIG to local.conf file"
echo "PACKAGECONFIG:append:pn-gstreamer1.0-plugins-bad = \" rtmp\"" >> conf/local.conf
else
echo " rtmp package configurations already exist in local.conf"
fi
Note: Complete build.sh script.
Yocto will look for these packages in the meta-layers specified in bblayer.conf and perform several tasks upon them, in the end, adding these as ready to use in the Yocto Image.
Refer to build/deploy instructions at https://github.com/cu-ecen-aeld/yocto-assignments-base/wiki/Build-basic-YOCTO-image-for-RaspberryPi
We can able to verify the presence of the required elements for the gst-pipelines with the gst-inspect command as below:
gst-inspect-1.0 | grep fakesrc
We can verify the GStreamer pipeline working model with a basic pipeline with a fakesrc and a fakesink.
gst-launch-1.0 -v fakesrc silent=false num-buffers=3 ! fakesink silent=false
If the output looks similar, then GStreamer is running correctly.
We can also use a custom video source by using the server pipeline as below:
Server(on Raspberry Pi (Yocto image)):
gst-launch-1.0 -v v4l2src device=/dev/video0! \ video/x-raw,width=640,height=480,framerate=30/1 ! \ videoconvert ! \ jpegenc ! \ rtpjpegpay ! \ udpsink host=$CLIENT_IP port=5000
Client (on Raspberry Pi (Yocto image)):
gst-launch-1.0 -v udpsrc port=5000 ! \ application/x-rtp,encoding-name=JPEG, payload=26 ! \ rtpjpegdepay ! \ jpegdec ! \ videoconvert ! \ autovideosink
The output should look something like this:
Server:
Client:
The JPEG encoding is used for this application since it's faster and gives better performance in terms of buffer dropping.
For more info see this link
Read more about application development