Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAudioDecoder does not expose metadata (Linux, GStreamer)



  • Hi there,

    current Qt (5.13.1) does not seem to make audio file (mp3 or ogg) metadata available on Linux with gstreamer backend. I manage to decode the audio data just fine. However the MetadataAvailabe signal never fires. Also calling decoder->isMetaDataAvailable() always returns false. Is this expected behaviour? If so, how do I access metadata on this platform?

    Thanks
    Felix



  • @Hazzl said in QAudioDecoder does not expose metadata (Linux, GStreamer):

    audio file (mp3 or ogg) metadata available on Linux

    just in case, are you positive the audio file you're working with has actual metadata?



  • @Pablo-J-Rogina yes, the files have associated tags. Those are also the things that interest me. However, wouldn't other metadata like bitrate or duration show up in any case of a supported encoding without there being any tags?



  • This is the code I'm working with:

    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QTextStream out(stdout, QIODevice::WriteOnly);
        QAudioDecoder player;
        QAudioFormat format;
    
        format.setChannelCount(2);
        format.setSampleSize(16);
        format.setSampleRate(48000);
        format.setCodec("audio/pcm");
        format.setSampleType(QAudioFormat::SignedInt);
        player.setSourceFilename(a.arguments().at(1));    
        player.setAudioFormat(format);
        player.connect(&player, &QAudioDecoder::finished, &a, &QCoreApplication::quit);
        player.connect(&player, &QAudioDecoder::bufferReady, [&]
        {
            player.read();
        });
        player.connect(&player, &QMediaObject::metaDataAvailableChanged, [&]
        {
            if (player.isMetaDataAvailable())
            {
                for (QString key: player.availableMetaData())
                    out << key << " = " << player.metaData(key).toString() << endl;
                a.quit();
            }
        });
        player.start();
    
        return a.exec();
    }
    

    This goes through the entire file and discards the decoded data. However I never get any metadata out. Curiously enough, if I replace QAudioDecoder with a QMediaPlayer then everything works as expected. Can anybody point out where I go wrong with my QAudioDecoder?


  • Lifetime Qt Champion

    Hi,

    I haven't take a look at the code of the class but from the documentation description I would say that its goal is to play efficiently local files without all the bells and whistles provided by QMediaPlayer.


Log in to reply