[FFmpeg-user] Stream merge with offset presents additional delay
Φιλντίσης Παναγιώτης
filntisis.panagiotis at gmail.com
Sun Oct 23 04:11:20 EEST 2016
I have a .MTS video recorded with a panasonic camera with both a video and
audio streams. I want to replace the audio stream with another audio stream
taken via a high quality microphone. I have already aligned both audio
streams and want to merge the video with the new audio. However if I merge
directly:
ffmpeg -i 00101.MTS -itsoffset 29.4009 -i good.wav -c:v copy -c:a copy
-map 0:0 -map 1:0 output.mkv
and check the frames with ffprobe:
ffprobe -i output.mkv -show_frames
then the first audio frame comes at about 60 ms later at 29.468.
If I first do though:
ffmpeg -i 00101.mts -c:v copy -c:a copy 00101.mkv
and then I merge using the video stream from the 00101.mkv file the first
audio frame comes at a correct time. Is this a bug of ffmpeg or is ffmpeg
taking account for something i am not aware? If not what is happening ? I
am pretty new to encoding and stuff like that. A correct time occurs also
if i use the .MTS video directly but instead of copying using libx264
encoding.
Some additional information is that the start_time of both streams in the
original .MTS file is not zero (while in the 00101.mkv file it is) but at
0.400144 seconds.
Moreover in the .MTS video the output from ffprobe shows that the duration
of the frame is 0.016678 while in the .mkv the duration is 0.033 (the video
fps is 29.97):
.MTS
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=36013
pkt_pts_time=0.400144
pkt_dts=37515
pkt_dts_time=0.416833
best_effort_timestamp=36013
best_effort_timestamp_time=0.400144
pkt_duration=1501
pkt_duration_time=0.016678
pkt_pos=47232
pkt_size=12268
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=1
display_picture_number=0
interlaced_frame=1
top_field_first=1
repeat_pict=0
[/FRAME]
.mkv
[FRAME]
media_type=video
stream_index=0
key_frame=0
pkt_pts=0
pkt_pts_time=0.000000
pkt_dts=17
pkt_dts_time=0.017000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=33
pkt_duration_time=0.033000
pkt_pos=45198
pkt_size=12268
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=B
coded_picture_number=1
display_picture_number=0
interlaced_frame=1
top_field_first=1
repeat_pict=0
[/FRAME]
More information about the ffmpeg-user
mailing list