17

在 gstreamer 中,caps 的语法是什么,指定媒体功能?Caps 是指定允许的媒体类型的字符串,看起来像“audio/x-raw-int,...”,但我无法找到关于 caps 字符串中允许的确切内容的良好文档。

4

8 回答 8

14

语法是:

<type>[,<property>=<value>]...

请注意,该类型不是MIME 类型,无论它看起来多么像。

您可以使用 找出哪些 caps 属性元素支持gst-inspect。它将为元素的焊盘提供“焊盘模板”,这将指定支持的大写范围。

GStreamer 插件编写者指南还包含一个定义类型列表,描述了常见音频、视频和图像格式的属性。

于 2011-11-11T05:49:54.860 回答
8

这是我理解的格式:

caps = <caps_name>, <field_name>=<field_value>[; <caps>]
<caps_name> = image/jpeg etc
<field_name> = width etc
<field_value> = <fixed_field_value>|<ranged_field_value>|<multi_field_value>
<fixed_field_value> = 800 etc
<ranged_field_value> = [<lower_value>, <upper_value>]
<multi_field_value> = {<fixed_field_value>, <fixed_field_value>, <fixed_field_value>, ...}
于 2013-05-16T14:08:28.633 回答
7

在 Java 中,对于 gstreamer-java

final Element videofilter = ElementFactory.make("capsfilter", "flt");
videofilter.setCaps(Caps.fromString("video/x-raw-yuv, width=720, height=576"
+ ", bpp=32, depth=32, framerate=25/1"));

在 C 中,假设您想要视频缩放上限过滤器

GstElement *videoscale_capsfilter;
GstCaps* videoscalecaps;
...
...
videoscale = gst_element_factory_make ("videoscale", "videoscale");
g_assert (videoscale);
videoscale_capsfilter = gst_element_factory_make ("capsfilter", "videoscale_capsfilter");
g_assert (videoscale_capsfilter);
... 
...

然后设置属性

g_object_set( G_OBJECT ( videoscale_capsfilter ),  "caps",  videoscalecaps, NULL );

然后您可以将这些添加到 bin 并按照您使用 gst-launch 构建媒体管道的方式链接它们

/* Add Elements to the Bin */
gst_bin_add_many (GST_BIN (pipeline),source ,demux ,decoder ,videoscale ,videoscale_capsfilter ,ffmpegcolorspace ,ffmpegcolorspace_capsfilter,autovideosink,NULL);

 /* Link confirmation */
if (!gst_element_link_many (demux, decoder,videoscale, videoscale_capsfilter ,ffmpegcolorspace, ffmpegcolorspace_capsfilter, autovideosink, NULL)){
 g_warning ("Main pipeline link Fail...");
}

/* Dynamic Pad Creation */
if(! g_signal_connect (source, "pad-added", G_CALLBACK (on_pad_added),demux))
{
 g_warning ("Linking Fail...");
}
于 2011-09-19T18:24:39.413 回答
7

我看到你在追求音频。

我只会给你长版本,你可以删除或更改你不需要的部分。它在 GStreamer 0.10 和 GStreamer 1.0 之间变化。我会给两个:

对于 GStreamer 0.10:

audio/x-raw-int,rate=44100,channels=2,width=16,depth=16,endianness=1234,signed=true

对于 GStreamer 1.0:

audio/x-raw,format=S16LE,channels=2,layout=interleaved

如您所见,使用 1.0,您将需要组合音频格式。S16LE 表示有符号 + int + 16 宽度 + little endian (=1234)。

于 2013-08-12T16:39:53.380 回答
5

This is how i use it in python...HTH

caps = gst.Caps("video/x-raw-yuv,format=(fourcc)AYUV,width=704,height=480")
capsFilter = gst.element_factory_make("capsfilter")
capsFilter.props.caps = caps
于 2010-04-01T18:41:42.440 回答
3

由于您的问题是关于语法,我不确定,但“定义类型列表”可能会有所帮助。

于 2011-09-01T11:42:44.227 回答
2

一个部分答案,我相信你已经解决了:

"MIMETYPE,PROPERTY1=VALUE1,PROPERTY2=VALUE2,..."

正式地,大写字母不是由字符串表示,而是由包含 GstStructures 数组的 GstCaps 对象表示。请参阅此处的文档。

也许如果我们在这里找到一个明确的答案,我们可以为该函数提交一个文档补丁gst_caps_from_string()

于 2010-06-15T22:34:11.323 回答
1

来自 x264enc 源代码:https ://github.com/GStreamer/gst-plugins-ugly/blob/master/ext/x264/gstx264enc.c#L693-L704

static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
    GST_PAD_SRC,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("video/x-h264, "
        "framerate = (fraction) [0/1, MAX], "
        "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ], "
        "stream-format = (string) { avc, byte-stream }, "
        "alignment = (string) au, "
        "profile = (string) { high-4:4:4, high-4:2:2, high-10, high, main,"
        " baseline, constrained-baseline, high-4:4:4-intra, high-4:2:2-intra,"
        " high-10-intra }")
    );

对于这个 CAPS,当被 gst-inspect 检查时,它就像:

Pad Templates:
  SRC template: 'src' 
    Availability: Always
    Capabilities:
      video/x-h264
              framerate: [ 0/1, 2147483647/1 ]
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
          stream-format: { (string)avc, (string)byte-stream }
              alignment: au
                profile: { (string)high-4:4:4, (string)high-4:2:2, (string)high-10, (string)high, (string)main, (string)baseline, (string)constrained-baseline, (string)high-4:4:4-intra, (string)high-4:2:2-intra, (string)high-10-intra }
于 2022-01-06T04:17:44.613 回答