为 Jetson Nano 配置 GStreamer

本文介绍了如何在Jetson Nano上安装并配置GStreamer的include路径,通过编辑/etc/profile文件添加环境变量。然后提供了一个简单的C程序(basic-tutorial-1.c)来测试GStreamer的功能,该程序从指定URL播放视频。编译程序使用`gcc`并链接GStreamer库。成功执行后,系统将播放来自https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm的视频。

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一段很有趣的视频。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

许野平

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值