FFmpeg cuts off ~50ms when I extract+convert audio from video

2

1

I want to extract the audio stream from many .MOV files with ffmpeg.

The goal is to have output files with small file size and perfectly equal sound to the input file. Currently I'm using this ffmpeg command:

ffmpeg -i input.mov -vn -ab 92k -acodec aac -strict -2 output.m4a

My problem is that re-encoding pcm_s24le to AAC creates an output file where some milliseconds at the beginning are missing.

enter image description here

Is there a workaround or a way resolve this? Like padding the output for 50ms


I/O information:

ffmpeg version 2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 20 2014 09:33:55 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvo-aacenc --enable-libfdk-aac --enable-nonfree --enable-vda
libavutil      54. 15.100 / 54. 15.100
libavcodec     56. 13.100 / 56. 13.100
libavformat    56. 15.102 / 56. 15.102
libavdevice    56.  3.100 / 56.  3.100
libavfilter     5.  2.103 /  5.  2.103
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '6.2.mov':
Metadata:
 major_brand     : qt  
 minor_version   : 0
 compatible_brands: qt  
 creation_time   : 2014-12-03 10:12:08
Duration: 00:00:01.58, start: 0.000000, bitrate: 42754 kb/s
Stream #0:0(und): Video: prores (apcn / 0x6E637061), yuv422p10le(bt709), 960x540, 40383 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
 Metadata:
  creation_time   : 2014-12-03 10:12:08
  handler_name    : Core Media Data Handler
  encoder         : Apple ProRes 422
  timecode        : 00:00:00:00
 Stream #0:1(und): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
 Metadata:
  creation_time   : 2014-12-03 10:12:08
  handler_name    : Core Media Data Handler
 Stream #0:2(und): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
 Metadata:
  creation_time   : 2014-12-03 10:12:08
  handler_name    : Core Media Data Handler
  timecode        : 00:00:00:00
File 'try.m4a' already exists. Overwrite ? [y/N] y
Output #0, ipod, to 'try.m4a':
Metadata:
 major_brand     : qt  
 minor_version   : 0
 compatible_brands: qt  
 encoder         : Lavf56.15.102
 Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp (24 bit), 92 kb/s (default)
 Metadata:
  creation_time   : 2014-12-03 10:12:08
  handler_name    : Core Media Data Handler
  encoder         : Lavc56.13.100 aac
 Stream mapping:
 Stream #0:1 -> #0:0 (pcm_s24le (native) -> aac (native))
 Press [q] to stop, [?] for help
 size=      19kB time=00:00:01.60 bitrate=  97.9kbits/s      
 video:0kB audio:18kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.684210%

Marco

Posted 2014-12-21T09:15:05.303

Reputation: 121

Some have recently complained about timing/synch issues with the aac encoder in ffmpeg. You might want to try a different encoder such as the libfdk_aac. This requires ffmpeg to be built with --enable-libfdk_aac and also --enable-nonfree. – Rajib – 2014-12-21T14:11:30.043

Unfortunately libfdk_aac is also causing timing errors. Possibly an ffmpeg issue? – Rajib – 2014-12-21T15:20:11.440

could depend to AAC codec? https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html

– Marco – 2014-12-21T20:54:33.807

No- its happening with libmp3lame as well. – Rajib – 2014-12-22T01:45:15.643

with libmp3lame the output have 47ms of silent at the beginning, the rest of the file it's correct – Marco – 2014-12-22T07:48:55.873

Yes 44ms with libfdk_aac. :( Maybe we should report a bug. – Rajib – 2014-12-22T07:49:54.793

1http://lame.sourceforge.net/tech-FAQ.txt – Marco – 2014-12-22T08:03:35.510

Maybe it's normal that encoders add some sample frame at the beginning of each encoded audio file – Marco – 2014-12-22T08:05:16.387

No answers