Gstreamer 播放时无法调节 Pipeline 音量,无法寻时,无法查询时长

问题描述 投票:0回答:1

我正在通过 C++ 使用 Gstreamer。我正在尝试使用 rawaudioparse 播放原始 pcm 缓冲区。虽然可以播放,但是播放时不能调节pipeline的音量,不能找时间,不能查询时长。

这是我试过的代码。

    pipeline = gst_parse_launch("appsrc name=src ! rawaudioparse format=pcm num-channels=1 sample-rate=44100 pcm-format=GST_AUDIO_FORMAT_S32LE ! volume name=vol ! audioconvert ! audioresample ! autoaudiosink --gst-debug=2", NULL);

    GstElement* appsrc = gst_bin_get_by_name(GST_BIN(pipeline), "src");
    GstStreamVolume* volume = (GstStreamVolume*)gst_bin_get_by_name(GST_BIN(pipeline), "vol");

(buf = ..., bufsize = ...)


    GstBuffer* buffer = gst_buffer_new_allocate(NULL, bufsize, NULL);

    gst_buffer_fill(buffer, 0, buf, bufsize);

    gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);
    gst_app_src_end_of_stream(GST_APP_SRC(appsrc));

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

当我试图寻找

gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), 10 * GST_MSECOND);
它失败了,没有进行任何寻求

当我尝试设置音量时

  gst_stream_volume_set_volume((GstStreamVolume*)pipeline, GST_STREAM_VOLUME_FORMAT_CUBIC, volumelevel);
音量不变。

当我尝试查询持续时间时,持续时间产生 -1

    gint64 duration;
    gst_element_query_duration(pipeline, GST_FORMAT_TIME, &duration);
    std::cout << "Duration: " << duration << std::endl;
c++ gstreamer gstreamer-1.0 python-gstreamer gstreamer-0.10
1个回答
0
投票

源 appsrc 默认设置为 live。使用 stream-type=GST_APP_STREAM_TYPE_SEEKABLE 更改源属性以执行查找操作。也在应用程序中实现搜索

© www.soinside.com 2019 - 2024. All rights reserved.