gstreamer caps 语法是什么?

发布于 2024-08-23 09:42:58 字数 116 浏览 5 评论 0原文

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

What is the syntax for caps, specifying media capabilities, in gstreamer? Caps are strings that specify the type of media allowed and look like "audio/x-raw-int,..." but I haven't been able to find good documentation on exactly what is allowed in a caps string.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

揽月 2024-08-30 09:42:59

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

I'm unsure due to your question is about syntax, but "list of defined types" may be helpful.

独享拥抱 2024-08-30 09:42:59

部分答案,我相信您已经解决了:

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

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

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

a partial answer, which i'm sure you've worked out already:

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

formally, caps are not represented by strings but by a GstCaps object containing an array of GstStructures. see the documentation here.

perhaps if we work out a definitive answer here we could submit a documentation patch for the function gst_caps_from_string()

万劫不复 2024-08-30 09:42:59

来自 x264enc 源代码: https 对于此CAPS, ://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 }")
    );

,当通过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 }

from x264enc source code: 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 }")
    );

for this CAPS, when inpstected by gst-inspect, it's like:

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 }
你げ笑在眉眼 2024-08-30 09:42:58

语法是:

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

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

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

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

The syntax is:

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

Note that the type is not a MIME type, however much it may look like one.

You can find out which caps properties elements support by using gst-inspect. It will proviide "pad templates" for the element's pads, which will specify the ranges of caps supported.

The GStreamer plugin writer's guide also contains a list of defined types which describes properties for common audio, video and image formats.

左秋 2024-08-30 09:42:58

在 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 中,假设您想要 videoscale caps 过滤器,

GstElement *videoscale_capsfilter;
GstCaps* videoscalecaps;
videoscalecaps = gst_caps_new_simple ("video/x-raw-rgb",
                          "width", G_TYPE_INT, 640, //GetWidth(),
                          "height", G_TYPE_INT, 480,//GetHeight(),
                            NULL); 
...
...
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...");
}

In Java, for 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"));

In C, say you want videoscale caps filter

GstElement *videoscale_capsfilter;
GstCaps* videoscalecaps;
videoscalecaps = gst_caps_new_simple ("video/x-raw-rgb",
                          "width", G_TYPE_INT, 640, //GetWidth(),
                          "height", G_TYPE_INT, 480,//GetHeight(),
                            NULL); 
...
...
videoscale = gst_element_factory_make ("videoscale", "videoscale");
g_assert (videoscale);
videoscale_capsfilter = gst_element_factory_make ("capsfilter", "videoscale_capsfilter");
g_assert (videoscale_capsfilter);
... 
...

then set properties

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

then you could add these to bin and link them the way you have constructed media pipeline using 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...");
}
只等公子 2024-08-30 09:42:58

据我了解,这是格式:

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>, ...}

Here is the format as far as I understand it:

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>, ...}
不知所踪 2024-08-30 09:42:58

我发现你在寻找音频。

我只会给你长版本,你可以删除或更改不需要的部分。但它在 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 宽度 + 小尾数 (=1234)。

I see you are after audio.

I'll just give you the long version, you can drop or change the parts you don't need. It changes between GStreamer 0.10 and GStreamer 1.0 though. I'll give both:

for GStreamer 0.10:

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

for GStreamer 1.0:

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

As you can see, with 1.0, you will need to combine the audio format. S16LE means signed + int + 16 width + little endian (=1234).

醉态萌生 2024-08-30 09:42:58

这就是我在 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文