I am extracting a 1-minute-long fragment of a video file starting at 30 min from the beginning, and adding subtitles from an external file using the following command:
ffmpeg -ss 1800 -i input_video.m4v -ss 1800 -i input_subtitle.srt -map 1:0 -c:a aac -c:v libx264 -c:s mov_text -crf 35 -preset slow -t 60 -avoid_negative_ts 1 output_video.mp4
The problem I get is that the transcoded video has duration 00:01:03.50
instead of expected 00:01:00.00
. And when playing such video with VLC, the playback stops before the progress bar reaches the end.
The duration becomes exactly 1 minute only if I remove the subtitle input. Looks like the duration of the output file is extended to fit in the last phrase from the subtitle that starts within the defined 1-minute range.
Is there a way to force the output duration to exactly the value set in the -d
flag?