gst常用命令

环境变量

GST_PLUGIN_PATH 环境变量用于指定 GStreamer 在启动时应该搜索插件的额外路径。默认情况下,GStreamer 会搜索一些标准的目录(如 /usr/lib/gstreamer-1.0/),但通过设置这个环境变量,可以添加额外的目录,以便 GStreamer 能够找到安装的自定义插件或第三方插件。

在这个例子中,GST_PLUGIN_PATH 被设置为 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/。这意味着 GStreamer 会在启动时搜索这个目录来查找插件。

export GST-plugin-path=“/usr/lib/aarch64-linux-gnu/gstreamer-1.0/“

直接查看 GStreamer 可执行文件或库文件的版本信息

(base) nvidia@nvidia-desktop:~$ ls -l /usr/bin/gst-launch-1.0
-rwxr-xr-x 1 root root 34744 83  2022 /usr/bin/gst-launch-1.0

如果是通过 apt 安装的 GStreamer,可以使用以下命令来查询安装的 GStreamer 包的版本:

(base) nvidia@nvidia-desktop:~$ apt list --installed | grep gstreamer1.0

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

gstreamer1.0-alsa/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.3]
gstreamer1.0-clutter-3.0/focal,now 3.0.27-1 arm64 [已安装,自动]
gstreamer1.0-gl/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.3]
gstreamer1.0-gtk3/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.2]
gstreamer1.0-libav/focal,now 1.16.2-2 arm64 [已安装]
gstreamer1.0-packagekit/focal-updates,focal-security,now 1.1.13-2ubuntu1.1 arm64 [已安装,自动]
gstreamer1.0-plugins-bad/now 1.16.3-0ubuntu1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.1]
gstreamer1.0-plugins-base-apps/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.3]
gstreamer1.0-plugins-base/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.3]
gstreamer1.0-plugins-good/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.2]
gstreamer1.0-plugins-ugly/focal,now 1.16.2-2build1 arm64 [已安装]
gstreamer1.0-pulseaudio/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.2]
gstreamer1.0-tools/focal-updates,focal-security,now 1.16.3-0ubuntu1.1 arm64 [已安装]
gstreamer1.0-x/now 1.16.3-0ubuntu1.1 arm64 [已安装,可升级至:1.16.3-0ubuntu1.3]
libgstreamer1.0-0-dbg/focal-updates,focal-security,now 1.16.3-0ubuntu1.1 arm64 [已安装]
libgstreamer1.0-0/focal-updates,focal-security,now 1.16.3-0ubuntu1.1 arm64 [已安装]
libgstreamer1.0-dev/focal-updates,focal-security,now 1.16.3-0ubuntu1.1 arm64 [已安装]

gst-launch-1.0 / gst-inspect-1.0

gst-launch-1.0 命令检查 GStreamer 的版本信息,将显示 GStreamer 的当前运行版本,但可能不会显示具体的次版本号。
使用 gst-inspect-1.0 命令可以显示 GStreamer 的详细信息,包括版本

(base) nvidia@nvidia-desktop:~$ gst-inspect-1.0 --version
gst-inspect-1.0 version 1.16.3
GStreamer 1.16.3
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

(base) nvidia@nvidia-desktop:~$ gst-launch-1.0 --version
gst-launch-1.0 version 1.16.3
GStreamer 1.16.3
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

查看包管理器安装的gst版本

如果是通过包管理器安装的 GStreamer,可以使用 dpkg 命令来查询特定软件包的版本

dpkg -l | grep gstreamer1.0

测试GStreamer 管道是否运行成功,查看系统能够显示视频

gst-launch-1.0 videotestsrc ! video/x-raw, width=1920, height=1080 ! autovideosink

gst-launch-1.0 是 GStreamer 的命令行工具,用于构建和运行 GStreamer 管道。这个特定的命令行,是用来创建一个简单的 GStreamer 管道,其功能如下:

  1. videotestsrc
    这是一个 GStreamer 源元素,用于生成测试视频模式。它不捕获真实视频,而是生成一个彩色条或其他测试图案,通常用于调试和演示。

  2. video/x-raw
    这是视频流的格式,指定了视频帧的原始数据。在这个例子中,它被用来设置视频帧的宽度和高度。

  3. width=1920, height=1080
    这些参数设置了视频帧的分辨率。在这个例子中,它们被设置为 1920x1080,这是一种常见的高清分辨率。

  4. autovideosink
    这是一个 GStreamer 接收器元素,它自动选择一个合适的视频渲染器来显示视频。在大多数桌面环境中,它会使用 X Window System 来显示视频。

整个命令的作用是创建一个 GStreamer 管道,该管道生成一个测试视频模式,并以 1920x1080 的分辨率显示它。这个命令通常用于测试 GStreamer 管道是否能够正常工作,以及视频显示是否正常。

如果运行这个命令并且看到了一个显示彩色条的窗口,那么这意味着 GStreamer 管道运行成功,系统能够显示视频。如果没有任何显示,或者出现了错误信息,那么可能需要进一步调试,检查 GStreamer 环境和系统配置。

请添加图片描述
这个命令对于测试视频处理应用程序、验证 GStreamer 管道配置、检查显示设备的工作状态等场景非常有用。如果开发视频处理软件,使用 videotestsrc 可以在没有接入实际视频源的情况下进行初步的测试和调试。

播放本地离线视频

gst-launch-1.0 playbin uri=file:///home/nvidia/Downloads/video_test.mp4

注意路径一定是这个形式gst-launch-1.0 playbin uri=file://+终端显示的路径

请添加图片描述说明这个是可以播放的。

显示摄像头的视频流

这是使用的是csi摄像头,其中的编号是3

gst-launch-1.0 v4l2src device=/dev/video3 ! videoconvert ! autovideosink

列出所有正在使用 /dev/video3 设备的进程

fuser /dev/video3
sudo fuser /dev/video3
[sudo] nvidia 的密码: 
/dev/video3:         2311754

v4l2-ctl 工具检查 /dev/video3 设备

请注意,v4l2-ctl 工具提供的信息是静态的,它反映了设备在查询时的状态。如果在使用 GStreamer 或其他视频捕获软件时遇到问题,这些工具提供的信息可能有助于诊断问题,但它们本身并不直接解决视频渲染问题(如绿屏)。

1 )列出所有视频设备

v4l2-ctl --list-devices
v4l2-ctl --list-devices
NVIDIA Tegra Video Input Device (platform:tegra-camrtc-ca):
	/dev/media0

vi-output, twgmsl 0-001a (platform:tegra-capture-vi:0):
	/dev/video0
	/dev/video1
	/dev/video2
	/dev/video3

2 )查询特定设备的详细信息,这个命令会显示设备的名称、驱动版本、功能标志等信息。

 v4l2-ctl --device /dev/video3 --info
Driver Info:
	Driver name      : tegra-video
	Card type        : vi-output, twgmsl 0-001d
	Bus info         : platform:tegra-capture-vi:0
	Driver version   : 5.10.104
	Capabilities     : 0x84200001
		Video Capture
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04200001
		Video Capture
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : tegra-camrtc-ca
	Model            : NVIDIA Tegra Video Input Device
	Serial           : 
	Bus info         : 
	Media version    : 5.10.104
	Hardware revision: 0x00000003 (3)
	Driver version   : 5.10.104
Interface Info:
	ID               : 0x03000051
	Type             : V4L Video
Entity Info:
	ID               : 0x0000004f (79)
	Name             : vi-output, twgmsl 0-001d
	Function         : V4L2 I/O
	Pad 0x01000050   : 0: Sink
	  Link 0x02000055: from remote pad 0x100000c of entity '13e40000.host1x:nvcsi@15a00000-': Data, Enabled

3)如果设备有多个输入源(如摄像头的前置和后置摄像头),可以使用以下命令列出它们:

v4l2-ctl --device /dev/video3 --list-inputs
ioctl: VIDIOC_ENUMINPUT
	Input       : 0
	Name        : Camera 0
	Type        : 0x00000002 (Camera)
	Audioset    : 0x00000000
	Tuner       : 0x00000000
	Standard    : 0x0000000000000000 ()
	Status      : 0x00000000 (ok)
	Capabilities: 0x00000000 (not defined)

注意:不是所有设备都支持多个输入

4)视频设备可以支持多种格式(如分辨率、帧率、像素格式等)。可以使用以下命令来列出支持的格

v4l2-ctl --device /dev/video3 --list-formats-ext
v4l2-ctl --device /dev/video3 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'UYVY' (UYVY 4:2:2)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2880x1860
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1944
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1800
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1536
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1280
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1600x1300
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x960
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x514
			Interval: Discrete 0.033s (30.000 fps)
	[1]: 'NV16' (Y/CbCr 4:2:2)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2880x1860
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1944
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1800
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1536
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1280
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1600x1300
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x960
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x514
			Interval: Discrete 0.033s (30.000 fps)
	[2]: 'UYVY' (UYVY 4:2:2)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2880x1860
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1944
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2592x1800
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1536
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1280
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1920x1080
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1600x1300
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x960
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x720
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x514
			Interval: Discrete 0.033s (30.000 fps)

5)查询和控制视频的流参数,如亮度、对比度、饱和度等。这些参数可能因设备而异。

v4l2-ctl --device /dev/video3 --list-controls
v4l2-ctl --device /dev/video3 --list-controls
v4l2-ctl: unrecognized option '--list-controls'

General/Common options:
  --all              display all information available
  -C, --get-ctrl <ctrl>[,<ctrl>...]
                     get the value of the controls [VIDIOC_G_EXT_CTRLS]
  -c, --set-ctrl <ctrl>=<val>[,<ctrl>=<val>...]
                     set the value of the controls [VIDIOC_S_EXT_CTRLS]
  -D, --info         show driver info [VIDIOC_QUERYCAP]
  -d, --device <dev> use device <dev> instead of /dev/video0
                     if <dev> starts with a digit, then /dev/video<dev> is used
                     Otherwise if -z was specified earlier, then <dev> is the entity name
                     or interface ID (if prefixed with 0x) as found in the topology of the
                     media device with the bus info string as specified by the -z option.
  -e, --out-device <dev> use device <dev> for output streams instead of the
                     default device as set with --device
                     if <dev> starts with a digit, then /dev/video<dev> is used
                     Otherwise if -z was specified earlier, then <dev> is the entity name
                     or interface ID (if prefixed with 0x) as found in the topology of the
                     media device with the bus info string as specified by the -z option.
  -E, --export-device <dev> use device <dev> for exporting DMA buffers
                     if <dev> starts with a digit, then /dev/video<dev> is used
                     Otherwise if -z was specified earlier, then <dev> is the entity name
                     or interface ID (if prefixed with 0x) as found in the topology of the
                     media device with the bus info string as specified by the -z option.
  -z, --media-bus-info <bus-info>
                     find the media device with the given bus info string. If set, then
                     -d, -e and -E options can use the entity name or interface ID to refer
                     to the device nodes.
  -h, --help         display this help message
  --help-all         all options
  --help-io          input/output options
  --help-meta        metadata format options
  --help-misc        miscellaneous options
  --help-overlay     overlay format options
  --help-sdr         SDR format options
  --help-selection   crop/selection options
  --help-stds        standards and other video timings options
  --help-streaming   streaming options
  --help-subdev      sub-device options
  --help-tuner       tuner/modulator options
  --help-vbi         VBI format options
  --help-vidcap      video capture format options
  --help-vidout      vidout output format options
  --help-edid        edid handling options
  -k, --concise      be more concise if possible.
  -l, --list-ctrls   display all controls and their values [VIDIOC_QUERYCTRL]
  -L, --list-ctrls-menus
		     display all controls and their menus [VIDIOC_QUERYMENU]
  -r, --subset <ctrl>[,<offset>,<size>]+
                     the subset of the N-dimensional array to get/set for control <ctrl>,
                     for every dimension an (<offset>, <size>) tuple is given.
  -w, --wrapper      use the libv4l2 wrapper library.
  --list-devices     list all v4l devices. If -z was given, then list just the
                     devices of the media device with the bus info string as
                     specified by the -z option.
  --log-status       log the board status in the kernel log [VIDIOC_LOG_STATUS]
  --get-priority     query the current access priority [VIDIOC_G_PRIORITY]
  --set-priority <prio>
                     set the new access priority [VIDIOC_S_PRIORITY]
                     <prio> is 1 (background), 2 (interactive) or 3 (record)
  --silent           only set the result code, do not print any messages
  --sleep <secs>     sleep <secs>, call QUERYCAP and close the file handle
  --verbose          turn on verbose ioctl status reporting
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Eternal-Student

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

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

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

打赏作者

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

抵扣说明:

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

余额充值