Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5290 closed defect (duplicate)

FFMPEG adds delay when converting into WAV

Reported by: xtemp09 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: aac
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When converting a file into WAV with FFMPEG, the program adds a delay of 0.02-0.04 s in the beginning of the file, i. e. 50 conversions gives 1 second of the delay.

# ffmpeg -i ffmpeg_aac_128k.m4a -c:a pcm_s16le 1.wav
ffmpeg version N-53341-gbd9c587-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.1 (Debian 5.3.1-10) 20160224
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --cc=gcc
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 27.101 / 57. 27.101
  libavformat    57. 27.101 / 57. 27.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 38.100 /  6. 38.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ffmpeg_aac_128k.m4a':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : For Amelie [New Version - Bonus Track]
    artist          : Leaves' Eyes
    album           : Vinland Saga
    date            : 2005
    encoder         : Lavf57.27.100
    genre           : Symphonic Gothic Metal
    track           : 14/14
  Duration: 00:00:09.47, start: 0.023220, bitrate: 129 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, wav, to '1.wav':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    INAM            : For Amelie [New Version - Bonus Track]
    IART            : Leaves' Eyes
    IPRD            : Vinland Saga
    ICRD            : 2005
    IPRT            : 14/14
    IGNR            : Symphonic Gothic Metal
    ISFT            : Lavf57.27.101
    Stream #0:0(und): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc57.27.101 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size=    1632kB time=00:00:09.47 bitrate=1411.4kbits/s speed=85.7x
video:0kB audio:1632kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013763%


# ffprobe ffmpeg_aac_128k.m4a
ffprobe version N-48618-g9ec17e4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.3 (Debian 4.9.3-3)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --cc=gcc-4.9
  libavutil      54. 29.100 / 54. 29.100
  libavcodec     56. 56.101 / 56. 56.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 30.100 /  5. 30.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ffmpeg_aac_128k.m4a':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : For Amelie [New Version - Bonus Track]
    artist          : Leaves' Eyes
    album           : Vinland Saga
    date            : 2005
    encoder         : Lavf57.27.100
    genre           : Symphonic Gothic Metal
    track           : 14/14
  Duration: 00:00:09.47, start: 0.023220, bitrate: 129 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
	  
# ffprobe version N-48618-g9ec17e4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.3 (Debian 4.9.3-3)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --cc=gcc-4.9
  libavutil      54. 29.100 / 54. 29.100
  libavcodec     56. 56.101 / 56. 56.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 30.100 /  5. 30.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, wav, from '1.wav':
  Metadata:
    artist          : Leaves' Eyes
    date            : 2005
    genre           : Symphonic Gothic Metal
    title           : For Amelie [New Version - Bonus Track]
    album           : Vinland Saga
    track           : 14/14
    encoder         : Lavf57.27.101
  Duration: 00:00:09.47, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
	
# ffmpeg -version
ffmpeg version N-53341-gbd9c587-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.1 (Debian 5.3.1-10) 20160224
configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --cc=gcc
libavutil      55. 19.100 / 55. 19.100
libavcodec     57. 27.101 / 57. 27.101
libavformat    57. 27.101 / 57. 27.101
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 38.100 /  6. 38.100
libswscale      4.  0.100 /  4.  0.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100

Change History (7)

comment:1 by xtemp09, 8 years ago

One should pay attention to:

  Duration: 00:00:09.47, start: 0.023220, bitrate: 129 kb/s

and

  Duration: 00:00:09.47, bitrate: 1411 kb/s
  1. e. the audio is 9.45 s long before the conversion and 9.47 s long after that. FFMPEG adds 0.02 s of garbage in the beginning of the audio file.

comment:2 by xtemp09, 8 years ago

The original audio length of the WAV file is:

Duration: 00:00:09.45, bitrate: 1411 kb/s

It means, the conversion of a WAV file into AAC, then conversion back into WAV increases duration.

Last edited 8 years ago by xtemp09 (previous) (diff)

comment:3 by Carl Eugen Hoyos, 8 years ago

Keywords: aac added; delay WAV removed
Priority: importantnormal

Do you think this is a regression?

comment:4 by Carl Eugen Hoyos, 8 years ago

Resolution: duplicate
Status: newclosed

Yes, and a duplicate of ticket #2325 afaict.

comment:5 by jeeb, 8 years ago

Similar end result, but the last comments there are most probably off regarding iTunes-specific metadata in MOV-derivatives in #2325 .

Libavcodec should nowadays be pushing out negative timestamps (which is correct, and visible by the nonzero start time), but with output formats that cannot handle negative timestamps either libavformat or ffmpeg cli moves the first packet to position zero (at least that was the end of the last technical discussion I had on this). That then leads to this effect of all samples being output instead of just those having timestamps >=0.

comment:6 by gjdfgh, 8 years ago

Negative timestamps are not enough; the demuxer should also set the delay field.

comment:7 by Elon Musk, 8 years ago

Delay from demuxer?

Note: See TracTickets for help on using tickets.