[FFmpeg-user] AAC in MOV 1 frame off

Peter Wright peter at peterphi.com
Tue Apr 1 20:19:16 CEST 2014


Hi,

I am having a problem with AV sync being off by 1 frame when using AAC and MP3 (tried all 3 AAC encoders, internal, libfaac and libfdk_aac) in MOV.
I've tried with 2.2 and with git master (d506deaeaa98013505241d8149d82327efea0379)

I have used lavfi to generate SMPTE bars (with burned-in timecode) and a sine-wave with a beep every second. The beep happens on frame 00.

To generate the samples (10 second clips are generated):

ffmpeg -f lavfi -i "smptebars=size=1920x1080:rate=25" -f lavfi -i  "sine=b=2:r=48000" -vf "drawtext=timecode='00\:00\:00\:00':r=25:x=(w-tw)/2:y=h-(2*lh):fontcolor=white:box=1:boxcolor=0x00000000 at 1:fontsize=100" -vcodec mpeg4 -t 10 -y -strict experimental -acodec aac aac.mov

ffmpeg -f lavfi -i "smptebars=size=1920x1080:rate=25" -f lavfi -i  "sine=b=2:r=48000" -vf "drawtext=timecode='00\:00\:00\:00':r=25:x=(w-tw)/2:y=h-(2*lh):fontcolor=white:box=1:boxcolor=0x00000000 at 1:fontsize=100" -vcodec mpeg4 -t 10 -y -acodec libmp3lame mp3.mov

ffmpeg -f lavfi -i "smptebars=size=1920x1080:rate=25" -f lavfi -i  "sine=b=2:r=48000" -vf "drawtext=timecode='00\:00\:00\:00':r=25:x=(w-tw)/2:y=h-(2*lh):fontcolor=white:box=1:boxcolor=0x00000000 at 1:fontsize=100" -vcodec mpeg4 -t 10 -y -acodec pcm_s16le pcm.mov

I'm playing back in Final Cut Pro X and Quicktime (latest version for Mavericks).

When I play back "aac.mov", the first beep is not audible and the next beep happens primarily on frame 00:00:00:24 (with a short pop in 00:00:00:23)
When I play back "mp3.mov", the first beep is audible and the next beep happens primarily on frame 00:00:01:00 (with a short pop on 00:00:00:24)
When I play back "pcm.mov", the first beep is audible and the next beep happens entirely on frame 00:00:01:00

I've noticed that for the MP3 and AAC sample there are packets generated with a negative PTS value, I'm not sure if this is part of the problem? See ffprobe results below

For aac.mov:
ffprobe -show_packets -of xml aac.mov
ffprobe version 2.2 Copyright (c) 2007-2014 the FFmpeg developers
  built on Mar 29 2014 02:29:54 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'aac.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf55.33.100
  Duration: 00:00:10.02, start: 0.021333, bitrate: 2018 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1953 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : DataHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
      handler_name    : DataHandler
<packet codec_type="audio" stream_index="1" pts="-1024" pts_time="-0.021333" dts="-1024" dts_time="-0.021333" duration="1024" duration_time="0.021333" size="325" pos="36" flags="K"/>
<packet codec_type="video" stream_index="0" pts="0" pts_time="0.000000" dts="0" dts_time="0.000000" duration="512" duration_time="0.040000" size="42424" pos="361" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="0" pts_time="0.000000" dts="0" dts_time="0.000000" duration="1024" duration_time="0.021333" size="344" pos="42785" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="1024" pts_time="0.021333" dts="1024" dts_time="0.021333" duration="1024" duration_time="0.021333" size="381" pos="43129" flags="K"/>
<packet codec_type="video" stream_index="0" pts="512" pts_time="0.040000" dts="512" dts_time="0.040000" duration="512" duration_time="0.040000" size="24350" pos="43510" flags="_"/>
<packet codec_type="audio" stream_index="1" pts="2048" pts_time="0.042667" dts="2048" dts_time="0.042667" duration="1024" duration_time="0.021333" size="277" pos="67860" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="3072" pts_time="0.064000" dts="3072" dts_time="0.064000" duration="1024" duration_time="0.021333" size="131" pos="68137" flags="K"/>
...


For mp3.mov:
ffprobe -show_packets -of xml mp3.mov
ffprobe version 2.2 Copyright (c) 2007-2014 the FFmpeg developers
  built on Mar 29 2014 02:29:54 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'mp3.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf55.33.100
  Duration: 00:00:10.02, start: 0.023021, bitrate: 2018 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1953 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : DataHandler
    Stream #0:1(eng): Audio: mp3 (.mp3 / 0x33706D2E), 48000 Hz, mono, s16p, 64 kb/s (default)
    Metadata:
      handler_name    : DataHandler
<packet codec_type="audio" stream_index="1" pts="-1105" pts_time="-0.023021" dts="-1105" dts_time="-0.023021" duration="1152" duration_time="0.024000" size="192" pos="36" flags="K"/>
<packet codec_type="video" stream_index="0" pts="0" pts_time="0.000000" dts="0" dts_time="0.000000" duration="512" duration_time="0.040000" size="42424" pos="228" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="47" pts_time="0.000979" dts="47" dts_time="0.000979" duration="1152" duration_time="0.024000" size="192" pos="42652" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="1199" pts_time="0.024979" dts="1199" dts_time="0.024979" duration="1152" duration_time="0.024000" size="192" pos="42844" flags="K"/>
<packet codec_type="video" stream_index="0" pts="512" pts_time="0.040000" dts="512" dts_time="0.040000" duration="512" duration_time="0.040000" size="24350" pos="43036" flags="_"/>
<packet codec_type="audio" stream_index="1" pts="2351" pts_time="0.048979" dts="2351" dts_time="0.048979" duration="1152" duration_time="0.024000" size="192" pos="67386" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="3503" pts_time="0.072979" dts="3503" dts_time="0.072979" duration="1152" duration_time="0.024000" size="192" pos="67578" flags="K"/>
...


for pcm.mov:
ffprobe -show_packets -of xml pcm.mov
ffprobe version 2.2 Copyright (c) 2007-2014 the FFmpeg developers
  built on Mar 29 2014 02:29:54 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pcm.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf55.33.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 2725 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1953 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : DataHandler
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16, 768 kb/s (default)
    Metadata:
      handler_name    : DataHandler
<packet codec_type="video" stream_index="0" pts="0" pts_time="0.000000" dts="0" dts_time="0.000000" duration="512" duration_time="0.040000" size="42424" pos="36" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="0" pts_time="0.000000" dts="0" dts_time="0.000000" duration="1024" duration_time="0.021333" size="2048" pos="42460" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="1024" pts_time="0.021333" dts="1024" dts_time="0.021333" duration="1024" duration_time="0.021333" size="2048" pos="44508" flags="K"/>
<packet codec_type="video" stream_index="0" pts="512" pts_time="0.040000" dts="512" dts_time="0.040000" duration="512" duration_time="0.040000" size="24350" pos="46556" flags="_"/>
<packet codec_type="audio" stream_index="1" pts="2048" pts_time="0.042667" dts="2048" dts_time="0.042667" duration="1024" duration_time="0.021333" size="2048" pos="70906" flags="K"/>
<packet codec_type="audio" stream_index="1" pts="3072" pts_time="0.064000" dts="3072" dts_time="0.064000" duration="1024" duration_time="0.021333" size="2048" pos="72954" flags="K"/>
<packet codec_type="video" stream_index="0" pts="1024" pts_time="0.080000" dts="1024" dts_time="0.080000" duration="512" duration_time="0.040000" size="4281" pos="75002" flags="_"/>
...


Any ideas? I’ve tried -copyts and -vsync to no avail



More information about the ffmpeg-user mailing list