<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Qt6 Multimedia has recently added an FFmpeg plugin. Maybe it makes sense to look at the code as it was solved there.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a href="https://github.com/qt/qtmultimedia/tree/dev/src/plugins/multimedia/ffmpeg">https://github.com/qt/qtmultimedia/tree/dev/src/plugins/multimedia/ffmpeg</a></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">The Qt-AV code has certainly grown over many FFmpeg versions and has only ever been adapted to "working".</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Maik</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Am Donnerstag, 27. Oktober 2022, 07:09:00 CEST schrieb Steven Robbins:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Hello,</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> After staring at ffmpeg docs and digikam/qtav code for a couple days: it</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> seems to me the qtav  code is fundamentally mismatched for decoding.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> As far as I can work out, the ffmpeg model is that a single packet from the</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> demuxer may generate an arbitrary number of frames.  In contrast, qtav</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> assumes that a packet may generate only a single frame.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> On the ffmpeg side, example code [1] shows the avcodec_receive_frame() loop</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> after sending the packet to the codec.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> [1] https://ffmpeg.org/doxygen/5.1/filtering_audio_8c-example.html</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> On the qtav side, the AudioDecoderFFmpeg::decode() function [2] has a single</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> avcodec_receive_frame() following the avcodec_send_packet().</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> [2] https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/video/</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> qtav/codec/audio/AudioDecoderFFmpeg.cpp#L110</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Have I overlooked something in this analysis?  The qtav code uses layers</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> exuberantly so I may well have gotten confused.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> If the analysis is correct: I don't see a simple path forward.  I think it</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> will need rewriting the AVDecoder class hierarchy -- because that is where</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> decode() is declared.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Also of note: as far as I can work out, this code has always been wrong,</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> even for ffmpeg version 4.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> -Steve</p>
<br /><br /></body>
</html>