在管道中使用autoaudiosink并播放没有声音的媒体

时间:2015-06-26 14:46:34

标签: gstreamer

我想使用下面的管道来播放声音和没有声音的内容。问题是内容没有声音PREROLLING管道,但不播放

gst-launch-1.0.exe uridecodebin uri=file:///home/mymediafile.ogv name=d1 ! tee name=t1 ! queue max-size-buffers=2 ! jpegenc ! appsink name=myappsink t1. ! queue ! autovideosink d1. ! queue ! audioconvert ! audioresample ! autoaudiosink

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

我发现没有办法让你的管道进入命令行。如果我放入管道的音频部分,没有音频的文件会挂起。

然而,在您的应用程序中,您将能够为pad_added事件添加信号,并且仅在需要时添加管道的音频部分。一些伪代码:

void decodebin_pad_added(GstElement *decodebin, GstPad *new_pad, gpointer user_data) {
 GstElement* pipeline = (GstElement*)user_data;

 GstCaps* audio_caps = gst_caps_from_string("audio/x-raw");
 GstCaps* pad_caps = gst_pad_get_current_caps(new_pad);
 if(! gst_caps_can_intersect(pad_caps, audio_caps)) {
  return;
 }

 GstElement* audio_pipeline = gst_parse_launch("queue ! audioconvert ! audioresample ! autoaudiosink", NULL);

 gst_bin_add(GST_BIN(pipeline), audio_pipeline);

 GstElement* decodebin = gst_bin_get_by_name(GST_BIN(pipeline), "d1");
 gst_element_link(decodebin, audio_pipeline);
 gst_object_unref(decodebin);
}

void decodebin_no_more_pads(GstElement *decodebin, gpointer user_data) {
    GstElement* pipeline = (GstElement*)user_data;

    gst_element_set_state(pipeline, GST_PLAYING);
}

GstElement* pipeline = gst_parse_launch("uridecodebin uri=file:///home/mymediafile.ogv name=d1 ! tee name=t1 ! queue max-size-buffers=2 ! jpegenc ! appsink name=myappsink t1. ! queue ! autovideosink", NULL);

GstElement* decodebin = gst_bin_get_by_name(GST_BIN(pipeline), "d1");
g_signal_connect(decodebin, "pad-added", G_CALLBACK(decodebin_pad_added), pipeline);
g_signal_connect(decodebin, "no-more-pads", G_CALLBACK(decodebin_no_more_pads), pipeline);

gst_element_set_state(pipeline, GST_STATE_PAUSED); //pause to make demuxer and decoders get setup and find out what's in the file

答案 1 :(得分:0)

async-handling=true添加到自动音频接收器。

  

gst-launch-1.0.exe uridecodebin uri = file:///home/mymediafile.ogv   名称= d1!发球名称= t1!队列max-size-buffers = 2! jpegenc!应用程式   名称= myappsink t1。 !排队!自动视频接收器d1。 !排队!音频转换   ! audioresample! autoaudiosink async-handling = true