valbok / QtAVPlayer

Free and open-source Qt Media Player library based on FFmpeg, for Linux, Windows, macOS, iOS and Android.
MIT License
306 stars 60 forks source link

Integration in digiKam (Qt5): some helps required. #428

Closed cgilles closed 6 months ago

cgilles commented 10 months ago

Hi,

First, thanks for sharing your code. It's very appreciated.

In digiKam, we would use the ffmpeg backend to play audio and video as the GStreamer backend from Qt5Multimedia is a mess for end users.

For 5/6 years, we have used QtAV for that. It works very well but with recent releases of ffmpeg, QtAV does not work well. QtAV is not maintained, so we need to find an alternative. QtAVPlayer is a good candidate.

digiKam can be compiled with Qt5 or Qt6. QtAvPlayer will be only used with Qt5, as the version of Qt6 requires QtMultimedia 6.5.0 or later as it's based on ffmpeg backend.

I created a git branch in digiKam named qtavplayer. We have a video player and an audio player. Code is here :

https://invent.kde.org/graphics/digikam/-/tree/development/qtavplayer/core/libs/video/player/QtAVPlayer?ref_type=heads

Note: QtAVPlayer code have been hosted in digiKam core without modification:

https://invent.kde.org/graphics/digikam/-/tree/development/qtavplayer/core/libs/video/QtAVPlayer?ref_type=heads

It's work but we faced some problems:

  1. We need a code to rotate the video rendering (90/180/270...) according to the orientation metadata from the media. The user can also rotate manually in the GUI. We can do it easily with Qt6:Multimedia or QtAV API, but we haven't found a solution yet with QtAVPlayer. Code relevant is commented for the moment:

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/mediaplayerview.cpp?ref_type=heads#L328

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/mediaplayerview.cpp?ref_type=heads#L393

  1. The audioplayer : in digiKam we have a photo slideshow tool where a soundtrack can be played in the background. So an audio player was created for that with QtAVPlayer where 2 dysfunctions can be seen:   --> the audio position while playing is always null:

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/daudioplayer.cpp?ref_type=heads#L70

--> the audio volume cannot be changed (it's always to max), even if we pass a float value [0.0 - 1.0]

Note : with the videoplayer, the 2 last problems are not present.

Thanks in advance for your guidance.

Best regards

Gilles Caulier

cgilles commented 10 months ago

Screenshot of the AudioPlayer :

https://i.imgur.com/Q7JIkbW.png

Note that audio track length is well reported here.

Screenshot of the VideoPlayer:

https://i.imgur.com/2DEaimx.png

Gilles Caulier

valbok commented 9 months ago

Hi Gilles, thanks for trying QAVPlayer I tried to build in on 22.04 Ubuntu, and it has a dep to KF5 which could not resolve.

Is it possible to build digiKam on Ubuntu?

valbok commented 9 months ago

We can do it easily with Qt6:Multimedia or QtAV API,

QAVPlayer returns video frames that you could render as you wish. Technically you can do whatever you want. Idea to use Qt renderers. Which is more efficient is QML.

Ic you use QVideoWidget as a video output. https://doc.qt.io/qt-5/qvideowidget.html - not sure if it supports orientations at all. As I remember it uses QPainter for Qt5 without hw acceleration - which is quite slow. And requires to convert all frames to AV_PIX_FMT_RGB32 - which twice very slow. Looks you would need to look at QGraphicsVideoItem::setRotation and which potentially could give you opengl renderer.

valbok commented 9 months ago

the audio position while playing is always null: // qCDebug(DIGIKAM_GENERAL_LOG) << "Audio position:" << d->player->position();

do you hear sound? You could export QT_LOGGING_RULES="qt.QtAVPlayer.debug=true" and see the debug output.

QAVPlayer->position() should show the synced pts of the playback. Audio and video streams are synced. each frame has its ows frame.pts() in seconds which must be available if it is valid frame.

Also, if you need only audio frames, you could disable video streams by on QAVPlayer::LoadedMedia call p.setVideoStreams({}); it will not decode video streams at all.

valbok commented 9 months ago

QGraphicsVideoItem::setRotation

If QtAV worked for you and had some renderers, you could try to adapt it for QVideoFrame's ?

cgilles commented 9 months ago

Hi Gilles, thanks for trying QAVPlayer I tried to build in on 22.04 Ubuntu, and it has a dep to KF5 which could not resolve.

Is it possible to build digiKam on Ubuntu?

yes, sure, here digikam is compiled under Unbuntu 18.04, 22.04, and 23.10.

There is a script to install dependencies here :

https://invent.kde.org/graphics/digikam/-/blob/master/project/scripts/installdeps-ubuntu.sh?ref_type=heads

Warning, this script drop snap from the system. If you want to not touch to this feature, remove lines from there to en end :

https://invent.kde.org/graphics/digikam/-/blob/master/project/scripts/installdeps-ubuntu.sh?ref_type=heads#L306

Gilles Caulier

cgilles commented 9 months ago

the audio position while playing is always null: // qCDebug(DIGIKAM_GENERAL_LOG) << "Audio position:" << d->player->position();

do you hear sound?

yes. it's fine.

You could export QT_LOGGING_RULES="qt.QtAVPlayer.debug=true" and see the debug output.

I will do it.

QAVPlayer->position() should show the synced pts of the playback. Audio and video streams are synced. each frame has its ows frame.pts() in seconds which must be available if it is valid frame.

But here, there is no video stream as media loaded are always audio track, as m4a, mp3, wav, etc... Did you already test this kind of configuration.

Also, if you need only audio frames, you could disable video streams by on QAVPlayer::LoadedMedia call p.setVideoStreams({}); it will not decode video streams at all.

See my previous comment.

Gilles Caulier

cgilles commented 9 months ago

QGraphicsVideoItem::setRotation

If QtAV worked for you and had some renderers, you could try to adapt it for QVideoFrame's ?

No. The goal is to drop definitively qtav code from digiKam core (git/master)

Gilles Caulier

valbok commented 9 months ago

Did you already test this kind of configuration.

Tested wav, mp3 files, and never seen empty QAVPlayer::position(), also https://github.com/valbok/QtAVPlayer/blob/master/tests/auto/integration/qavplayer/tst_qavplayer.cpp#L249

valbok commented 9 months ago

We can do it easily with Qt6:Multimedia or QtAV API,

Ic you already use QGraphicsVideoItem for qtmm mediaplayer
https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/qtmm/mediaplayerview.cpp?ref_type=heads#L223

cgilles commented 9 months ago

We can do it easily with Qt6:Multimedia or QtAV API,

Ic you already use QGraphicsVideoItem for qtmm mediaplayer https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/qtmm/mediaplayerview.cpp?ref_type=heads#L223

Sure but this code is for the Qt6 version, not the Qt5...

Gilles

valbok commented 9 months ago

Screenshot of the AudioPlayer :

https://i.imgur.com/Q7JIkbW.png

Note that audio track length is well reported here.

added qDebug() << d->player->position() and it works, Elapsed is also updated

cgilles commented 9 months ago

Where did you add the qdebug exactly. because i already do it here:

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/daudioplayer.cpp?ref_type=heads#L70

...and i can see this:

digikam.dplugin.generic: Playing: QUrl("file:///home/gilles/Music/Agnes Obel - Myopia (2020)/03 - Island Of Doom.mp3") mjpeg : supported hardware device contexts: cuda vaapi Available pixel formats: yuvj420p : AVPixelFormat( 12 ) cuda : AVPixelFormat( 117 ) vaapi : AVPixelFormat( 44 ) Using software decoding in yuvj420p digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0 digikam.general: Audio position: 0

Gilles Caulier

valbok commented 9 months ago

doing exactly there, where you mentioned.

valbok commented 9 months ago

strange that volume does not work, but this helps https://github.com/valbok/QtAVPlayer/pull/430

valbok commented 9 months ago

btw doing

  1. Preview and set the volume
  2. Start sliding, -> always max volume is used, it sets volume to 1.0, is it correct?
cgilles commented 9 months ago

btw doing

1. Preview and set the volume

2. Start sliding, -> always max volume is used, it sets volume to 1.0, is it correct?

more and less for the moment. typically the volume must be saved and restored volume between session...

Gilles

valbok commented 9 months ago

Sure but this code is for the Qt6 version, not the Qt5...

All video frames will go to https://doc.qt.io/qt-5/qgraphicsvideoitem.html#videoSurface-prop

the same idea as QVideoWidget.

cgilles commented 9 months ago

strange that volume does not work, but this helps #430

I sync you last commit in digiKam branch. No i can change the volume. Thanks.

Audio position still zero to the console, as i can see...

Gilles

cgilles commented 9 months ago

Did you seen this warning from G++ under Ubuntu 23.04 with Qt5.15.10:

[ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavstream.cpp.o [ 53%] Built target half_mt_cli [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavstreamframe.cpp.o [ 53%] Built target core_videotools_obj [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavsubtitlecodec.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavsubtitleframe.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideobuffer_cpu.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideobuffer_gpu.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideocodec.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideofilter.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideoframe.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideoinputfilter.cpp.o [ 53%] Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideooutputfilter.cpp.o In file included from /usr/include/aarch64-linux-gnu/qt5/QtMultimedia/qvideoframe.h:46, from /usr/include/aarch64-linux-gnu/qt5/QtMultimedia/QVideoFrame:1, from /home/gilles/Devel/8.x/core/libs/video/QtAVPlayer/qavvideoframe.h:14, from /home/gilles/Devel/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:8: /usr/include/aarch64-linux-gnu/qt5/QtMultimedia/qabstractvideobuffer.h:111:12: warning: ‘virtual uchar QAbstractPlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int)’ was hidden [-Woverloaded-virtual=] 111 | uchar map(MapMode mode, int numBytes, int bytesPerLine) override; | ^~~ /home/gilles/Devel/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:192:9: note: by ‘virtual int PlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int, uchar*)’ 192 | int map(MapMode mode, int numBytes, int bytesPerLine[4], uchar *data[4]) override | ^~~ [ 53%] Built target core_qtavplayer_obj

Gilles

cgilles commented 9 months ago

strange that volume does not work, but this helps #430

I sync you last commit in digiKam branch. No i can change the volume. Thanks.

Audio position still zero to the console, as i can see...

Gilles

Your last changes about audio volume introduce a 2/3s delay before to take effect, as when i change volume or when i stop/pause play. It's visible with simple audio player and with video player (as the video is paused/stopped but audio continue to play a little bit).

Gilles

valbok commented 9 months ago

2/3s delay before to take effect

Right, looks bug, volume is changed only when new frame is arrived which is not nice. Thanks, will fix

valbok commented 9 months ago

/home/gilles/Devel/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:192:9: note: by ‘virtual int PlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int, uchar_)’ 192 | int map(MapMode mode, int numBytes, int bytesPerLine[4], uchar *data[4]) override | ^~~ [ 53%] Built target core_qtavplayer_obj

Gilles

https://github.com/valbok/QtAVPlayer/pull/432

cgilles commented 9 months ago

/home/gilles/Devel/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:192:9: note: by ‘virtual int PlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int, uchar_)’ 192 | int map(MapMode mode, int numBytes, int bytesPerLine[4], uchar *data[4]) override | ^~~ [ 53%] Built target core_qtavplayer_obj Gilles

432

ok, i will backport this commit late this evening.

Look also all warnings that i can see under Ubuntu 23.10 where ffmpeg 5.1 is present :

gilles@KU23:~/devel/GIT/8.x/build/core/libs/video$ pwd /home/gilles/devel/GIT/8.x/build/core/libs/video gilles@KU23:~/devel/GIT/8.x/build/core/libs/video$ make Automatic MOC for target core_videotoolscommon_obj Built target core_videotoolscommon_obj_autogen Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/core_videotoolscommon_obj_autogen/mocs_compilation.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/manager/vidslidesettings.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/manager/ffmpegbinary.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/manager/ffmpeglauncher.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/manager/vidslidetask.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/manager/vidslidethread.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/ffmpegconfighelper.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotoolscommon_obj.dir/player/vidplayerdlg.cpp.o Built target core_videotoolscommon_obj Automatic MOC for target core_videotools_obj Built target core_videotools_obj_autogen Building CXX object core/libs/video/CMakeFiles/core_videotools_obj.dir/core_videotools_obj_autogen/mocs_compilation.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotools_obj.dir/player/QtAVPlayer/daudioplayer.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotools_obj.dir/player/QtAVPlayer/dvideowidget.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotools_obj.dir/player/QtAVPlayer/mediaplayerview.cpp.o Building CXX object core/libs/video/CMakeFiles/core_videotools_obj.dir/player/QtAVPlayer/slidevideo.cpp.o Built target core_videotools_obj Automatic MOC for target core_qtavplayer_obj Built target core_qtavplayer_obj_autogen Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/core_qtavplayer_obj_autogen/mocs_compilation.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudiocodec.cpp.o /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudiocodec.cpp: In member function ‘QAVAudioFormat QAVAudioCodec::audioFormat() const’: /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudiocodec.cpp:41:38: warning: ‘AVCodecContext::channels’ is deprecated [-Wdeprecated-declarations] 41 | format.setChannelCount(d->avctx->channels); | ^~~~ In file included from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudiocodec.cpp:13: /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:1006:9: note: declared here 1006 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudiocodec.cpp:41:38: warning: ‘AVCodecContext::channels’ is deprecated [-Wdeprecated-declarations] 41 | format.setChannelCount(d->avctx->channels); | ^~~~ /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:1006:9: note: declared here 1006 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudiocodec.cpp:41:38: warning: ‘AVCodecContext::channels’ is deprecated [-Wdeprecated-declarations] 41 | format.setChannelCount(d->avctx->channels); | ^~~~ /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:1006:9: note: declared here 1006 | int channels; | ^~~~ Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudiofilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudioframe.cpp.o /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp: In member function ‘QByteArray QAVAudioFrame::data() const’: /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:125:61: warning: ‘int64_t av_get_default_channel_layout(int)’ is deprecated [-Wdeprecated-declarations] 125 | int64_t outChannelLayout = av_get_default_channel_layout(fmt.channelCount()); | ~~~~~~~^~~~~~ In file included from /usr/include/x86_64-linux-gnu/libavutil/frame.h:33, from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavframe_p.h:25, from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:9: /usr/include/x86_64-linux-gnu/libavutil/channel_layout.h:457:9: note: declared here 457 | int64_t av_get_default_channel_layout(int nb_channels); | ^~~~~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:37: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:37: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:37: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:62: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:62: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:62: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:115: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:115: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:115: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:151:107: warning: ‘int av_get_channel_layout_nb_channels(uint64_t)’ is deprecated [-Wdeprecated-declarations] 151 | int64_t channelLayout = (frame->channel_layout && frame->channels == av_get_channel_layout_nb_channels(frame->channel_layout)) | ~~~~~~~^~~~~ /usr/include/x86_64-linux-gnu/libavutil/channel_layout.h:449:5: note: declared here 449 | int av_get_channel_layout_nb_channels(uint64_t channel_layout); | ^~~~~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:152:18: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 152 | ? frame->channel_layout | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:152:18: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 152 | ? frame->channel_layout | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:152:18: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 152 | ? frame->channel_layout | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:153:48: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 153 | : av_get_default_channel_layout(frame->channels); | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:153:48: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 153 | : av_get_default_channel_layout(frame->channels); | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:153:48: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 153 | : av_get_default_channel_layout(frame->channels); | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:153:40: warning: ‘int64_t av_get_default_channel_layout(int)’ is deprecated [-Wdeprecated-declarations] 153 | : av_get_default_channel_layout(frame->channels); | ~~~~~~~^~~~~~~ /usr/include/x86_64-linux-gnu/libavutil/channel_layout.h:457:9: note: declared here 457 | int64_t av_get_default_channel_layout(int nb_channels); | ^~~~~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:163:40: warning: ‘SwrContext swr_alloc_set_opts(SwrContext, int64_t, AVSampleFormat, int, int64_t, AVSampleFormat, int, int, void)’ is deprecated [-Wdeprecated-declarations] 163 | d->swr_ctx = swr_alloc_set_opts(nullptr, | ~~~~^~~ 164 | outChannelLayout, outFormat, outSampleRate, | ~~~~~~~~~~~ 165 | channelLayout, AVSampleFormat(frame->format), frame->sample_rate, | ~~~~~~~~~~~~~ 166 | 0, nullptr); | ~~~ In file included from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:14: /usr/include/x86_64-linux-gnu/libswresample/swresample.h:260:20: note: declared here 260 | struct SwrContext swr_alloc_set_opts(struct SwrContext *s, | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:202:54: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 202 | frame->channels, | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:202:54: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 202 | frame->channels, | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioframe.cpp:202:54: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 202 | frame->channels, | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudioinputfilter.cpp.o /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp: In constructor ‘QAVAudioInputFilter::QAVAudioInputFilter(const QAVFrame&)’: /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:30: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ In file included from /usr/include/x86_64-linux-gnu/libavutil/hwcontext.h:23, from /usr/include/x86_64-linux-gnu/libavcodec/codec.h:27, from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:313, from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:20: /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:30: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:30: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:52: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:52: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:52: warning: ‘AVFrame::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:510:14: note: declared here 510 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:87: warning: ‘AVCodecParameters::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ In file included from /usr/include/x86_64-linux-gnu/libavformat/avformat.h:314: /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:166:14: note: declared here 166 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:87: warning: ‘AVCodecParameters::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:166:14: note: declared here 166 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:58:87: warning: ‘AVCodecParameters::channel_layout’ is deprecated [-Wdeprecated-declarations] 58 | d->channel_layout = frm->channel_layout ? frm->channel_layout : stream->codecpar->channel_layout; | ^~~~~~ /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:166:14: note: declared here 166 | uint64_t channel_layout; | ^~~~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:24: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:24: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:24: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:40: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:40: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:40: warning: ‘AVFrame::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavutil/frame.h:643:9: note: declared here 643 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:69: warning: ‘AVCodecParameters::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:172:14: note: declared here 172 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:69: warning: ‘AVCodecParameters::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:172:14: note: declared here 172 | int channels; | ^~~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavaudioinputfilter.cpp:59:69: warning: ‘AVCodecParameters::channels’ is deprecated [-Wdeprecated-declarations] 59 | d->channels = frm->channels ? frm->channels : stream->codecpar->channels; | ^~~~ /usr/include/x86_64-linux-gnu/libavcodec/codec_par.h:172:14: note: declared here 172 | int channels; | ^~~~ Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudiooutput.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavaudiooutputfilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavcodec.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavdemuxer.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavfilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavfiltergraph.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavfilters.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavframecodec.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavframe.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavinoutfilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qaviodevice.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavpacket.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavplayer.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavstream.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavstreamframe.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavsubtitlecodec.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavsubtitleframe.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideobuffer_cpu.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideobuffer_gpu.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideocodec.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideofilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideoframe.cpp.o In file included from /usr/include/x86_64-linux-gnu/qt5/QtMultimedia/qvideoframe.h:46, from /usr/include/x86_64-linux-gnu/qt5/QtMultimedia/QVideoFrame:1, from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavvideoframe.h:14, from /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:8: /usr/include/x86_64-linux-gnu/qt5/QtMultimedia/qabstractvideobuffer.h:111:12: warning: ‘virtual uchar QAbstractPlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int)’ was hidden [-Woverloaded-virtual] 111 | uchar map(MapMode mode, int numBytes, int bytesPerLine) override; | ^~~ /home/gilles/devel/GIT/8.x/core/libs/video/QtAVPlayer/qavvideoframe.cpp:192:9: note: by ‘virtual int PlanarVideoBuffer::map(QAbstractVideoBuffer::MapMode, int, int, uchar*)’ 192 | int map(MapMode mode, int numBytes, int bytesPerLine[4], uchar *data[4]) override | ^~~ Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideoinputfilter.cpp.o Building CXX object core/libs/video/QtAVPlayer/CMakeFiles/core_qtavplayer_obj.dir/qavvideooutputfilter.cpp.o Built target core_qtavplayer_obj gilles@KU23:~/devel/GIT/8.x/build/core/libs/video$

Config detected by cmake at digiKAm config time :

-- FFMpeg AVCodec (required) : TRUE (59.37.100) -- FFMpeg AVDevice (required) : TRUE (59.7.100) -- FFMpeg AVFilter (required) : TRUE (8.44.100) -- FFMpeg AVFormat (required) : TRUE (59.27.100) -- FFMpeg AVUtil (required) : TRUE (57.28.100) -- FFMpeg SWScale (required) : TRUE (6.7.100) -- FFMpeg SWResample (required) : TRUE (4.7.100) -- FFMpeg AVResample (optional) : FALSE ()

Gilles

valbok commented 9 months ago

looks made mistake with LIBAVUTIL_VERSION_MAJOR,

#if LIBAVUTIL_VERSION_MAJOR < 58
    format.setChannelCount(d->avctx->channels);
#else
    format.setChannelCount(d->avctx->ch_layout.nb_channels);
#endif

Do you know what is LIBAVUTIL_VERSION_MAJOR for you?

valbok commented 9 months ago

https://github.com/valbok/QtAVPlayer/pull/431

2/3s delay before to take effect

Right, looks bug, volume is changed only when new frame is arrived which is not nice. Thanks, will fix

cgilles commented 9 months ago

looks made mistake with LIBAVUTIL_VERSION_MAJOR,

#if LIBAVUTIL_VERSION_MAJOR < 58
    format.setChannelCount(d->avctx->channels);
#else
    format.setChannelCount(d->avctx->ch_layout.nb_channels);
#endif

Do you know what is LIBAVUTIL_VERSION_MAJOR for you?

yes sure :

gilles@KU23:/usr/include/x86_64-linux-gnu/libavutil$ pwd /usr/include/x86_64-linux-gnu/libavutil

gilles@KU23:/usr/include/x86_64-linux-gnu/libavutil$ cat version.h /*

/**

ifndef AVUTIL_VERSION_H

define AVUTIL_VERSION_H

include "macros.h"

/**

define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))

define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c

define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)

/**

/**

/**

define LIBAVUTIL_VERSION_MAJOR 57

define LIBAVUTIL_VERSION_MINOR 28

define LIBAVUTIL_VERSION_MICRO 100

define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

                                           LIBAVUTIL_VERSION_MINOR, \
                                           LIBAVUTIL_VERSION_MICRO)

define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \

                                       LIBAVUTIL_VERSION_MINOR,     \
                                       LIBAVUTIL_VERSION_MICRO)

define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT

define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)

/**

define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 58)

define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 58)

/**

endif / AVUTIL_VERSION_H /

Gilles

cgilles commented 9 months ago

431

2/3s delay before to take effect

Right, looks bug, volume is changed only when new frame is arrived which is not nice. Thanks, will fix

Done. merged back in digiKam core

https://invent.kde.org/graphics/digikam/-/commit/9ce21116ad7298900a4e6870b508dea8de06002c

Gilles

valbok commented 9 months ago

Did you have a chance to figure out why player->position() returns 0 for you? but it still sends audio frames? Could you add qDebug()<<d->pts(); to QAVPlayer::position() ?

cgilles commented 9 months ago

yes, I do it now and the audio player work as expected now. position progress well, volume can be changed. Perfect.

Now we must implement the video rotation feature.

Gilles

valbok commented 9 months ago

what was wrong with player->position() ?

cgilles commented 9 months ago

well it reported always 0. Now it's not the case.

Note: your last recent commits do not compile here under Kubuntu 23.04 : 

gilles@KU23:~/devel/GIT/QtAVPlayer/examples/widget_video$ pwd
/home/gilles/devel/GIT/QtAVPlayer/examples/widget_video
gilles@KU23:~/devel/GIT/QtAVPlayer/examples/widget_video$ qmake .
gilles@KU23:~/devel/GIT/QtAVPlayer/examples/widget_video$ make
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavplayer.o ../../src/QtAVPlayer/qavplayer.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavcodec.o ../../src/QtAVPlayer/qavcodec.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavframecodec.o ../../src/QtAVPlayer/qavframecodec.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavaudiocodec.o ../../src/QtAVPlayer/qavaudiocodec.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavvideocodec.o ../../src/QtAVPlayer/qavvideocodec.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavsubtitlecodec.o ../../src/QtAVPlayer/qavsubtitlecodec.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavdemuxer.o ../../src/QtAVPlayer/qavdemuxer.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavpacket.o ../../src/QtAVPlayer/qavpacket.cpp
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_AVPLAYER_MULTIMEDIA -DQT_NO_DEBUG -DQT_MULTIMEDIAWIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -I../../src -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtMultimediaWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtConcurrent -I/usr/include/x86_64-linux-gnu/qt5/QtNetwork -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o qavframe.o ../../src/QtAVPlayer/qavframe.cpp
../../src/QtAVPlayer/qavframe.cpp: In member function ‘virtual double QAVFramePrivate::duration() const’:
../../src/QtAVPlayer/qavframe.cpp:116:21: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘duration’; did you mean ‘pkt_duration’?
  116 |              frame->duration
      |                     ^~~~~~~~
      |                     pkt_duration
make: *** [Makefile:873: qavframe.o] Error 1
gilles@KU23:~/devel/GIT/QtAVPlayer/examples/widget_video$ 

Gilles

valbok commented 9 months ago

sorry, reverted, will try to find proper version where it was deprecated.

cgilles commented 9 months ago

Ok,

I tested again the audio player position feature. It work but only with some audio track, not all. One working :

digikam.dplugin.generic: Playing: QUrl("file:///mnt/videos/music/TODO/BILLY-IDOL----Complette-Discography-(1982---2006)-10CD----ANGLIE-(London,-Greater-London)-Rock,-Hard,-Punk,-Rock-(320Kpbs)-pawlyn/(02) BILLY IDOL - Rebel Yell 1984/03 Eyes Without a Face.mp3") FFmpeg: [mp3 @ 0x7f977001ae80] Estimating duration from bitrate, this may be inaccurate

digikam.general: Audio position: 0 digikam.general: Audio position: 26 digikam.general: Audio position: 52 digikam.general: Audio position: 78 digikam.general: Audio position: 104 digikam.general: Audio position: 130 digikam.general: Audio position: 156 digikam.general: Audio position: 182 digikam.general: Audio position: 208 digikam.general: Audio position: 235 digikam.general: Audio position: 261 digikam.general: Audio position: 287 digikam.general: Audio position: 313 digikam.general: Audio position: 339 digikam.general: Audio position: 365 digikam.general: Audio position: 391 digikam.general: Audio position: 417 digikam.general: Audio position: 444 digikam.general: Audio position: 470

And one not working :

digikam.dplugin.generic: Playing: QUrl("file:///mnt/videos/music/PROCESSED/Art of Noise - The Seduction Of Claude Debussy (1999)/14 - Out Of This World [Version 138].mp3") digikam.general: Audio position: 0 mjpeg : supported hardware device contexts: cuda vaapi Available pixel formats: yuvj420p : AVPixelFormat( 12 ) cuda : AVPixelFormat( 117 ) vaapi : AVPixelFormat( 44 ) Using software decoding in yuvj420p digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808 digikam.general: Audio position: -9223372036854775808

As you can see with the last trace, the audio position is definitively wrong (but not equal to zero as previously)

Gilles

valbok commented 9 months ago

could you qDebug()<<frame.pts(); ? or share the file? never seen mp3 files with wrong pts yet.

cgilles commented 9 months ago

MP3 files can be downloaded here : https://drive.google.com/drive/folders/1nK8A9ITUeAu_o9UOgTw2mX_7exfA2epG?usp=sharing

cgilles commented 9 months ago

QAVAudioFrame::pts() sounds really better than QAVPlayer::position():

digikam.dplugin.generic: Playing: QUrl("file:///mnt/videos/music/PROCESSED/Art of Noise - The Seduction Of Claude Debussy (1999)/14 - Out Of This World [Version 138].mp3")
digikam.general: Audio position: 0
digikam.general: Frame position: 0.0250567
mjpeg : supported hardware device contexts:
    cuda
    vaapi
Available pixel formats:
   yuvj420p : AVPixelFormat( 12 )
   cuda : AVPixelFormat( 117 )
   vaapi : AVPixelFormat( 44 )
Using software decoding in yuvj420p
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.0261224
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.0522449
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.0783673
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.10449
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.130612
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.156735
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.182857
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.20898
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.235102
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.261224
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.287347
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.313469
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.339592
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.365714
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.391837
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.417959
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.444082
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.470204
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.496327
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.522449
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.548571
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.574694
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.600816
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.626939
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.653061
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.679184
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.705306
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.731429
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.757551
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.783673
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.809796
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.835918
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.862041
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.888163
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.914286
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.940408
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.966531
digikam.general: Audio position: -9223372036854775808
digikam.general: Frame position: 0.992653
digikam.general: Audio position: -9223372036854775808

Code : https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/daudioplayer.cpp?ref_type=heads#L70

Gilles

valbok commented 9 months ago

Right, first one does not work, thanks. It is a bug since the file contains video stream with image. The position is for that image is returned, which is a bug.

valbok commented 9 months ago

Audio position: -9223372036854775808 fixed, it is NaN value, returned from video frame with cover. Now audio stream is a priority in this case.

cgilles commented 9 months ago

Yes, i seen. I updated the QtAVPlayter in digiKam core.

Now it still the rotation support to implement with QtAVPlayer in the DVideoWidget class:

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/dvideowidget.cpp?ref_type=heads#L74

If i resume your previous comments, you recommend to use the same mechanism that the Qt6Multimedia to render the video frames :

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/qtmm/mediaplayerview.cpp?ref_type=heads#L167

So, QGraphicsScene, QGraphicsView, and QGraphicsVideoItem. We need code to forward QAVVideoFrame in the QGraphicsVideoItem where we can process rotation easily with existing API from Qt5.

Right ?

Note: originally, i started the implementation of the QtAVPlayer::DVideoWidget with the legacy QtAv code. It was a bad idea in fact. We need to use QtMultimedia based class implementation to host new code with QtAVPlayer.

Gilles

valbok commented 9 months ago

So, QGraphicsScene, QGraphicsView, and QGraphicsVideoItem. We need code to forward QAVVideoFrame in the >? > QGraphicsVideoItem where we can process rotation easily with existing API from Qt5. Right ?

Yes, good thing there is all video sinks in Qt now accept QVideoFrame's. F.e. https://doc.qt.io/qt-5/qgraphicsvideoitem.html#videoSurface-prop

So the code should be almost the same as for QVideoWidget:

QGraphicsVideoItem *item = new QGraphicsVideoItem;
m_surface = item->videoSurface();
QObject::connect(&p, &QAVPlayer::videoFrame, &p, [&](const QAVVideoFrame &frame) {
    QVideoFrame videoFrame = frame; // .convertTo(AV_PIX_FMT_RGB32);
    if (!m_surface->isActive() || m_surface->surfaceFormat().frameSize() != videoFrame.size()) {
        QVideoSurfaceFormat f(videoFrame.size(), videoFrame.pixelFormat(), videoFrame.handleType());
        m_surface->start(f);
    }
    if (m_surface->isActive())
        m_surface->present(videoFrame);
}, Qt::DirectConnection);
valbok commented 9 months ago

We need to use QtMultimedia based class implementation to host new code with QtAVPlayer.

Anything to render the audio and video frames is already supported in Qt. There are 3 ways how to render video frames:

  1. QVideoWidget -> provides the video surface which accepts QVideoFrame https://doc.qt.io/qt-5/qvideowidget.html#videoSurface-prop
  2. QGraphicsVideoItem - https://doc.qt.io/qt-5/qgraphicsvideoitem.html#videoSurface-prop
  3. QML video item - unfortunately it is private API, - QDeclarativeVideoOutput::videoSurface()

Do you want to implement another render and place it QAVPlayer? As QtAv did, because qtmm did not support hw acceleration and did not have video surfaces API, btw, looks Widget and GraphicsItem are not HW accelerated in q5tmm.

Btw it is good idea to reimplement renderers, but decided that rendering it is separate big task, and not directly related to the player. Since it should be part of the qtmm in perfect world.

cgilles commented 9 months ago

Well the point 1/ is already implemented in your examples/video_widget but rotation cannot be done of course. This is what i use currently in digiKam core.

The point 2/ is definitively the right way to go for the orientation stuff. If you provide this kind a render codes/classes in QtAVPlayer, this will be great.

For the point 3/, we don't use QML code in digiKam at all, and we don't plan to do it in the future. digiKam is for desktop only, so Windows, MacOS, and Linux. Android is not supported for the moment...

Best

Gilles

cgilles commented 9 months ago

Hi,

I implemented the the QGraphicsView/Scene/Item with QtAVPlayer and it works as expected. Rotation works too. It's still only a problem to handle the resize event from the QGraphicsView when parent widget is resized. We discovered the same dysfunction with Qt6 due to a bug in Qt framework.

We are near the final step to drop definitively the bugous and unmaintained Qt5::QtAV form digiKam. It's have been a long way...

One Q about videostream metadata. To check the orientation of the video and process to an automatic rotation while playing, with QtAV we look the media metadata reported by ffmpeg. A similar way is done with Qt6::multimedia API.

Look this code :

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/dvideowidget.cpp?ref_type=heads#L149

It try to get the orientation info from the video stream. It's called here:

https://invent.kde.org/graphics/digikam/-/blob/development/qtavplayer/core/libs/video/player/QtAVPlayer/mediaplayerview.cpp?ref_type=heads#L327

... so when player read the media, we process to an automatic rotation depending of Exif or Xmp flags take by ffmpeg to the video file. Vertical video can be shown properly on screen in this case.

... the metadata map is empty because current stream is null. Why:

digikam.general: Video Metadata from "/mnt/data/Images/SALAGOU/2021-12-21/66179368138__C05A772F-62BA-48DF-A389-1C7FFC7EE627.MOV" digikam.general: --- digikam.general: Video Streams Available: 0 digikam.general: ---

Gilles

valbok commented 9 months ago

.. the metadata map is empty because current stream is null. Why:

you should call p.availableVideoStreams() on QAVPlayer::LoadedMedia, since if the source is not loaded, the streams are unknown.

Btw. availableVideoStreams() returns all available video streams, it could be many, p.currentVideoStreams() returns current requested video streams, you could also p.setVideoStreams({}); to disable decoding/retrieving video streams.

valbok commented 9 months ago

btw stream.metadata() returns what is stored there: https://ffmpeg.org/doxygen/trunk/structAVStream.html#a50d250a128a3da9ce3d135e84213fb82

curious that it can return rotation info...

If you would share the file with "rotate" metadata, I will check how to return this.

valbok commented 9 months ago

Ic sometimes there is metadata called "rotate" from AVStream, but can't understand is it always available or not

cgilles commented 9 months ago

Right. It's fixed fowllowing the QAVPlayer::LoadedMedia status.

As i seen with ffmpeg <= 4.x, the orientation was available here. With ffmpeg >= 5, it's not the case.

The info was named "rotate" from ffmpeg -i or ffprobe.

Look the ffmpeg metadata wrapper that we write for digiKam core:

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/dmetadata/dmetadata_video.cpp?ref_type=heads#L662

It will be nice if QtAvPlayer can return something as "rotate" entry in metadata stream map using this kind of code.

Best

Gilles

cgilles commented 9 months ago

Here, a video file taken vertically with my iphone to test:

https://drive.google.com/file/d/17Fk2gyONvPf8j8Q9sTyRTZk0KN30yOYJ/view?usp=sharing

Gilles

valbok commented 9 months ago

thanks https://github.com/valbok/QtAVPlayer/pull/444

but used a bit different approach, not sure which one is the best I can use your code, if you want =)