0

Qt 6.2.0 / Ubuntu 20.04.

I want to read the title tag from a mkv video file. So at first I'm trying to retrieve all the available tags:

QMediaPlayer p;
p.setSource(QUrl::fromLocalFile(dir.absolutePath()));
QMediaMetaData metadata = p.metaData();
QList<QMediaMetaData::Key> keys = metadata.keys();
foreach (QMediaMetaData::Key key, keys)
{
    qDebug() << key;
}

The list is empty. I'm aware the docs say:

Not all identifiers are supported on all platforms

But I cannot believe no one metadata is there! The title tag is surely there because, say, VLC reads it correctly. Is my approach wrong?

Here it seems QMediaPlayer needs some time to extract the tags. Is there a different approach that avoid this waste of time?

The goal is to extract the title (or other info) from hundreds of video files so I cannot wait so long for each one.

Mark
  • 4,338
  • 7
  • 58
  • 120
  • Does this answer your question? [How to access the meta data of QMediaPlayer?](https://stackoverflow.com/questions/53053201/how-to-access-the-meta-data-of-qmediaplayer) – scopchanov Nov 05 '21 at 22:02
  • Unfortunately I cannot wait. I need to process tons of video files and extract the tags (basically the title). If there is another way that does not require to wait, please feel free to add an answer. I edit the question. – Mark Nov 06 '21 at 10:11
  • https://bugreports.qt.io/secure/Dashboard.jspa – scopchanov Nov 06 '21 at 11:46
  • @scopchanov sorry I don't understand what you are suggesting. I asked for a different approach, showing what I have done until now (the well-known minimal and reproducible example) and you suggest to file a bug report? – Mark Nov 06 '21 at 13:55
  • I suggest you to make a feature request. – scopchanov Nov 06 '21 at 14:25

1 Answers1

0
        QMediaPlayer* player = new QMediaPlayer(this);
        player->setSource(QUrl::fromLocalFile(folderPath + "/" + fileName));
        QTimer timer;
        timer.setSingleShot(true);
        QEventLoop loop;
        connect(player, &QMediaPlayer::mediaStatusChanged, &loop,&QEventLoop::quit);
        connect( &timer, &QTimer::timeout, &loop, &QEventLoop::quit );
        timer.start(1000);
        loop.exec();

        if(timer.isActive())
        {
             qDebug()<<player->metaData().keys();
        }
        else
            qDebug("timeout");

        delete player;