Jetson Nano 已经安装了 GStreamer,但是,nVidia 并没有完成配置, include 路径需要自己在配置一下才行。方法如下:
在 /etc/profile 文件最后添加以下两行内容即可:
export C_INCLUDE_PATH=/usr/include/gstreamer-1.0:/usr/include/glib-2.0:/usr/lib/aarch64-linux-gnu/glib-2.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/gstreamer-1.0:/usr/include/glib-2.0:/usr/lib/aarch64-linux-gnu/glib-2.0/include:$CPLUS_INCLUDE_PATH
保存后重启系统,即可。用下面的程序(文件名 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;
}
用下面的命令编译:
gcc basic-tutorial-1.c -o basic-tutorial-1 `pkg-config --cflags --libs gstreamer-1.0`
运行编译好的程序,应该能看到来自 https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm一段很有趣的视频。