QMediaPlayer says !hasAudio
-
I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.
However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.
player->setURL(localFileURL); if (player->hasAudio()) cout << "yes"; else cout<<"no";I've also tried putting the play() call before the hasAudio check and it's the same result.
Is QMediaPlayer not able to play video files that have audio?
-
I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.
However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.
player->setURL(localFileURL); if (player->hasAudio()) cout << "yes"; else cout<<"no";I've also tried putting the play() call before the hasAudio check and it's the same result.
Is QMediaPlayer not able to play video files that have audio?
@whatabout Some ideas: verify the path with
QFileInfo::exists(). Check the docs if player accepts local filesystem URLs. Check if your local URL is correct (starts withfile://). Check if the audo stream type is supported by Qt. -
@whatabout Some ideas: verify the path with
QFileInfo::exists(). Check the docs if player accepts local filesystem URLs. Check if your local URL is correct (starts withfile://). Check if the audo stream type is supported by Qt.@sierdzio
The video part of it plays just fine.
The same goes for a second file that I tried. Video plays without sound.File 1 has this audio:
Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)File 2 has this audio:
Stream #0:1: Audio: pcm_u8, 11024 Hz, 1 channels, u8, 88 kb/sIf QMediaPlayer doesn't support these basic types it will be fairly useless to me.
I checked and my Debian distro has the gstreamer "basic" plugins for audio.
-
I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.
However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.
player->setURL(localFileURL); if (player->hasAudio()) cout << "yes"; else cout<<"no";I've also tried putting the play() call before the hasAudio check and it's the same result.
Is QMediaPlayer not able to play video files that have audio?
@whatabout I think you have to install audio codecs on windows so that it supports all audios types
-
@whatabout I think you have to install audio codecs on windows so that it supports all audios types
@Ronel_qtmaster said in QMediaPlayer says !hasAudio:
@whatabout I think you have to install audio codecs on windows so that it supports all audios types
OP is not on Windows...
-
@sierdzio
The video part of it plays just fine.
The same goes for a second file that I tried. Video plays without sound.File 1 has this audio:
Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)File 2 has this audio:
Stream #0:1: Audio: pcm_u8, 11024 Hz, 1 channels, u8, 88 kb/sIf QMediaPlayer doesn't support these basic types it will be fairly useless to me.
I checked and my Debian distro has the gstreamer "basic" plugins for audio.
@whatabout said in QMediaPlayer says !hasAudio:
I checked and my Debian distro has the gstreamer "basic" plugins for audio.
OK that is probably not enough, see: https://doc.qt.io/qt-6/videooverview.html#supported-media-formats
-
@whatabout said in QMediaPlayer says !hasAudio:
I checked and my Debian distro has the gstreamer "basic" plugins for audio.
OK that is probably not enough, see: https://doc.qt.io/qt-6/videooverview.html#supported-media-formats
@sierdzio
On x86_64 Debian Linux, I installed "*gstreamer*", which includes all available audio plugins, as well as multimedia-audio-plugins, and there's still no audio detected for these videos. I see no evidence that any audio format is supported.I might be willing to change the distro as an experiment, but I think the fault is with Qt 6.
-
@sierdzio
On x86_64 Debian Linux, I installed "*gstreamer*", which includes all available audio plugins, as well as multimedia-audio-plugins, and there's still no audio detected for these videos. I see no evidence that any audio format is supported.I might be willing to change the distro as an experiment, but I think the fault is with Qt 6.
Is your code using the FFMpeg or GStreamer backend? FFMpeg is the default on most platforms in current Qt6 versions.
What happens if you use the other backend?
What is the output from this with
QT_MEDIA_BACKEND=ffmpegandQT_MEDIA_BACKEND=gstreamer?#include <QCoreApplication> #include <QMediaFormat> #include <QDebug> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QMediaFormat format(QMediaFormat::MPEG4); //QMediaFormat format(QMediaFormat::Matroska); foreach(auto audioCodec, format.supportedAudioCodecs(QMediaFormat::Decode)) { qDebug() << QMediaFormat::audioCodecName(audioCodec) << QMediaFormat::audioCodecDescription(audioCodec); } return 0; }I would expect that AAC is in the list for FFMpeg backend. The 8-bit PCM I would not be so sure about.
-
Is your code using the FFMpeg or GStreamer backend? FFMpeg is the default on most platforms in current Qt6 versions.
What happens if you use the other backend?
What is the output from this with
QT_MEDIA_BACKEND=ffmpegandQT_MEDIA_BACKEND=gstreamer?#include <QCoreApplication> #include <QMediaFormat> #include <QDebug> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QMediaFormat format(QMediaFormat::MPEG4); //QMediaFormat format(QMediaFormat::Matroska); foreach(auto audioCodec, format.supportedAudioCodecs(QMediaFormat::Decode)) { qDebug() << QMediaFormat::audioCodecName(audioCodec) << QMediaFormat::audioCodecDescription(audioCodec); } return 0; }I would expect that AAC is in the list for FFMpeg backend. The 8-bit PCM I would not be so sure about.
@ChrisW67 Here's the output when I use the ffmpeg backend:
Checking HW acceleration for decoder mjpeg [AVHWDeviceContext @ 0x563c30037200] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed Checking HW context: vaapi Using above hw context. Can't obtain QAudioOutput. [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed [mjpeg @ 0x563c30032100] get_buffer() failed failed to get textures for frame true [AVHWFramesContext @ 0x7f3fc8015540] Failed to read image from surface 0x4000002: 20 (the requested function is not implemented). Error transferring the data to system memory: -5 could not map data of QVideoFrame for upload Invalid texture upload for 0x563c30145c40 layer=0 mip=0 Invalid texture upload for 0x7f4068001460 layer=0 mip=0 Segmentation faultI would note that FFplay is what I use the play video files on a daily basis, so I know that ffmpeg/ffplay work reliably on their own. Somehow Qt6 isn't using it correctly.
As for gstreamer that's what it's using by default.
-
Does anyone know who it is at Qt corporate that is developing QMediaPlayer? They need to be alerted about these problems.
@whatabout You would raise a bug report at https://bugreports.qt.io/