[FFmpeg-user] converting to AAC audio duration changes
Jeanne Rich
jrich at laika.com
Mon Sep 16 23:44:10 CEST 2013
Hi.
I'm trying to create an H.264 with AAC audio quicktime movie from an DNxHD quicktime movie with PCM audio. What I am noticing is that the AAC audio ends up having a longer duration than the original PCM audio and starts at a negative timestamp. This is causing me problems since my tools think the resulting movie is longer than it actually should be. I also am trying to take chuncks of the resulting movie and concat them together with the demuxer. Am I doing something wrong with the encoding parameters, and also, when I concat the movie, I am using the duration directive to be 1 second each for the 2 movies I am concatenating, but I end up with a movie longer than 2 seconds.
Below is the original Avid movie properties via ffprobe:
/local/prod/b3p/2.0/ffmpeg/HEAD/bin/ffprobe '-show_streams' '-show_format' '/laika/home/j/jrich/data/hbm_edit/0100_MON_2012_10_22_QT.mov'
ffprobe version 2.0-b7dd459 Copyright (c) 2007-2013 the FFmpeg developers
built on Sep 16 2013 12:06:10 with gcc 4.1.2 (GCC)
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/HEAD --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC'
libavutil 52. 43.100 / 52. 43.100
libavcodec 55. 31.101 / 55. 31.101
libavformat 55. 16.103 / 55. 16.103
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 85.100 / 3. 85.100
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 '/laika/home/j/jrich/data/hbm_edit/0100_MON_2012_10_22_QT.mov':
Metadata:
creation_time : 2012-11-14 17:40:17
timecode : 01:00:09:00
Duration: 00:02:09.13, start: 0.000000, bitrate: 37728 kb/s
Stream #0:0(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
Metadata:
creation_time : 2012-11-14 17:40:18
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080, 36175 kb/s, 24 fps, 24 tbr, 24k tbn, 24k tbc (default)
Metadata:
creation_time : 2012-11-14 17:40:18
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2012-11-14 17:45:17
handler_name : Apple Alias Data Handler
timecode : 01:00:09:00
Unsupported codec with id 0 for input stream 2
[STREAM]
index=0
codec_name=pcm_s16be
codec_long_name=PCM signed 16-bit big-endian
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=twos
codec_tag=0x736f7774
sample_fmt=s16
sample_rate=48000
channels=2
bits_per_sample=16
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=6198000
duration=129.125000
bit_rate=1536000
nb_frames=6198000
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=2012-11-14 17:40:18
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
[/STREAM]
[STREAM]
index=1
codec_name=dnxhd
codec_long_name=VC3/DNxHD
profile=unknown
codec_type=video
codec_time_base=1/24000
codec_tag_string=AVdn
codec_tag=0x6e645641
width=1920
height=1080
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv422p
level=-99
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/24000
start_pts=0
start_time=0.000000
duration_ts=3099000
duration=129.125000
bit_rate=36175872
nb_frames=3099
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=2012-11-14 17:40:18
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
[/STREAM]
[STREAM]
index=2
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_time_base=1/24
codec_tag_string=tmcd
codec_tag=0x64636d74
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/600
start_pts=0
start_time=0.000000
duration_ts=77475
duration=129.125000
bit_rate=N/A
nb_frames=1
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=2012-11-14 17:45:17
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
TAG:timecode=01:00:09:00
[/STREAM]
[FORMAT]
filename=/laika/home/j/jrich/data/hbm_edit/0100_MON_2012_10_22_QT.mov
nb_streams=3
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=129.125000
size=608967160
bit_rate=37728846
probe_score=95
TAG:creation_time=2012-11-14 17:40:17
TAG:timecode=01:00:09:00
[/FORMAT]
I then run the following command to convert it to a quicktime movie encoded with H.264 for the video and AAC for the audio:
/local/prod/b3p/2.0/ffmpeg/HEAD/bin/ffmpeg '-i' '/laika/home/j/jrich/data/hbm_edit/0100_MON_2012_10_22_QT.mov' '-f' 'mov' '-preset' 'slow' '-profile:v' 'main' '-pix_fmt' 'yuv420p' '-crf' '1' '-bf' '0' '-movflags' 'faststart' '-r' '24.0' '-map_metadata' '-1:s' '-acodec' 'libfaac' '-aq' '1' '-ar' '48000' '-ac' '2' '-ab' '128k' '-y' '/laika/tmp/jrich/trans/outH264.mov'
ffmpeg version 2.0-b7dd459 Copyright (c) 2000-2013 the FFmpeg developers
built on Sep 16 2013 12:06:10 with gcc 4.1.2 (GCC)
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/HEAD --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC'
libavutil 52. 43.100 / 52. 43.100
libavcodec 55. 31.101 / 55. 31.101
libavformat 55. 16.103 / 55. 16.103
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 85.100 / 3. 85.100
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/laika/home/j/jrich/data/hbm_edit/0100_MON_2012_10_22_QT.mov':
Metadata:
creation_time : 2012-11-14 17:40:17
timecode : 01:00:09:00
Duration: 00:02:09.13, start: 0.000000, bitrate: 37728 kb/s
Stream #0:0(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s (default)
Metadata:
creation_time : 2012-11-14 17:40:18
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080, 36175 kb/s, 24 fps, 24 tbr, 24k tbn, 24k tbc (default)
Metadata:
creation_time : 2012-11-14 17:40:18
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2012-11-14 17:45:17
handler_name : Apple Alias Data Handler
timecode : 01:00:09:00
[libx264 @ 0xfc3040] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0xfc3040] profile Main, level 5.0
[libx264 @ 0xfc3040] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x1:0x111 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to '/laika/tmp/jrich/trans/outH264.mov':
Metadata:
encoder : Lavf55.16.103
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 12288 tbn, 24 tbc (default)
Stream #0:1: Audio: aac (libfaac) (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:1 -> #0:0 (dnxhd -> libx264)
Stream #0:0 -> #0:1 (pcm_s16be -> libfaac)
Press [q] to stop, [?] for help
[mov @ 0xfc2780] Starting second pass: moving the moov atom to the beginning of the file
frame= 3099 fps= 12 q=-1.0 Lsize= 414956kB time=00:02:09.13 bitrate=26324.7kbits/s
video:414729kB audio:163kB subtitle:0 global headers:0kB muxing overhead 0.015614%
[libx264 @ 0xfc3040] frame I:21 Avg QP: 0.54 size:572544
[libx264 @ 0xfc3040] frame P:3078 Avg QP: 4.12 size:134067
[libx264 @ 0xfc3040] mb I I16..4: 39.2% 0.0% 60.8%
[libx264 @ 0xfc3040] mb P I16..4: 2.3% 0.0% 6.8% P16..4: 9.2% 8.4% 9.0% 0.0% 0.0% skip:64.3%
[libx264 @ 0xfc3040] coded y,uvDC,uvAC intra: 79.2% 67.4% 59.5% inter: 20.5% 13.3% 12.5%
[libx264 @ 0xfc3040] i16 v,h,dc,p: 46% 19% 32% 4%
[libx264 @ 0xfc3040] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 21% 16% 4% 3% 4% 3% 4% 4%
[libx264 @ 0xfc3040] i8c dc,h,v,p: 66% 13% 21% 1%
[libx264 @ 0xfc3040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0xfc3040] ref P L0: 51.4% 3.9% 16.4% 12.8% 7.9% 7.6% 0.0%
[libx264 @ 0xfc3040] kb/s:26311.34
The resulting ffprobe shows the result of the conversion:
/local/prod/b3p/2.0/ffmpeg/HEAD/bin/ffprobe '-show_streams' '-show_format' /laika/tmp/jrich/trans/outH264.mov
ffprobe version 2.0-b7dd459 Copyright (c) 2007-2013 the FFmpeg developers
built on Sep 16 2013 12:06:10 with gcc 4.1.2 (GCC)
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/HEAD --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC'
libavutil 52. 43.100 / 52. 43.100
libavcodec 55. 31.101 / 55. 31.101
libavformat 55. 16.103 / 55. 16.103
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 85.100 / 3. 85.100
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 '/laika/tmp/jrich/trans/outH264.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf55.16.103
Duration: 00:02:09.15, start: 0.021333, bitrate: 26321 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 26311 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : DataHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 10 kb/s (default)
Metadata:
handler_name : DataHandler
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Main
codec_type=video
codec_time_base=1/48
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=50
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/12288
start_pts=0
start_time=0.000000
duration_ts=1586688
duration=129.125000
bit_rate=26311376
nb_frames=3099
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]
[STREAM]
index=1
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=2
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=6199024
duration=129.146333
bit_rate=10343
nb_frames=6054
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=/laika/tmp/jrich/trans/outH264.mov
nb_streams=2
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=-0.021333
duration=129.147000
size=424915427
bit_rate=26321350
probe_score=100
TAG:major_brand=qt
TAG:minor_version=512
TAG:compatible_brands=qt
TAG:encoder=Lavf55.16.103
[/FORMAT]
Below is the file I am using for the concat demuxer: Is this formatted correctly?
file /laika/tmp/jrich/trans/outVideoSegment1.mov
duration 1.000000
file /laika/tmp/jrich/trans/outVideoSegment2.mov
duration 1.000000
at 24 fps, I would think I would get a movie that has 48 frames, but I am getting a movie with 49 frames. The 2 movies are h264 with AAC audio, and in both cases I have the same issue as described above, audio is longer than video, and audio starts at a negative TS.
-jeanne
More information about the ffmpeg-user
mailing list