[FFmpeg-user] h264 timebase question

Stuart Bruce stuartrbruce at gmail.com
Tue Dec 31 11:21:49 CET 2013


Hello

The background of the problem: I'm trying to use FFmpeg to save time 
during bulk exports of videos from Avid Media Composer. I've got a MOV 
that was exported from Avid at the right settings (h264, 640x360), which 
took some time to export. I've also got a 'same as source' export MOV, 
which exported much quicker but which is far too big. So I'm trying to 
get FFmpeg to convert the large same as source MOV so that it matches 
the settings of the correctly-sized MOV.

However, so far I haven't been able to get it to match. The problems lie 
(I think) in the time_base and codec_time_base settings.

Here's my command line so far:

-i "[source file]" -s 640x360 -pix_fmt yuv420p -vcodec libx264 -acodec 
pcm_s16be -b:v 768k -ar 44100 -profile:v main -level 3.1 
-force_key_frames expr:gte(t,n_forced) -bf 0 -ac 1 -threads 4 -y 
"[output file]"

I've pasted 3 stream analyses from FFprobe below. Number (1) is from the 
source file, number (2) is what I'm aiming for, and number (3) is what 
I'm getting.

The key differences are in codec_time_base (1/48 instead of 1/48000), 
time_base (which has become 1/12288 even though the source is 1/24000), 
and duration_ts.

Unfortunately because they don't match, this is throwing off some other 
thumbnail-generation aspects which are based on seeking to the correct 
point in the resulting movie. With the Avid-exported MOV, the thumbnail 
generation is frame accurate, but using the FFmpeg-sourced MOV, this 
seeking is often a frame off, when it absolutely needs to be frame-accurate.

Apologies that this explanation is a bit long-winded. I'm not, as you 
can tell, an encoding expert. Any help would be very much appreciated.

Thanks

Stuart



(1) The source I'm using:
[STREAM]
index=0
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=1671000
duration=69.625000
bit_rate=36175872
nb_frames=1671
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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=2013-12-24 09:15:03
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
[/STREAM]

(2) The output I'm aiming for (analysis based on a file exported 
directly from Avid Media Composer):
[STREAM]
index=1
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/48000
codec_tag_string=avc1
codec_tag=0x31637661
width=640
height=360
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=31
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=1671000
duration=69.625000
bit_rate=736680
nb_frames=1671
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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=2013-12-24 11:55:57
TAG:language=eng
TAG:handler_name=Apple Alias Data Handler
[/STREAM]

(3) The output I'm actually getting from the FFmpeg-generated file:
[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      <-- different
codec_tag_string=avc1
codec_tag=0x31637661
width=640
height=360
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=31
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/12288      <-- different
start_pts=0
start_time=0.000000
duration_ts=855552      <-- different
duration=69.625000
bit_rate=796023
nb_frames=1671
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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
TAG:timecode=01:00:00:00
[/STREAM]

-- 
Stuart Bruce
stuart at stuartbruce.co.uk



More information about the ffmpeg-user mailing list