Sunday, September 21, 2025

specifying start and end times with ffmpeg

Trying

-ss 00:01:00 == starts at 1 minute
-t 00:01:00 == duration 1 minute

(-start_number when encoding single frame-sequences)

-start_number or -ss has to come before the -i if ffmpeg has to seek without decoding.

putting -t at the beginning, before the input, does not work. 
-t 00:00:10 output.mp4
creates a file with 10 second duration.

but
-ss 00:02:00 -t 00:00:10 output.mp4
Nothing was written into output file, because at least one of its streams received no packets.

Putting -ss at the end of the first -i input.mp4 led to seg fault.

If the input file is properly seekable, this should work to seek to 30 seconds into the video, and get an output which is 10 seconds long starting from that point - 
ffmpeg -ss 30 -i input.mp4 -t 10 -c copy output.mp4

Finishes in milliseconds but won't be frame-accurate due to the -c copy - via https://dev.to/javidjamae/ffmpeg-ss-t-and-to-flags-input-vs-output-seeking-2b3p

No comments:

Post a Comment