在gstreamer中,cap的语法是什么,指定媒体功能?Caps是指定允许的媒体类型的字符串,看起来像"audio/x-raw-int,..."但是我无法找到关于cap字符串中允许的确切内容的良好文档.
daf*_*daf 11
语法是:
<type>[,<property>=<value>]...
Run Code Online (Sandbox Code Playgroud)
请注意,该类型不是 MIME类型,但它可能看起来像一个类型.
您可以通过使用找出支持哪些大写属性元素gst-inspect.它将为元素的焊盘提供"焊盘模板",它将指定支持的焊盘范围.
GStreamer插件编写器指南还包含已定义类型的列表,这些类型描述了常见音频,视频和图像格式的属性.
小智 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
Run Code Online (Sandbox Code Playgroud)
对于GStreamer 1.0:
audio/x-raw,format=S16LE,channels=2,layout=interleaved
Run Code Online (Sandbox Code Playgroud)
如您所见,使用1.0,您需要组合音频格式.S16LE表示signed + int + 16 width + little endian(= 1234).
在 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"));
Run Code Online (Sandbox Code Playgroud)
在 C 中,假设您想要 videoscale caps 过滤器
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);
...
...
Run Code Online (Sandbox Code Playgroud)
然后设置属性
g_object_set( G_OBJECT ( videoscale_capsfilter ), "caps", videoscalecaps, NULL );
Run Code Online (Sandbox Code Playgroud)
然后您可以将这些添加到 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...");
}
Run Code Online (Sandbox Code Playgroud)
小智 6
据我了解,这是格式:
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>, ...}
Run Code Online (Sandbox Code Playgroud)
这就是我在 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
Run Code Online (Sandbox Code Playgroud)