我在 gstreamer 中看到过这种管道运行命令:
例如,
gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, framerate=25/1, width=640, height=360 ! xvimagesink
Run Code Online (Sandbox Code Playgroud)
我已经阅读了一些video/x-raw, format=I420, framerate=25/1, width=640, height=360指定媒体类型的页面。但我无法理解它会产生什么效果 - 是将输入转换为指定的帧率/格式/宽度/高度等......还是就像指定输入已经在这个帧率/宽度/ht中一样?如果它只是指定输入在此帧速率等中,它会对管道产生什么影响......而不是转换。
它真的有必要还是我们可以忽略它?
max*_*kin 10
他们将这种video/x-raw, format=I420, framerate=25/1, width=640, height=360东西简称为“能力”或“上限”。
有时需要明确指定在 gstreamer 管道中的元素之间流动的数据类型。而 caps 就是做到这一点的方法。
为什么有时需要这样做?因为一些 gstreamer 元素可以接受(或产生)多种类型的媒体。您可以使用以下gst-inspect命令查看此内容:
$ gst-inspect videotestsrc
...
Pad Templates:
SRC template: 'src'
Availability: Always
Capabilities:
video/x-raw-yuv
format: YUY2
color-matrix: { sdtv, hdtv }
chroma-site: { mpeg2, jpeg }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-raw-yuv
format: UYVY
color-matrix: { sdtv, hdtv }
chroma-site: { mpeg2, jpeg }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-raw-yuv
format: YVYU
color-matrix: { sdtv, hdtv }
...
Run Code Online (Sandbox Code Playgroud)
这意味着videotestsrc具有src可以产生各种格式(YUY2、UYVY、YVYU 等)、大小、帧率等输出的pad 。
同样适用于xvimagesink:
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
video/x-raw-rgb
framerate: [ 0/1, 2147483647/1 ]
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
video/x-raw-yuv
framerate: [ 0/1, 2147483647/1 ]
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
Run Code Online (Sandbox Code Playgroud)
它能够查看各种格式的数据流。
GStreamer 使用称为caps 协商的过程来决定在两个元素之间使用哪种具体数据格式。如果用户未提供任何功能,它会尝试选择“最佳拟合”格式。这就是为什么可以从管道中删除功能并且它仍然可以工作的原因:
$ gst-launch-1.0 -v videotestsrc ! xvimagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstXvImageSink:xvimagesink0.GstPad:sink: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Run Code Online (Sandbox Code Playgroud)
我添加了-v标志以查看 gstreamser 实际决定使用的大写字母。
但有时会出现 gstreamser 无法协商数据格式或您有不同偏好的情况。
例如,在从套接字读取流的管道的情况下,不可能猜测某些数据格式,您需要提供正确的功能。
通过执行这两个管道,您可以看到指定上限会有所不同:
$ gst-launch -v videotestsrc ! 'video/x-raw-yuv, width=600, height=600' ! xvimagesink
$ gst-launch -v videotestsrc ! 'video/x-raw-yuv, width=60, height=60' ! xvimagesink
Run Code Online (Sandbox Code Playgroud)
重要的是要了解功能不会转换数据,而是指定将生成或使用哪些格式元素。
| 归档时间: |
|
| 查看次数: |
4733 次 |
| 最近记录: |