cutting video with ffmpeg

Author:

to cut out a 6 minutes and 56.935 seconds long piece of video which starts 6 minutes and 20.112 seconds into input_file.MTS using ffmpeg and not reencoding the file, you can run:

ffmpeg -ss 00:06:20.112 -i input_file.MTS -c copy -t 00:06:56.935 output_file.MTS

from the ffmpeg man page:

       -t duration (input/output)
           When used as an input option (before "-i"), limit the duration of data read from the input file.

           When used as an output option (before an output url), stop writing the output after its duration reaches duration.

           duration must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

           -to and -t are mutually exclusive and -t has priority.

       -to position (input/output)
           Stop writing the output or reading the input at position.  position must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

           -to and -t are mutually exclusive and -t has priority.

       -fs limit_size (output)
           Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The size of the output file is slightly more than the
           requested file size.

       -ss position (input/output)
           When used as an input option (before "-i"), seeks in this input file to position. Note that 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 url), decodes but discards input until the timestamps reach position.

           position must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

       -sseof position (input)
           Like the "-ss" option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF.

and from the ffmpeg-utils man page

   Time duration
       There are two accepted syntaxes for expressing time duration.

               [-][<HH>:]<MM>:<SS>[.<m>...]

       HH expresses the number of hours, MM the number of minutes for a maximum of 2 digits, and SS the number of seconds for a maximum of 2 digits. The m at the end expresses
       decimal value for SS.

       or

               [-]<S>+[.<m>...]

       S expresses the number of seconds, with the optional decimal part m.

       In both expressions, the optional - indicates negative duration.

       Examples

       The following examples are all valid time duration:

       55  55 seconds

       12:03:45
           12 hours, 03 minutes and 45 seconds

       23.189
           23.189 seconds

Leave a Reply

Your email address will not be published. Required fields are marked *