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.
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
Asked: 2023-05-12 11:44:56 +0000
Seen: 15 times
Last updated: May 12 '23
How to use ffmpeg to provide a video stream in Node?
What is the process for converting a complete directory using ffmpeg?
Command line option for ffmgeg creating an output MP4 with 720p and 60fps for Youtube?
How to save ffmpeg output to a file using redirection?
Is it possible for ffmpeg to display a progress bar?
ffmpeg: How can I get the bit rate of a MP3 File?
How can hdmv pgs subtitles be extracted from an mkv file and converted to srt format using ffmpeg?
How can FFmpeg open an RTSP stream with the same URL?
What is the process for combining several mono files into a single multichannel file using FFmpeg?