Gstreamer Creating C Code Applications

From RidgeRun Developer Connection
Jump to: navigation, search

Gstreamer C Code Application

The gst-launch test utility is handy for verifying a GStreamer pipeline is setup correctly. However gst-launch is not a good choice to use in a shipping embedded Linux product. Instead, a GStreamer application is needed. One choice is to use GStreamer Deamon, which you can control using D-Bus. Another option is to role your own application.

This wiki documents how to create a GStreamer C code application using the Ridgerun's SDK. The applications is located in $(DEVDIR)/myapps, uses the Ridgerun classes for GStreamer, autotools, and general sdk installation into target. Like all GStreamer C code application, the application uses glib. The example applicatin was tested using the Turrialba SDK running on a Leopardboard368 using a MT9P031 Aptina sensor.

The example applicatin can be better understood by referring to the GStreamer documentation.

The source code to the GStreamer C code application can be retrieved using:

git clone https://github.com/RidgeRun/video-capture-application.git video-capture-application

Gstreamer applications can have parsers, callbacks according to signals, read values from command lines and many other capabilities. In this case this is just a simple application that runs the following pipeline:

videotestsrc num-buffers=300 ! 'video/x-raw-yuv,format=(fourcc)NV12,width=640, height=480' ! dmaiaccel ! dmaienc_h264 ! queue ! qtmux ! filesink location=$FILENAME

where the FILENAME is the first command line parameter.

Application source code directory structure

video_capture_application/
├── Config
├── Makefile
└── src
         ├── autogen.sh
         ├── configure.ac
         ├── Makefile.am
         ├── README
         └── src

                  ├── Makefile.am
                  ├── video_capture_application.c
                  └── video_capture.h

Compiling Application

ARM Compilation

The RidgeRun SDK makes it easy to cross compile for the ARM:

cd $DEVDIR/myapps
git clone https://github.com/RidgeRun/video-capture-application.git video-capture-application
cd video-capture-application
make

When the application is installed it can be run at the target with the following command:

video_capture_application test_file.mov

After 300 frames have been processed, the file test_file.mov will contain the video.

x86 Compilation

You doin't need the RidgeRun SDK to build for the host. You do need GStreamer development libraries installed.

cd $HOME/work
git clone https://github.com/RidgeRun/video-capture-application.git video-capture-application
cd video-capture-application/src
./autogen.sh
./configure
make

After compiling the application can be executed as any regular binary:

./video-capture-application video_test.mov

After 300 frames have been processed, the file test_file.mov will contain the video.