[FFmpeg-trac] #4919(avfilter:new): afade filter misses first frame to be filtered

FFmpeg trac at avcodec.org
Thu Oct 8 22:14:07 CEST 2015


#4919: afade filter misses first frame to be filtered
----------------------------------+---------------------------------------
             Reporter:  ezran     |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avfilter  |                  Version:  unspecified
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+---------------------------------------
 The afade audio filter can skip filtering the first frame it should be
 applied to, when fading out.

 Cause: In filter_frame for the afade filter, when calculating whether the
 current frame includes part of a fade-out, the number of samples to fade
 is used rather than the number of samples in the frame.  This can let the
 frame pass through unfiltered even when it should have the fade applied.
 Then at the beginning of the next frame, the fade starts mid-way through.

 How to reproduce:
 {{{
 Generate loud 5-second sine wave at 44100 Hz to test with:
 $ ffmpeg -f lavfi -i "sine=duration=5" -af volume=7 sine.wav

 Apply fade-out with a duration of 1000 samples, starting at sample 216388:
 ffmpeg -i sine.wav -af afade=t=out:ss=216388:ns=1000 out.wav
 }}}

 Because the audio frames are 4096 samples long, the fade will actually be
 applied starting at sample 217088 (which is 700 samples late), with a
 sudden drop in volume, and then will continue to fade out over the
 following 300 samples.

 This issue occurs in latest master, and appears to have existed since the
 afade filter was introduced.

 Full log of filter run (no errors evident from log):
 {{{
 $ ffmpeg -i sine.wav -af afade=t=out:ss=216388:ns=1000 out.wav
 ffmpeg version N-75841-g5911eeb Copyright (c) 2000-2015 the FFmpeg
 developers
   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-3)
   configuration: --prefix=/usr --shlibdir=/usr/lib64 --libdir=/usr/lib64
 --incdir=/usr/include --bindir=/usr/bin --datadir=/usr/share/ffmpeg
 --mandir=/usr/share/man
   libavutil      55.  2.100 / 55.  2.100
   libavcodec     57.  4.100 / 57.  4.100
   libavformat    57.  3.100 / 57.  3.100
   libavdevice    57.  0.100 / 57.  0.100
   libavfilter     6. 10.100 /  6. 10.100
   libswscale      4.  0.100 /  4.  0.100
   libswresample   2.  0.100 /  2.  0.100
 Guessed Channel Layout for  Input Stream #0.0 : mono
 Input #0, wav, from 'sine.wav':
   Metadata:
     encoder         : Lavf57.3.100
   Duration: 00:00:05.00, bitrate: 705 kb/s
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1
 channels, s16, 705 kb/s
 Output #0, wav, to 'out.wav':
   Metadata:
     ISFT            : Lavf57.3.100
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono,
 s16, 705 kb/s
     Metadata:
       encoder         : Lavc57.4.100 pcm_s16le
 Stream mapping:
   Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
 Press [q] to stop, [?] for help
 size=     431kB time=00:00:05.00 bitrate= 705.7kbits/s
 video:0kB audio:431kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.017687%
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/4919>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list