gstreamer 中用于指定媒体功能的 caps 的语法是什么? Caps 是指定允许的媒体类型的字符串,看起来像“audio/x-raw-int,...”,但我无法找到关于 caps 字符串中允许的内容的良好文档。
语法是:
<type>[,<property>=<value>]...
请注意,该类型不是 MIME 类型,无论它看起来多么像。
您可以使用
gst-inspect
找出哪些 caps 属性元素支持。它将为元素的焊盘提供“焊盘模板”,它将指定支持的上限范围。
GStreamer 插件编写者指南还包含一个已定义类型列表,其中描述了常见音频、视频和图像格式的属性。
在 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...");
}
据我所知,这是格式:
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>, ...}
我看到你在寻找音频。
我只会给你长版本,你可以删除或更改你不需要的部分。但它在 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)。
这就是我在 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
我不确定,因为你的问题是关于语法的,但是“定义类型列表”可能会有所帮助。
部分答案,我相信您已经解决了:
"MIMETYPE,PROPERTY1=VALUE1,PROPERTY2=VALUE2,..."
正式而言,大写字母不是由字符串表示,而是由包含 GstStructures 数组的 GstCaps 对象表示。请参阅文档此处。
如果我们在这里找到明确的答案,我们可以提交该函数的文档补丁
gst_caps_from_string()
来自 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 }