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

Gstreamer 在管道中使用autoaudiosink,播放没有声音的媒体,gstreamer,Gstreamer,我想使用下面的管道播放有声和无声内容。问题是内容没有声音预滚管道,但不能播放 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 ! audio

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

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

我怎样才能解决这个问题呢?

我没有办法让您的管道在命令行上运行。如果我放入管道的音频部分,没有音频的文件将挂起

但是,在您的应用程序中,您可以为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

我没有办法让你的管道在命令行上运行。如果我放入管道的音频部分,没有音频的文件将挂起

但是,在您的应用程序中,您可以为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

async handling=true
添加到autoaudiosink

gst-launch-1.0.exe uridecodebin uri=file:///home/mymediafile.ogv name=d1!发球台名称=t1!队列最大缓冲区大小=2!JPEG!应用接收器 name=myappsink t1!队列自动视频接收器d1!队列音频转换器 ! 音频重采样!autoaudiosink异步处理=true


async handling=true
添加到autoaudiosink

gst-launch-1.0.exe uridecodebin uri=file:///home/mymediafile.ogv name=d1!发球台名称=t1!队列最大缓冲区大小=2!JPEG!应用接收器 name=myappsink t1!队列自动视频接收器d1!队列音频转换器 ! 音频重采样!autoaudiosink异步处理=true


您的目标是获取任何通用URL,将视频作为JPEG编码数据传递到appsink,并播放音频(如果存在)?此外,您是作为应用程序还是从命令行编写此文件?1。是的,这就是我想要实现的。我想将通用URL传递到管道,播放视频和音频(如果存在)。另外,我想通过appsink 2同时捕获帧。我正在写申请书。上面的命令行只是显示如何重现我的问题。您的目标是获取任何通用URL,将视频作为JPEG编码的数据传递到appsink,并播放音频(如果存在)?此外,您是作为应用程序编写还是从命令行编写?1。是的,这就是我想要实现的。我想将通用URL传递到管道,播放视频和音频(如果存在)。另外,我想通过appsink 2同时捕获帧。我正在写申请书。上面的命令行只是显示如何重现我的问题