ffmpeg -ss START -i input.mp4 -to END -c copy output.mp4 to cut a video segment without reencoding. This approach utilizes streamcopy, which copies audio and video data directly from the source file to the new container. It is significantly faster than re-encoding because it avoids complex decoding and encoding processes.
Understanding Streamcopy for Fast Cuts
The core mechanism that allows FFmpeg to cut videos instantly is the -c copy flag (or its shorthand -codec copy). When you specify this flag, FFmpeg does not touch the actual media streams. Instead, it reads the existing packets from the input file and writes them into a new container format with minimal overhead. This process is often referred to as "stream copying" or "remuxing."
Because no pixel data is decoded and then re-encoded, there is absolutely zero generation loss in terms of compression artifacts. The quality of the output file is identical to the source material within the selected time range. This makes the method ideal for quick edits, archival purposes, or preparing clips for further processing where preserving original fidelity is critical.
Why Not Reencode?
Reencoding involves decoding every frame of the video, applying filters or transformations, and then compressing those frames again using a codec like H.264 or H.265. This process is computationally expensive and can take hours for long videos. More importantly, each generation of compression introduces some degree of quality degradation, known as generational loss. By avoiding this step entirely, you maintain the highest possible quality for your clip.
Command Structure and Parameters
To perform a minimal cut, you need to understand the specific flags used to define the start and end points. The standard syntax involves specifying the input file, the desired start time, the duration or end time, and the output file name.
- -ss: This flag sets the start position of the cut. It must appear before the
-iinput flag for fast seeking. Placing it after-icauses FFmpeg to decode all frames from the beginning up to that point, negating the speed benefit. - -i: Specifies the path to the source video file.
- -to: Defines the absolute end timestamp. Alternatively, you can use
-tto specify the duration of the clip relative to the start time. - -c copy: Ensures that both audio and video streams are copied without modification.
For example, to extract a 10-second clip starting at 1 minute and 30 seconds, you would use:
ffmpeg -ss 00:01:30 -i input.mp4 -to 00:01:40 -c copy output.mp4
This command tells FFmpeg to jump to 1:30, read until 1:40, and save the result. Note that if you prefer to specify duration rather than an end time, replace -to with -t 00:00:10.
Accuracy and Keyframe Limitations
While streamcopy is fast, it has a significant limitation regarding precision. Video codecs typically store frames in groups called GOPs (Group of Pictures). Most frames depend on previous keyframes for decoding. If you cut at an arbitrary second that does not align with a keyframe, FFmpeg cannot accurately reconstruct the video from that exact point.
Consequently, the cut may start slightly earlier than requested, jumping back to the nearest preceding keyframe. This results in a few extra seconds of footage being included in your output. For most casual uses, this slight inaccuracy is acceptable. However, if precise frame-level accuracy is required, you must accept the slower performance of reencoding.
If you need to understand the difference between seeking methods and their impact on accuracy, review our guide on FFmpeg's ss, -t, -to, Streamcopy, and Keyframe Differences. This resource explains why placing -ss before or after -i changes the behavior drastically.
Handling Audio and Container Formats
When using -c copy, FFmpeg attempts to preserve the original codecs for both video and audio. This works seamlessly with common formats like MP4, MKV, and MOV. However, some container formats do not support certain codecs natively. If you encounter errors about unsupported muxers, you may need to change the output extension to a compatible format.
Additionally, some older or proprietary codecs might not be stream-copyable due to licensing or technical restrictions. In such cases, FFmpeg will throw an error. A simple diagnostic step is to run the command with verbose logging (-v trace) to see exactly which stream fails. Usually, switching to a more universal container like MKV resolves these compatibility issues without needing to reencode.
Common Pitfalls
One frequent mistake is placing the -ss flag after the -i flag. As mentioned, this forces FFmpeg to decode the entire video up to the cut point, making the operation slow and defeating the purpose of streamcopy. Always place -ss before -i.
Another issue arises when cutting across multiple files. If you need to join several clips, simply concatenating them via streamcopy requires that they share the same codec and resolution. If they differ, you will need to reencode one or all of them to ensure smooth playback. For detailed instructions on joining files, see How to Concatenate Videos with FFmpeg.
Frequently Asked Questions
Why is my cut inaccurate by several seconds?
This happens because the cut point does not align with a video keyframe. FFmpeg must start decoding from the nearest preceding keyframe, causing the output to include extra footage before your specified start time. To fix this, you can either accept the inaccuracy or reencode the video for precise cuts.
Can I use this method for any video format?
Most common formats like MP4, AVI, and MKV work well. However, some specialized or encrypted formats may not support streamcopy. If you receive an error, try changing the output file extension to .mkv, which supports a wider variety of codecs and containers.
Does streamcopy reduce file size?
No, streamcopy preserves the original bitrate and data structure. The resulting file will be roughly the same size per second as the source. If you need to reduce file size, you must reencode using a different codec or lower bitrate settings.
Is it safe to use on DRM-protected videos?
No, attempting to streamcopy DRM-protected content will likely fail or produce corrupted files. Digital Rights Management systems encrypt the media streams, preventing direct copying. You must decrypt the content first, which may violate terms of service depending on your jurisdiction.
How do I verify the cut worked correctly?
Play the output file in a media player and check the timestamps. If the video starts abruptly or shows black frames at the beginning, it indicates a keyframe alignment issue. You can also use ffprobe on the output file to inspect the exact start and end times of the streams.