0

I am trying to concatenate 2 files. But When I calculate the duration of each individual input files, it is not the same as the output file.

I use this command:

ffmpeg -vsync 1 -y -i input.mp4 -i input.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map [outv] -map [outa] -preset ultrafast -r 30 output.mp4

my input duration is 19.962100 sec

And my output duration is 39.966667 sec instead of 39.978sec

How I should do to keep the right final duration?

Update

below videos info:

input.mp4

index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=449351/26955000
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
coded_width=1920
coded_height=1088
closed_captions=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=unspecified
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=13477500/449351
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=1796589
duration=19.962100
bit_rate=17005411
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=599
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
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2020-03-02T12:26:42.000000Z
TAG:language=eng
TAG:handler_name=VideoHandle

output.mp4

index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Constrained Baseline
codec_type=video
codec_time_base=1/60
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
coded_width=1920
coded_height=1088
closed_captions=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/15360
start_pts=0
start_time=0.000000
duration_ts=613888
duration=39.966667
bit_rate=12327531
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=1199
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
DISPOSITION:timed_thumbnails=0
TAG:language=und
TAG:handler_name=VideoHandler
6
  • Do they have different original frame rates? (e.g. 29.97 and 30 respectively)
    – Tom Yan
    Apr 15, 2021 at 8:53
  • Thx. I updated my post adding videos info. The frame rates is 30. Apr 15, 2021 at 9:44
  • Are the 2 files actually one same file passed twice? Either way, I think you should try -vsync drop instead. It seems that -vsync 1 caused one frame to duplicate (see nb_frames), possibly due to some weird frame rate variation in the source (see avg_frame_rate).
    – Tom Yan
    Apr 15, 2021 at 9:57
  • Also the bitstream might need some fixes at the end of the day. See if the h264_metadata bitstream filter can help.
    – Tom Yan
    Apr 15, 2021 at 9:59
  • Indeed in this example the input file is passed twice. But the end goal is to be able to concatenate any files and make sure that the duration will be correct. Apr 15, 2021 at 10:05

0

You must log in to answer this question.

Browse other questions tagged .