Gstreamer daemon usage
Old documentation - this is for GStreamer Daemon 0.10. You want to use Gstd-1.0.
Warning
This GStreamer Daemon version is deprecated. A new version was written from scratch on C in 2017 to take advantage of the GStreamer 1.x API and can be found here:
If you are interested on the old vala release please continue reading this page. Otherwise please use the new documentation.
Introduction
Gstreamer Daemon (or gstd for short), is a technology developed by RidgeRun that let control audio and video streaming via gstreamer in an easy but very powerful way, but not only this as gstd will take care of the multimedia streaming you can create your own application and communicate with gstd just using dbus method calls. The advantage of gstd being the one handling the streaming and using dbus messages for interaction, is that gstd does not care who is sending messages to it as long as it is via dbus messages, this means that if your favourite programming language (c, c++, vala, python... etc) has a dbus binding you can use it to create your application (a GUI, a web interface, a command line... whatever you like!).
The key technologies behind gstd are gstreamer and dbus. Here you will find information about the RidgeRun GStreamer daemon project page and repository
For the moment this wiki page will focus on the usage of gstd on RidgeRun SDK for embedded systems.
Enabling dbus and gstd on RR SDK
To enable dbus and gstd on RidgeRun SDK, you need to enable the aplications for build and installation like this:
- First go to the root of your devdir and do a make env to set all needed env variables:
# on the root of your devdir `make env`
- Then do a make config to open the configuration menu:
cd $DEVDIR make config
- On the configuration menu go to the target software selection:
File System Configuration --->Select target's file system software --->
being there select dbus (in this case it is version 1.4.20, also please notice that it can be already selected as RR SDK manage package dependencies) and gstd:
[*] dbus-1.4.20 ... [*] gstd
After this dbus and gstd are enabled for build and installation on the target filesystem, you can exit the configuration menu and build the SDK with dbus support and gstreamer daemon.
cd $DEVDIR make
Gstreamer daemon usage example on a dm36x leopardboard
NOTE: In this example I will be using the LI-DVI video output and a LI-5M03 for input, please modify the output or input as you need.
For this example I will be using a tool that comes with gstd called gst-client. Gst-client is a separate program from gstd, gst-client can send and listen to dbus messages and that is how it communicate with gstd.
Gst-client can run in interactive mode, and that how we are going to use it here.
Gstd has the capability to manage several pipelines, for this example we are going to use only 2. The first pipeline will be to record a video and the second pipeline will be for video playback.
- Video recording pipeline:
H264ENC_PARMS="encodingpreset=2 ratecontrol=2 intraframeinterval=23 idrinterval=46 targetbitrate=3000000 profile=100 level=50 entropy=1 t8x8inter=true t8x8intra=true single-nalu=true" gst-client create "v4l2src input-src=camera chain-ipipe=true always-copy=false ! capsfilter caps=video/x-raw-yuv,format=(fourcc)NV12,width=640,height=480 ! dmaiaccel ! dmaienc_h264 $H264ENC_PARMS ! queue ! qtmux ! filesink name=file location=gstd_test1.mp4 sync=false enable-last-buffer=false"
- Video playback pipeline:
filesrc location=gstd_test1.mov name=file ! qtdemux ! dmaidec_h264 ! queue ! TIDmaiVideoSink enable-last-buffer=false videoStd=720P_60 videoOutput=DVI noCopy=true
First boot your board, and disable the on screen image like this:
fbset -disable
After this, lets check if gstd is already running on the backgraound:
ps | grep gstd | grep -v grep
If you can see a something like "1126 root 8388 S /usr/bin/gstd --system" then it is already running at the background, if not then run gstd on the background like this:
gstd &
Now gstd will be running on the background and listening to dbus methods calls. Lets use gst-client to tell gstd to create the pipelines for video recording and video playback:
First the video recording pipeline, but before please notice that gstd creates the pipeline and sets it to NULL state later we will see how to set the pipelines to PLAYING state:
/ # H264ENC_PARMS="encodingpreset=2 ratecontrol=2 intraframeinterval=23 idrinterval=46 targetbitrate=3000000 profile=100 level=50 entropy=1 t8x8inter=true t8x8intra=true single-nalu=true" / # / # / # / # gst-client create "v4l2src input-src=camera chain-ipipe=true always-copy=false ! capsfilter caps=video/x-raw-yuv,format=(fourcc)NV12,width=640,height=480 ! dmaiaccel ! dmaienc_h264 $H264ENC_PARMS ! queue ! qtmux ! filesink name=file location=gstd_test1.mp4 sync=false enable-last-buffer=false" Parse single command interactive: Pipeline path created: /com/ridgerun/gstreamer/gstd/pipe0 Ok. / #
As you can see gstd create the pipeline and told gst-client the pipeline path (/com/ridgerun/gstreamer/gstd/pipe0). Now we are going to create the video playback pipeline:
/ # gst-client create "filesrc location=gstd_test1.mov name=file ! qtdemux ! dmaidec_h264 ! queue ! TIDmaiVideoSink enable-last-buffer=false videoStd=720P_60 videoOutput=DVI noCopy=true" Parse single command interactive: Pipeline path created: /com/ridgerun/gstreamer/gstd/pipe1 Ok. / #
The playback pipeline now have the path /com/ridgerun/gstreamer/gstd/pipe1.
Now we are going to set the recording pipeline to PLAYING state to start the recording:
/ # gst-client -p 0 play Parse single command interactive: davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124 vpfe-capture vpfe-capture: IPIPE Chained vpfe-capture vpfe-capture: Resizer present vpfe-capture vpfe-capture: standard not supported Ok. / #
Now we are recording from the camera, let it record a video long enough for us to play later with the playback pipeline.
To stop recording we need to send a EOS signal like this:
/ # gst-client -p 0 send-eos Parse single command interactive: Ok. / #
NOTE: give some time for the video file to stop saving, or else you will get a corrupted video file.
After this, we no longer need the recording pipeline so lets set it to null and destroy it like this:
/ # gst-client -p 0 null Parse single command interactive: Ok. / # gst-client -p 0 destroy Parse single command interactive: Pipeline with path:/com/ridgerun/gstreamer/gstd/pipe0, destroyed Ok. / #
Now we can play with the video we recorded using the playback pipeline.
Set the video playback pipeline to PLAYING state:
/ # gst-client -p 1 play Parse single command interactive: Ok. / #
Now you should be watching the video you record at a normal speed. Lets try a seek:
/ # gst-client -p 1 seek 20 Parse single command interactive: Ok. / #
Notice you can do this even on PLAYING state.
Lets change the playback speed, first lets make it go slower:
/ # gst-client -p 1 speed 0.5 Parse single command interactive: Ok. / #
And now go faster:
/ # gst-client -p 1 speed 1.5 Parse single command interactive: Ok. / #
Back to normal speed:
/ # gst-client -p 1 speed 1 Parse single command interactive: Ok. / #
We can pause the video:
/ # gst-client -p 1 pause Parse single command interactive: Ok. / #
while we are in pause we can also do a seek:
/ # gst-client -p 1 seek 20 Parse single command interactive: Ok. / #
You can set the state back to PLAYING and you will see where you set the seek in the video:
/ # gst-client -p 1 play Parse single command interactive: Ok. / #
And we can set thie pipeline to NULL:
/ # gst-client -p 1 null Parse single command interactive: Ok. / #
Now we can destroy the pipeline:
/ # gst-client -p 1 destroy Parse single command interactive: Pipeline with path:/com/ridgerun/gstreamer/gstd/pipe1, destroyed Ok. / #
To see more options you got with the gst-client run it in the interactive mode and type help like this:
gst-client
After running this command you should see the interactive console like this:
Interactive console execution: gst-client$
Type help to get the different commands supported, this is what my gst-client displays when I type help:
gst-client$ help Request the syntax of an specific command with "help <command>". This is the list of supported commands: create: Creates a new pipeline and returns the dbus-path to access it destroy: Destroys the pipeline specified by_path(-p) or the active pipeline destroy-all: Destroys all pipelines on the factory. play: Sets the pipeline specified by_path(-p) or the active pipeline to play state tplay: Sets the pipeline specified by_path (-p) or the active pipeline to play state for a specifed duration abort-autostop: Aborts the auto stop property in the pipeline specified by_path (-p) or the active pipeline. ready: Sets the pipeline specified by_path(-p) or the active pipeline to ready state pause: Sets the pipeline specified by_path(-p) or the active pipeline to pause state null: Sets the pipeline specified by_path(-p) or active pipeline to null state aplay: Sets the pipeline to play state, it does not wait the change to be done aready: Sets the pipeline to ready state, it does not wait the change to be done apause: Sets the pipeline to pause state, it does not wait the change to be done anull: Sets the pipeline to null state, it does not wait the change to be done set: Sets an element's property value of the pipeline Supported <data-type>s include: boolean, integer, int64, and string get: Gets an element's property value of the pipeline get-duration: Gets the pipeline duration time get-position: Gets the pipeline position sh: Execute a shell command using interactive console get-state: Get the state of a specific pipeline(-p flag) or the active pipeline get-elem-state: Get the state of a specific element ofthe active pipeline list-pipes: Returns a list of all the dbus-path ofthe existing pipelines ping: Shows if gstd is alive ping-pipe: Test if the active pipeline is alive active: Sets the active pipeline,if no <path> is passed:it returns the actual active pipeline seek: Moves current playing position to a new one skip: Skips a period, if period is positive: it moves forward, if negative: it moves backward speed: Changes playback rate: * rate>1.0: fast-forward playback, * rate<1.0: slow-forward playback, * rate=1.0: normal speed. Negative rate causes reverse playback. step: Step the number of frames, if no number is provided, 1 is assumed send-eos: Send an EOS event on the pipeline send-custom-event: Send a custom event on the pipeline. The event type can be: * UPSTREAM * DOWNSTREAM * DOWNSTREAM_OOB * BOTH * BOTH_OOB element-set-state: Sets the element state Supported <state>s include: null, ready, paused, playing element-async-set-state: Sets the element state, it does not wait the change to be done exit: Exit/quit active console quit: Exit/quit active console strict: Enable/disable strict execution mode. version: Show gst-client version. gst-client$
Ok thats it for this example, please remember that the gst-client is a tool to communicate with gstd but it can be replaced with your own application talking to gstd through dbus.