1,安装gstreamer
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools
2,拷个官方教程源码:
basic-tutorial-1.c
#include <gst/gst.h>
int main(int argc, char *argv[]) {
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Build the pipeline */
pipeline = gst_parse_launch ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm", NULL);
/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
3,编译
官方写的编译命令是
gcc basic-tutorial-1.c -o basic-tutorial-1 `pkg-config --cflags --libs gstreamer-1.0`
但实际执行时pkg-config --cflags --libs gstreamer-1.0无法识别到,也就无法执行得到库和文件的包含路径。我在shell下单独执行pkg-config --cflags --libs gstreamer-1.0是可以的,最后发现命令左右两边的引号不是单引号,而应该是数字键最左边的符号,在Tab键上方,1左边的那个键。
编译成功。执行生成的文件,我这里是test.
./basic-tutorial-1
过五秒钟,出来一个视频,不过显示分屏了,不过能显示说明就OK了。