Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG not "cutting" as expected

I am using FFMPEG (from a java application) via a simple system.process and trying to cut a video into chunks. I am attempting to cut it into 10 second increments. My FFMPEG commands look like:

ffmpeg -i SampleVideo.mp4 -ss 00:00:00.00 -t 00:00:10.00 -strict -2 1438458522836/1438458522836_0.mp4
ffmpeg -i SampleVideo.mp4 -ss 00:00:10.01 -t 00:00:20.00 -strict -2 1438458522836/1438458536306_1.mp4
ffmpeg -i SampleVideo.mp4 -ss 00:00:20.01 -t 00:00:30.00 -strict -2 1438458522836/1438458546042_2.mp4
ffmpeg -i SampleVideo.mp4 -ss 00:00:30.01 -t 00:00:40.00 -strict -2 1438458522836/1438458561165_3.mp4
ffmpeg -i SampleVideo.mp4 -ss 00:00:40.01 -t 00:00:50.00 -strict -2 1438458522836/1438458577187_4.mp4
ffmpeg -i SampleVideo.mp4 -ss 00:00:50.01 -t 00:01:00.00 -strict -2 1438458522836/1438458587935_5.mp4

They look correct to me but my videos are not coming out in 10 second increments. They seem to be getting "split" in random spots. Any ideas on what I am doing wrong?

For reference:

video 0 == 10 seconds
video 1 == 20 seconds
Video 2 == 30 seconds
Video 3 == 32 seconds
Video 4 == 22 seconds
Video 5 == 12 seconds

Any help would be appreciated.

like image 531
mornindew Avatar asked Aug 01 '15 20:08

mornindew


1 Answers

As stated in the FFMPEG documentation:

-ss position (input/output) When used as an input option (before -i), seeks in this input file to position. Note the in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.

When used as an output option (before an output filename), decodes but discards input until the timestamps reach position.

position may be either in seconds or in hh:mm:ss[.xxx] form.

So, you won't get an exact starting point, but since -t stops "listening" when the pointer hits the specified time, you don't get uniform times, but they all end when you want.

like image 85
kkirigaya Avatar answered Oct 28 '22 08:10

kkirigaya