Skip to content

Instantly share code, notes, and snippets.

@ignasbol
Created September 27, 2021 21:21
Show Gist options
  • Select an option

  • Save ignasbol/01f527b79f79398092aa115384ef2c3d to your computer and use it in GitHub Desktop.

Select an option

Save ignasbol/01f527b79f79398092aa115384ef2c3d to your computer and use it in GitHub Desktop.
Video fast trim

Quickly trim a video file without losing original settings

Option #1

ffmpeg -i <input_file> -ss <start_time> -to <end_time> -c:v copy -c:a copy <output_file>

Option #2

ffmpeg -i <input_file> -ss <start_time> -t <duration> -c:v copy -c:a copy <output_file>

Parameters

  • -i <input_file> - input file name (e.g. input.mp4)
  • -ss <start_time> - sets the start time offset, format HH:MM:SS.m or specified as a number of seconds (e.g. 30)
  • -to <end_time> - sets the end time offset, format HH:MM:SS.m or specified as a number of seconds (e.g. 30)
  • -t <duration> - sets the duration to be cut, specified as a number of seconds (e.g. 30)
  • -c:v copy - copy video codec from the input file
  • -c:a copy - copy audio codec from the input file
  • <output_file> - output file name (e.g. output.mp4)

Note: if both -t and -to are specified, only -t will be used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment