#420(undetermined:new): Sound fragments after seeking
#420: Sound fragments after seeking --------------------------+-------------------------- Reporter: kaptnole | Type: defect Status: new | Priority: important Component: undetermined | Version: unspecified Keywords: | Blocked By: Blocking: | Reproduced: 1 Analyzed: 1 | --------------------------+-------------------------- While trying to use FFmpeg libs as a developer I found the following: When decoding sound from some compressed audio formats and doing a seek, the first decoded packet after seeking is buggy. I had this with some mp4 files with aac audio codec and some wmv files with wma audio codec. Looks like some leftovers from internal buffers - but I am using 'avcodec_flush_buffers'! That of course leads to nasty sound noise/clicks. See attached sourcecode. Basically it shows the first few bytes of the first decoded sound packet then seeks back and shows the first packets decoding again. If you use it with some wmv or mp4 file with sound you should see see effect that both outputs at 0 are different but should be equal. Just make sure the sound is not only silence at the first 10 packets. Or am I missing some other flush...whatever function here? I am developing under windows using the actual ffmpeg git version. Confirmed for 32 and 64 bit version, self compiled and downloaded autobuilds. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------+--------------------------- Reporter: kaptnole | Owner: Type: defect | Status: new Priority: important | Component: undetermined Version: unspecified | Resolution: Keywords: | Blocked By: Blocking: | Reproduced: 1 Analyzed: 1 | ------------------------+--------------------------- Comment (by prunkdump): I noticed the same problem. See audioBitStream.jpg to see what append on the audio streams. On the first stream I seek while playing strong sound, on the second I seek while playing very low sound (close to silence) So I send my bug demonstration. '''To compile''' {{{ tar -xvjf seekbug.tar.bz2 cd seekbug make }}} '''Usage''' {{{ ./seekbug music.mp3 }}} right arrow -> play down arrow -> pause left arrow -> seek to start '''To hear the problem''' - play the audio - pause while playing strong song - seek to start - play again while listening carefully '''To see the bit stream''' Debug with gdb {{{ gdb seekbug : set args music.mp3 : break seekBugBreak : run }}} Do the seek when you want - play - pause (when you want) - seek to start Enable the break call - type the "s" key - play again (gdb break) Dump memory {{{ : dump memory dump.raw bufferStart bufferEnd : quit }}} Open the dump with audacity - file -> import -> raw data - dump.raw - signed 16bit, default endianness, stereo -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:1> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking -------------------------------------+------------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: new Priority: important | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Comment (by michael): Ive failed to find a good testcase for this but you could try something like: (in aacdec.c) {{{ static void flush(AVCodecContext *avctx) { AACContext *ac= avctx->priv_data; int type, i, ch; for (type = 3; type >= 0; type--) { for (i = 0; i < MAX_ELEM_ID; i++) { ChannelElement *che = ac->che[type][i]; if (che) { memset(che, 0, sizeof(*che)); } } } } ... .flush = flush, }}} and if it works find out which fields actually need to be reset, id be happy to apply a patch that would fix this -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:2> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking -------------------------------------+------------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: new Priority: important | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Comment (by kaptnole): Hi, Michael, Your proposal works! For my testcase it is sufficient to clear the element with type 1 and id 0. But it did not hurt to clear them all. Thank you. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:3> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking -------------------------------------+------------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: new Priority: important | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Comment (by michael): I was more wondering which fields of the element have to be cleared, clearing them all seems a bit strong even if it works. I mean for example something like SingleChannelElement.coeffs/saved -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:4> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking -------------------------------------+------------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: new Priority: important | Component: Version: unspecified | undetermined Keywords: | Resolution: Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Comment (by kaptnole): Its the "saved" field, the following works: {{{ static void flush(AVCodecContext *avctx) { AACContext *ac= avctx->priv_data; int type, i, j; for (type = 3; type >= 0; type--) { for (i = 0; i < MAX_ELEM_ID; i++) { ChannelElement *che = ac->che[type][i]; if (che) { for (j = 0; j <= 1; j++) { // memset(che->ch[j].coeffs, 0, sizeof(che->ch[j].coeffs)); memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved)); } } } } } }}} -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:5> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking -------------------------------------+------------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: closed Priority: important | Component: Version: unspecified | undetermined Keywords: | Resolution: fixed Blocking: | Blocked By: Analyzed by developer: 1 | Reproduced by developer: 1 -------------------------------------+------------------------------------- Changes (by michael): * status: new => closed * resolution: => fixed Comment: Thanks, ive added the code -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:6> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+----------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: closed Priority: important | Component: avcodec Version: git-master | Resolution: fixed Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Changes (by cehoyos): * keywords: => aac * version: unspecified => git-master * component: undetermined => avcodec -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:7> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+----------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: closed Priority: important | Component: avcodec Version: git-master | Resolution: fixed Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Comment (by JHawkZZ): Hi guys. I ran into this exact problem using a December 26th snapshot of ffmpeg, which surprised me because it includes AAC's static flush function. It turns out that in aacdec.h, 'AVCodec ff_aac_decoder''s flush function pointer was not assigned. Only 'AVCodec ff_aac_latm_decoder''s pointer was. I verified it fixed by setting the pointer and rebuilding ffmpeg, but I wanted to post here so it can hopefully be included in the main branch. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:8> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Changes (by JHawkZZ): * status: closed => reopened * resolution: fixed => -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:9> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Comment (by cehoyos): Please test current git head, if the problem is still reproducible and you have a patch to fix it, please send the patch to ffmpeg-devel. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:10> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Comment (by kaptnole): JHawkZZ is absolutely right. .../libavcodec/aacdec.c defines two decoders "ff_aac_decoder" and "ff_aac_latm_decoder". This whole thread was about "ff_aac_decoder". To be honest, I do not even know what "ff_aac_latm_decoder" is for. Unfortunately the patching "flush" function was falsely assigned only to the latter one. I do not know If it also needs it but in any case it is missing in "ff_aac_decoder". If you add a line: {{{ flush = flush, }}} in the initialization of "ff_aac_decoder" the bug is fixed. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:11> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Comment (by cehoyos): Could you send a patch to ffmpeg-devel? -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:12> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Comment (by kaptnole): How do you define "patch"? Sending a post to ffmpeg-devel that links here? -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:13> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+------------------------------------ Reporter: kaptnole | Owner: Type: defect | Status: reopened Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: aac | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+------------------------------------ Comment (by cehoyos): No, please do a git checkout, make your change, run git diff>patchfile.diff and send the resulting patch as an attachment together with an explanation to ffmpeg-devel. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:14> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+----------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: closed Priority: important | Component: avcodec Version: git-master | Resolution: fixed Keywords: aac latm | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Changes (by cehoyos): * keywords: aac => aac latm * status: reopened => closed * resolution: => fixed Comment: Fixed by you. -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/420#comment:15> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
#420: Sound fragments after seeking ------------------------------------+----------------------------------- Reporter: kaptnole | Owner: Type: defect | Status: closed Priority: important | Component: avcodec Version: git-master | Resolution: fixed Keywords: aac latm | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 1 | ------------------------------------+----------------------------------- Comment (by DonMoir): Not sure if the flush here is sufficient. After numerous seeks on audio with acc fltp I am seeing a constant ramp up of memory. During normal playback it all looks good but somehow many seeks cause ramp of memory and quite a bit. This is file I am using for testing. It's not the video but audio memory that increases a lot after numerous seeks. I tested by turning off the video or audio to check results. http://sms.pangolin.com/temp/anoha_0.ts -- Ticket URL: <https://trac.ffmpeg.org/ticket/420#comment:16> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg