最近要在嵌入式板子上显示视频+字幕,摄像头移动时,qcamera显示卡顿。无奈转回gstreamer。
之前直接调用的命令行参数,但为了动态改变字幕内容,只能编程实现。
1. gstreamer安装
环境:intel-x64/ubuntu16.04
$ sudo apt-cache search gstreamer* | more
$ sudo apt-get install libgstreamer*
......
gstreamer1.0-alsa - GStreamer plugin for ALSA
gstreamer1.0-clutter-3.0 - Clutter PLugin for GStreamer 1.0
gstreamer1.0-doc - GStreamer core documentation and manuals
gstreamer1.0-plugins-base - GStreamer plugins from the "base" set
gstreamer1.0-plugins-base-appus - GStreamer helper programs from the "base" set
gstreamer1.0-plugins-base-dbg - GStreamer plugins from the "base" set
gstreamer1.0-plugins-base-doc - GStreamer documentation for plugins from the "base" set
gstreamer1.0-plugins-good - GStreamer plugins from the "good" set
gstreamer1.0-plugins-good-dbg - GStreamer plugins from the "good" set
gstreamer1.0-plugins-good-doc - GStreamer documentation for plugins from the "good" set
gstreamer1.0-pulseaudio - GStreamer plugin for PulseAudio
gstreamer1.0-tools - Tools for use with GStreamer
gstreamer1.0-x - GStreamer plugins for X11 and Pango
......
libgstreamer-plugins-base1.0-0 - GStreamer libraries from the "base" set
libgstreamer-plugins-base1.0-dev - GStreamer development files for libraries from the "base" set
libgstreamer-plugins-good1.0-0 - GStreamer development files for libraries from the "good" set
libgstreamer-plugins-good1.0-dev - GStreamer development files for libraries from the "good" set
libgstreamer1.0-0 - Core GStreamer libraries and elements
libgstreamer1.0-0-dbg - Core GStreamer libraries and elements
libgstreamer1.0-dev - GStreamer core development files
2. gstreamer helloworld
来自手册,不过还是看中文教程方便。
GStreamer基础教程01——Hello World
不过有一处变更,因为在 gstreamer 1.0中, playbin2 被重命名为 playbin。
unable to build pipeline: no element “playbin2”
1 #include <gst/gst.h>
2
3 int main(int argc, char *argv[]) {
4 GstElement *pipeline;
5 GstBus *bus;
6 GstMessage *msg;
7
8 /* Initialize GStreamer */
9 gst_init (&argc, &argv);
10
11 // Build the pipeline
12 // pipeline = gst_parse_launch ("playbin uri=https://gstreamer.freedesktop.org/media/gst-integration-testsuite.save/defaults/webm/vorbis_vp8.0.webm", NULL);
13 pipeline = gst_parse_launch ("playbin uri=file:///home/sunshia/Documents/videodrv/gstreamer/vorbis_vp8.0.webm", NULL);
14 // Start playing
15 gst_element_set_state (pipeline, GST_STATE_PLAYING);
16
17 // Wait until error or EOS
18 bus = gst_element_get_bus (pipeline);
19 msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
20
21 // Free resources
22 if (msg != NULL)
23 gst_message_unref (msg);
24 gst_object_unref (bus);
25 gst_element_set_state (pipeline, GST_STATE_NULL);
26 gst_object_unref (pipeline);
27 //
28 return 0;
29 }
3. 编写Makefile
1
2 TARGET=gst-helloworld
3 CC=gcc
4 SRC=$(wildcard *.c)
5 OBJ=$(SRC:.c=.o)
6
7 PKG_CONFIG_PATH += -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include
8
9 CFLAGS=-g
10
11 CFLAGS += `pkg-config --cflags gstreamer-1.0 glib-2.0`
12 LDFLAGS += `pkg-config --libs gstreamer-1.0 glib-2.0`
13
14 all:depend $(TARGET)
15 depend:
16 $(CC) -MM $(SRC) > .depend
17 -include .depend
18
19 $(TARGET):$(OBJ)
20 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
21
22 clean:
23 rm $(TARGET) $(OBJ) .depend -f
一个简单的makefile示例及其注释
一个简单的通用Makefile实现
pkg-config的一些用法
4. gdb调试
$ gdb gst-helloworld -tui
用GDB调试程序(一)
gdb基本命令(非常详细)
- 最后,记不住markdown语法。
献给写作者的 Markdown 新手指南