我收到以下错误

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();
}


我希望你能帮助我。

最佳答案

正如@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();

10-08 00:18