Opened 4 years ago

Last modified 4 years ago

#2938 new defect

Incorrect start time and duration when transcoding audio-only (-vn) from A/V files.

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

Description

Summary of the bug: When extracting audio only from a a/v file the duration gets extended. When muxed to mov/mp4 container ffprobe reports start time as 0.021333 in top level output, but -0.021333 in -show_streams output. I work on video and audio separately and align the video and audio to start at 0.00. This bug has made it impossible to continue to do this. Using audio filter '-af 'aresample=first_pts=0' results in the same wrong start time and audio duration. I have observed this behavior with the built-in AAC encoder, libfdk_aac, and libfaac. Muxing to matroska or raw AAC results in a 0.00 start time, but the duration is still off by 40ms. I get the same result on all video files that I have tested this problem with, I have not been able to get a start time of 0.00 when muxing to MOV container.

How to reproduce:

% ffmpeg -i big_buck_bunny_480p_h264.mov -vn -c:a aac -strict -2 offset.mov                                                                                                                                        
ffmpeg version N-56052-g59b9ecc Copyright (c) 2000-2013 the FFmpeg developers                                                                                                                                                                
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_480p_h264.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2008-05-27 18:32:32
    timecode        : 00:00:00:00
  Duration: 00:09:56.46, start: 0.000000, bitrate: 3342 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 854x480, 2899 kb/s, 24 fps, 24 tbr, 2400 tbn, 4800 tbc (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:2(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 437 kb/s (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
Output #0, mov, to 'offset.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    timecode        : 00:00:00:00
    encoder         : Lavf55.16.101
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
Stream mapping:
  Stream #0:2 -> #0:0 (aac -> aac)
Press [q] to stop, [?] for help
size=    9445kB time=00:09:56.48 bitrate= 129.7kbits/s    
video:0kB audio:9335kB subtitle:0 global headers:0kB muxing overhead 1.179736%

FFprobe of original file:

% ffprobe big_buck_bunny_480p_h264.mov -show_streams -select_streams a
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_480p_h264.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2008-05-27 18:32:32
    timecode        : 00:00:00:00
  Duration: 00:09:56.46, start: 0.000000, bitrate: 3342 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 854x480, 2899 kb/s, 24 fps, 24 tbr, 2400 tbn, 4800 tbc (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
      timecode        : 00:00:00:00
    Stream #0:2(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 437 kb/s (default)
    Metadata:
      creation_time   : 2008-05-27 18:32:32
      handler_name    : Apple Alias Data Handler
Unsupported codec with id 0 for input stream 1
[STREAM]                                                                                                                                                                                                                                     
index=2
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=28631040
duration=596.480000
bit_rate=437605
nb_frames=27960
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:creation_time=2008-05-27 18:32:32
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
[/STREAM]

FFprobe output of output file:

% ffprobe offset.mov -show_streams                                                                                                                                                  
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'offset.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf55.16.101
  Duration: 00:09:56.50, start: 0.021333, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : DataHandler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=-1024
start_time=-0.021333
duration_ts=28632064
duration=596.501333
bit_rate=128196
nb_frames=27961
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]

Change History (5)

comment:1 in reply to: ↑ description ; follow-ups: Changed 4 years ago by cehoyos

  • Component changed from FFmpeg to undetermined

Replying to rlabonte:

Muxing to matroska or raw AAC results in a 0.00 start time, but the duration is still off by 40ms.

Does this mean audio gets significantly longer (or shorter?) if you encode several times?

comment:2 in reply to: ↑ 1 Changed 4 years ago by rlabonte

Replying to cehoyos:

Replying to rlabonte:

Muxing to matroska or raw AAC results in a 0.00 start time, but the duration is still off by 40ms.

Does this mean audio gets significantly longer (or shorter?) if you encode several times?

I ran the same command as above but muxed to an MKV container.

FFprobe output from MKV output of the same command as before:

% ffprobe offset.mkv -show_streams -show_format                                                                                                                                                      
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, matroska,webm, from 'offset.mkv':
  Metadata:
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    TIMECODE        : 00:00:00:00
    ENCODER         : Lavf55.16.101
  Duration: 00:09:56.50, start: 0.000000, bitrate: 130 kb/s
    Stream #0:0(eng): Audio: aac, 48000 Hz, 5.1, fltp (default)
    Metadata:
      CREATION_TIME   : 2008-05-27 18:32:32
      LANGUAGE        : eng
      HANDLER_NAME    : Apple Alias Data Handler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:CREATION_TIME=2008-05-27 18:32:32
TAG:LANGUAGE=eng
TAG:HANDLER_NAME=Apple Alias Data Handler
[/STREAM]
[FORMAT]
filename=offset.mkv
nb_streams=1
nb_programs=0
format_name=matroska,webm
format_long_name=Matroska / WebM
start_time=0.000000
duration=596.501000
size=9757210
bit_rate=130859
probe_score=100
TAG:MAJOR_BRAND=qt  
TAG:MINOR_VERSION=537199360
TAG:COMPATIBLE_BRANDS=qt  
TAG:TIMECODE=00:00:00:00
TAG:ENCODER=Lavf55.16.101
[/FORMAT]

I previously failed to mention, -c:a copy is unaffected by this bug. I did a -c:a copy of the resulting mkv version to a new mov container and got this:

% ffprobe offset_from_mkv.mov  -show_streams -show_format                                                                                                                                             
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'offset_from_mkv.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf55.16.101
  Duration: 00:09:56.50, start: 0.000000, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : DataHandler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=28632040
duration=596.500833
bit_rate=128196
nb_frames=27961
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]
[FORMAT]
filename=offset_from_mkv.mov
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=596.501000
size=9671451
bit_rate=129709
probe_score=100
TAG:major_brand=qt  
TAG:minor_version=512
TAG:compatible_brands=qt  
TAG:encoder=Lavf55.16.101
[/FORMAT]

comment:3 in reply to: ↑ 1 Changed 4 years ago by rlabonte

Replying to cehoyos:

Replying to rlabonte:

Muxing to matroska or raw AAC results in a 0.00 start time, but the duration is still off by 40ms.

Does this mean audio gets significantly longer (or shorter?) if you encode several times?

I just realized I misinterpreted your question. The short answer is the audio duration gets longer, but the offset remains the same.

% ffmpeg -i big_buck_bunny_480p_h264.mov -vn -c:a aac -strict -2 offset1.mov && ffmpeg -i offset1.mov -vn -c:a aac -strict -2 offset2.mov && ffmpeg -i offset2.mov -vn -c:a aac -strict -2 offset3.mov

The FFprobe result for the final rendition:

% ffprobe offset3.mov -show_streams -show_format                                                                                                                                                      
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'offset3.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf55.16.101
  Duration: 00:09:56.54, start: 0.021333, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : DataHandler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=-1024
start_time=-0.021333
duration_ts=28634112
duration=596.544000
bit_rate=128174
nb_frames=27963
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]
[FORMAT]
filename=offset3.mov
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=-0.021333
duration=596.544000
size=9670468
bit_rate=129686
probe_score=100
TAG:major_brand=qt  
TAG:minor_version=512
TAG:compatible_brands=qt  
TAG:encoder=Lavf55.16.101
[/FORMAT]

comment:4 follow-up: Changed 4 years ago by cehoyos

How much longer does it get if you encode five (or ten) times?

comment:5 in reply to: ↑ 4 Changed 4 years ago by rlabonte

Replying to cehoyos:

How much longer does it get if you encode five (or ten) times?

I did 11 total audio transcodes. The duration grew by 213.333ms from FFprobe's 596.48 seconds for the source audio duration to 596.693333 of the final transcode.

Continuation from my re-transcodes above:

% ffmpeg -i offset3.mov -vn -c:a aac -strict -2 offset4.mov && ffmpeg -i offset4.mov -vn -c:a aac -strict -2 offset5.mov && ffmpeg -i offset5.mov -vn -c:a aac -strict -2 offset6.mov && ffmpeg -i offset6.mov -vn -c:a aac -strict -2 offset7.mov && ffmpeg -i offset7.mov -vn -c:a aac -strict -2 offset8.mov && ffmpeg -i offset8.mov -vn -c:a aac -strict -2 offset9.mov && ffmpeg -i offset9.mov -vn -c:a aac -strict -2 offset10.mov

FFprobe output of offset10.mov:

ffprobe offset10.mov -show_streams
ffprobe version N-56052-g59b9ecc Copyright (c) 2007-2013 the FFmpeg developers                                                                                                                                                               
  built on Sep  5 2013 14:16:47 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfdk_aac --enable-libx264 --enable-libfreetype
  libavutil      52. 43.100 / 52. 43.100
  libavcodec     55. 31.101 / 55. 31.101
  libavformat    55. 16.101 / 55. 16.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 83.102 /  3. 83.102
  libswscale      2.  5.100 /  2.  5.100
  libswresample   0. 17.103 /  0. 17.103
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'offset10.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf55.16.101
  Duration: 00:09:56.69, start: 0.021333, bitrate: 129 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : DataHandler
[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=6
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=-1024
start_time=-0.021333
duration_ts=28641280
duration=596.693333
bit_rate=128101
nb_frames=27970
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]
Note: See TracTickets for help on using tickets.