Ask Your Question
0

How can I extract a given range from a Video with ffmpeg?

asked 2023-05-12 11:44:56 +0000

wagner gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-12 11:45:01 +0000

wagner gravatar image

You can use the -ss and -to options in ffmpeg to extract a specific range from a video. The -ss option sets the start timestamp and the -to option sets the end timestamp. The timestamps should be in the format HH:MM:SS.

Here's a basic example:

ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4

In this command:

  • -i input.mp4 specifies the input file.
  • -ss 00:01:00 sets the start time of the cut to 1 minute.
  • -to 00:02:00 sets the end time of the cut to 2 minutes.
  • -c copy copies the input streams to the output file. This means the command won't re-encode the video and audio streams, which makes it run faster.
  • output.mp4 is the output file.

This command will extract a 1-minute clip from the input video, starting at 1:00 and ending at 2:00.

Please note that when using -c copy, the cut may not be precise, because it's limited to existing keyframes. If you need a precise cut, you should remove -c copy, which will cause ffmpeg to re-encode the video:

ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 output.mp4

This command will give you a more precise cut, but it will take longer to run.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

1 follower

Stats

Asked: 2023-05-12 11:44:56 +0000

Seen: 15 times

Last updated: May 12 '23