QAudioDecoder“GStreamer;无法启动解码过程”

时间:2015-11-26 16:51:30

标签: c++ qt gstreamer

我收到以下错误

GStreamer; Unable to start decoding process
当我尝试启动QAudioDecoder时,在控制台中

以下代码:

void Media::decode(Memo* memo){
   decoder = new QAudioDecoder();
   format.setSampleRate(48000);
   format.setChannelCount(1);
   format.setSampleSize(8);
   format.setCodec("audio/pcm");
   format.setSampleType(QAudioFormat::UnSignedInt); 
   format.setByteOrder(QAudioFormat::LittleEndian);
   decoder->setAudioFormat(format);
   decoder->setSourceFilename(memo->getPathMedia());
   connect(decoder, SIGNAL(bufferReady()), this, SLOT(readBuffer()));
   decoder->start();
}



void Media::readBuffer(){
    buffer = decoder->read();
}

我希望你能帮助我。

1 个答案:

答案 0 :(得分:0)

按照@nayana的建议,我使用GST_DEBUG=3启用了GStreamer调试日志,它表明源文件名设置不正确:

filesrc gstfilesrc.c:632:gst_file_src_uri_set_uri:<source> Invalid URI 'file:file:///home/rom1/Music/track01.mp3'

只需删除file:前缀即可。

// In my source file ...
QString source = qvariant_cast<QString>(audioPlayer->property("source"));

source.remove(0, 7);

qDebug() << "Loading media" << source;
decoder.setSourceFilename(source);
decoder.start();