Opened 7 years ago

Last modified 2 years ago

#110 reopened defect

MP4 Muxer gives incorrect frame duration with AAC

Reported by: thebombzen Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: aac mov
Cc: michael Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The frame durations of an MP4/AAC file are inaccurate according to FAAD. I encoded an M4A file with

ffmpeg -v 9 -loglevel 99 -i IJustHadSex.m4v -vn -acodec copy -map_metadata 0:0 "I Just Had Sex.m4a"

The full uncut output is this:

FFmpeg version git-N-29123-g256c5b0, Copyright (c) 2000-2011 the FFmpeg developers

built on Apr 14 2011 21:24:32 with gcc 4.7.0 20110402 (experimental)
configuration: --enable-cross-compile --arch=x86_64 --target-os=mingw32 --cross-prefix=/usr/x86_64-w64-mingw32/bin/ --prefix=/usr/local/x86_64-w64-mingw32 --pkg-config=pkg-config --cpu=i7
libavutil 50. 40. 1 / 50. 40. 1
libavcodec 52.119. 0 / 52.119. 0
libavformat 52.107. 0 / 52.107. 0
libavdevice 52. 4. 0 / 52. 4. 0
libavfilter 1. 78. 0 / 1. 78. 0
libswscale 0. 13. 0 / 0. 13. 0

[NULL @ 000000000033A770] Probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000033A770] ISO: File Type Major Brand: M4V
[h264 @ 000000000033B7B0] Unsupported bit depth: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000033A770] All info found

Seems stream 0 codec frame rate differs from container frame rate: 47.96 (1199/25) -> 23.98 (1199/50)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IJustHadSex.m4v':

Metadata:

major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.104.0
title : I Just Had Sex (feat. Akon)
artist : The Lonely Island
album : Incredibad

Duration: 00:02:55.31, start: 0.000000, bitrate: 1306 kb/s

Stream #0.0(und), 2, 1/1199: Video: h264 (Constrained Baseline), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 25/1199, 1171 kb/s, 23.98 fps, 23.98 tbr, 1199 tbn, 47.96 tbc
Metadata:

creation_time : 1970-01-01 00:00:00

Stream #0.1(und), 1, 1/44100: Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
Metadata:

creation_time : 1970-01-01 00:00:00

Output #0, ipod, to 'I Just Had Sex.m4a':

Metadata:

major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
creation_time : 1970-01-01 00:00:00
album : Incredibad
title : I Just Had Sex (feat. Akon)
artist : The Lonely Island
encoder : Lavf52.107.0
Stream #0.0(und), 0, 1/44100: Audio: aac, 44100 Hz, stereo, 128 kb/s
Metadata:

creation_time : 1970-01-01 00:00:00

Stream mapping:

Stream #0.1 -> #0.0

Press [q] to stop encoding
size= 2845kB time=175.31 bitrate= 132.9kbits/s

video:0kB audio:2739kB global headers:0kB muxing overhead 3.847214%

The full ffmpeg -v 9 -loglevel 99 -i for the new input file is this:

FFmpeg version git-N-29123-g256c5b0, Copyright (c) 2000-2011 the FFmpeg developers

built on Apr 14 2011 21:24:32 with gcc 4.7.0 20110402 (experimental)
configuration: --enable-cross-compile --arch=x86_64 --target-os=mingw32 --cross-prefix=/usr/x86_64-w64-mingw32/bin/ --prefix=/usr/local/x86_64-w64-mingw32 --pkg-config=pkg-config --cpu=i7
libavutil 50. 40. 1 / 50. 40. 1
libavcodec 52.119. 0 / 52.119. 0
libavformat 52.107. 0 / 52.107. 0
libavdevice 52. 4. 0 / 52. 4. 0
libavfilter 1. 78. 0 / 1. 78. 0
libswscale 0. 13. 0 / 0. 13. 0

[NULL @ 00000000014BA410] Probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000014BA410] ISO: File Type Major Brand: M4A
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000014BA410] All info found
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'I Just Had Sex.m4a':

Metadata:

major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
creation_time : 1970-01-01 00:00:00
title : I Just Had Sex (feat. Akon)
artist : The Lonely Island
album : Incredibad
encoder : Lavf52.107.0

Duration: 00:02:55.31, start: 0.000000, bitrate: 132 kb/s

Stream #0.0(und), 1, 1/44100: Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
Metadata:

creation_time : 1970-01-01 00:00:00

At least one output file must be specified

However, FAAD claims that the frame duration is inaccurate for the MP4, and that it has to use the duration listed in the AAC bitstream instead. Furthermore, iTunes says the file has a duration of 789:57:13, which is iTunes's way of saying Error!

The FAAD output is this:

* Ahead Software MPEG-4 AAC Decoder V2.7

Build: Jun 14 2010
Copyright 2002-2004: Ahead Software AG
http://www.audiocoding.com
Floating point version

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.


I Just Had Sex.m4a file info:

LC AAC 175.139 secs, 2 ch, 44100 Hz

title: I Just Had Sex (feat. Akon)
artist: The Lonely Island
album: Incredibad
tool: Lavf52.107.0

---------------------

| Config: 2 Ch |

---------------------

| Ch | Position |

---------------------

| 00 | Left front |
| 01 | Right front |

---------------------

MP4 seems to have incorrect frame duration, using values from AAC data.
Decoding I Just Had Sex.m4a took: 0.84 sec. 208.00% real-time.

Notice the MP4 error.

This is important because iTunes won't play the resulting file.

Attachments (3)

ticket110.mp4 (646.7 KB) - added by cehoyos 6 years ago.
ticket110_elbandi.mp4 (19.1 KB) - added by Elbandi 6 years ago.
copy.ts (1.8 MB) - added by zengyi 4 years ago.
FFmpeg get a wrong duration with this file also。The correct duration is 8 seconds。

Change History (15)

comment:1 Changed 7 years ago by cehoyos

  • Priority changed from important to normal
  • Status changed from new to open

Could you test latest git HEAD? Your version is >200 changes old.

comment:2 Changed 7 years ago by thebombzen

I have confirmed that this error still occurs with git-N-29369-g03a91c7, built April 25.

ffmpeg version git-N-29369-g03a91c7, Copyright (c) 2000-2011 the FFmpeg developers

built on Apr 25 2011 16:05:01 with gcc 4.5.1 20100924 (Red Hat 4.5.1-4)
configuration: --enable-static --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-x11grab --enable-runtime-cpudetect --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencv --enable-libdc1394 --enable-libfaac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib --arch=x86_64 --cpu=i7 --enable-pic --enable-sram --extra-libs=-lx264 --extra-cflags='-O3 -w'
libavutil 51. 0. 0 / 51. 0. 0
libavcodec 53. 1. 0 / 53. 1. 0
libavformat 53. 0. 3 / 53. 0. 3
libavdevice 53. 0. 0 / 53. 0. 0
libavfilter 2. 0. 0 / 2. 0. 0
libswscale 0. 13. 0 / 0. 13. 0
libpostproc 51. 2. 0 / 51. 2. 0

The FAAD message still holds:

SI.m4a file info:

LC AAC 225.617 secs, 2 ch, 44100 Hz

tool: Lavf53.0.3

channel config

MP4 seems to have incorrect frame duration, using values from AAC data.
Decoding SI.m4a took: 0.81 sec. 278.54x real-time.

comment:3 Changed 6 years ago by cehoyos

I am unable to reproduce this with a random m4v input file and a cut random m4v input file (and faad 2.7).

Please upload a sample.

comment:4 Changed 6 years ago by cehoyos

  • Version changed from git to git-master
$ ffmpeg -i ticket110.mp4 -acodec copy out.m4a
ffmpeg version N-33430-gcb50ada, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct  9 2011 20:28:29 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil    51. 20. 1 / 51. 20. 1
  libavcodec   53. 19. 1 / 53. 19. 1
  libavformat  53. 14. 0 / 53. 14. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ticket110.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1969-12-31 23:00:00
    encoder         : Lavf53.14.0
  Duration: 00:00:50.50, start: 0.000000, bitrate: 104 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 99 kb/s
    Metadata:
      creation_time   : 1969-12-31 23:00:00
Output #0, ipod, to 'out.m4a':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1969-12-31 23:00:00
    encoder         : Lavf53.14.0
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 99 kb/s
    Metadata:
      creation_time   : 1969-12-31 23:00:00
Stream mapping:
  Stream #0.0 -> #0.0 (copy)
Press [q] to stop, [?] for help
size=     647kB time=00:00:50.50 bitrate= 104.9kbits/s
video:0kB audio:616kB global headers:0kB muxing overhead 5.001625%
$ ffmpeg -i out.m4a
ffmpeg version N-33430-gcb50ada, Copyright (c) 2000-2011 the FFmpeg developers
  built on Oct  9 2011 20:28:29 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil    51. 20. 1 / 51. 20. 1
  libavcodec   53. 19. 1 / 53. 19. 1
  libavformat  53. 14. 0 / 53. 14. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 43. 6 /  2. 43. 6
  libswscale    2.  1. 0 /  2.  1. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    creation_time   : 1969-12-30 23:00:00
    encoder         : Lavf53.14.0
  Duration: 00:00:50.50, start: 0.000000, bitrate: 104 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 99 kb/s
    Metadata:
      creation_time   : 1969-12-30 23:00:00
At least one output file must be specified
$ faad out.m4a
 *********** Ahead Software MPEG-4 AAC Decoder V2.7 ******************

 Build: Mar 31 2010
 Copyright 2002-2004: Ahead Software AG
 http://www.audiocoding.com
 Floating point version

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License.

 **************************************************************************

out.m4a file info:

LC AAC  50.454 secs, 2 ch, 44100 Hz

tool: Lavf53.14.0

  ---------------------
 | Config:  2 Ch       |
  ---------------------
 | Ch |    Position    |
  ---------------------
 | 00 | Left front     |
 | 01 | Right front    |
  ---------------------

MP4 seems to have incorrect frame duration, using values from AAC data.
Decoding out.m4a took:  0.17 sec. 296.79x real-time.

Changed 6 years ago by cehoyos

comment:5 Changed 6 years ago by cehoyos

  • Keywords aac mp4 added

comment:6 Changed 6 years ago by Elbandi

Same error.

$ ffmpeg -i ticket110_elbandi.mp4
ffmpeg version 0.7.2-4:0.7.2-1ubuntu1, Copyright (c) 2000-2011 the Libav developers
  built on Nov 10 2011 09:55:34 with gcc 4.4.3
  configuration: --extra-version='4:0.7.2-1ubuntu1' --arch=amd64 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-libopenjpeg --enable-libfaac --enable-nonfree --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdirac --enable-libmp3lame --enable-librtmp --enable-libx264 --enable-libxvid --enable-libopencore-amrnb --enable-version3 --enable-libopencore-amrwb --enable-version3 --enable-libdc1394 --enable-shared --disable-static
  libavutil    51.  7. 0 / 51.  7. 0
  libavcodec   53.  5. 0 / 53.  5. 0
  libavformat  53.  2. 0 / 53.  2. 0
  libavdevice  53.  0. 0 / 53.  0. 0
  libavfilter   2.  4. 0 /  2.  4. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  52.  0. 0 / 52.  0. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ticket110_elbandi.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.2.0
  Duration: 00:00:03.05, start: 0.000000, bitrate: 51 kb/s
    Stream #0.0(eng): Audio: aac, 16000 Hz, mono, s16, 48 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
$ faad ticket110_elbandi.mp4
 *********** Ahead Software MPEG-4 AAC Decoder V2.7 ******************

 Build: Nov 10 2009
 Copyright 2002-2004: Ahead Software AG
 http://www.audiocoding.com
 Floating point version

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License.

 **************************************************************************

ticket110_elbandi.mp4 file info:

LC AAC  1.503 secs, 2 ch, 32000 Hz

tool: Lavf53.2.0

  ---------------------
 | Config:  2 Ch       |
  ---------------------
 | Ch |    Position    |
  ---------------------
 | 00 | Left front     |
 | 01 | Right front    |
  ---------------------

Decoding ticket110_elbandi.mp4 took:  0.02 sec. 75.13x real-time.

Changed 6 years ago by Elbandi

comment:7 Changed 5 years ago by michael

  • Resolution set to worksforme
  • Status changed from open to closed

Testing with latest ffmpeg, both encoding as well as stream copy lead to files that show identical
durations with faad and ffmpeg. So i assume this has been fixed. If not please provide a input file that gets muxed with ffmpeg to something with bad duration and reopen the ticket

comment:8 Changed 5 years ago by cehoyos

  • Resolution worksforme deleted
  • Status changed from closed to reopened

If there ever was an issue (I am not sure), it is not fixed, faad still reports "MP4 seems to have incorrect frame duration, using values from AAC data."

comment:9 Changed 5 years ago by cehoyos

  • Keywords mov added; mp4 removed

Changed 4 years ago by zengyi

FFmpeg get a wrong duration with this file also。The correct duration is 8 seconds。

comment:10 Changed 4 years ago by zengyi

this is the log: ffmpeg gets duration 23:17:30.63
./ffmpeg -i /home/copy.ts
ffmpeg version 1.1.git Copyright (c) 2000-2013 the FFmpeg developers

built on May 8 2013 17:15:46 with gcc 4.4.6 (GCC) 20110731 (Red Hat 4.4.6-3)
configuration: --disable-yasm --disable-asm
libavutil 52. 30.100 / 52. 30.100
libavcodec 55. 7.100 / 55. 7.100
libavformat 55. 4.101 / 55. 4.101
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 63.101 / 3. 63.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102

[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=83536, dts=1050949216, size=1076
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=87136, dts=2101814896, size=19108
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590043328, dts=9549390032, size=13220
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590072128, dts=9457950256, size=12484
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590100928, dts=9366557280, size=12484
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590133328, dts=9275232704, size=14876
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590158528, dts=9183965728, size=9908
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590198128, dts=9092767152, size=13588
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590234128, dts=9001676576, size=8988
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590255728, dts=8910650800, size=8988
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590270128, dts=8819635824, size=6964
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590284528, dts=8728620848, size=7884
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590306128, dts=8637609472, size=7884
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590349328, dts=9597672576, size=11932
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590374528, dts=9506801600, size=10460
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590403328, dts=9415970224, size=10828
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590442928, dts=9325218048, size=13956
[mpegts @ 0x2d21ee0] Invalid timestamps stream=0, pts=8590478928, dts=9234559472, size=12852
[mpegts @ 0x2d21ee0] max_analyze_duration 5000000 reached at 5000000 microseconds
[mpegts @ 0x2d21ee0] PES packet size mismatch
Input #0, mpegts, from '/home/copy.ts':

Duration: 23:17:30.63, start: 11677.213522, bitrate: 1 kb/s
Program 1

Stream #0:0[0x1022]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 528x576 [SAR 1:1 DAR 11:12], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1023]: Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s

comment:11 Changed 4 years ago by cehoyos

Just for reference: I did not open a new ticket for the unrelated sample because the file has invalid timestamps and I am not convinced that "duration" is strictly defined for a sample with broken timestamps. Could be tested again once ticket #1438 is fixed.

comment:12 Changed 2 years ago by michael

  • Cc michael added

Can someone explain what issue this is about ?
the input file ticket110.mp4 has durations at muxer level which dont match aac, obviously when remuxing they will still mismatch

Note: See TracTickets for help on using tickets.