VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

Trim a video with stream copy or re-encoding

When trimming without re-encoding, the clip depends on the file structure. Check the cut points against the content and select the export format appropriate to the task.

A film strip displays six landscape scenes, including one orange one. Markers divide the pale pre- and post-roll sections.
When trimming video content over time, the required boundaries are checked based on the content. The illustration is for reference only.Image: Vioneto · AI-generated illustration

First, define precisely which frame and which clip should start and end in the final cut. Then decide on the export settings. Streamcopy transfers compressed data without re-encoding the video. For arbitrary, precisely desired cut points, re-encoding is often the more appropriate approach. In both cases, a bitrate reduction is required afterward.

A short clip is a new version

Assume you want to show only the locking of a component in a demonstration. If the clip starts too late, the initial position is missing; if it ends too early, the locking action is not visible. Therefore, note the desired start and end points based on the content. Keep the original file and export the clip segment under a new name. Existing subtitles or chapter markers must be adjusted to match the new version.

Why Streamcopy might have different limitations

FFmpeg documents what happens when -ss is used before the input. In many formats, the seek first goes to an earlier seek point. When transcoding with accurate_seek enabled, as it is by default, FFmpeg decodes and discards the interval between that point and the requested position. Stream copy preserves the interval instead.

FFmpeg: Stream Copy, Seek Start, and Output Duration

An example with re-encoding

For a suitable SDR MP4 test file, an example command with FFmpeg installed is: ffmpeg -ss 5.2 -i "input.mp4" -t 2.4 -map 0:v:0 -map 0:a:0 -c:v libx264 -crf 18 -preset medium -c:a aac -movflags +faststart "output.mp4"

The example selects the first video stream and, if available, the first audio track. It starts at 5.2 seconds and uses a target duration of 2.4 seconds. The video and existing audio are re-encoded; additional audio tracks, subtitles, and other auxiliary streams are not fully preserved. These settings are provided as a working example only and are not universal recommendations for HDR, any source, or any playback pathway. Use a new output path and check the available encoders on your installation.

What our own experiment actually shows

We executed the command using FFmpeg 8.0.1 on a custom synthetic H.264 file with 25 frames per second and no audio. FFprobe reports 60 video frames and a duration of 2.4 seconds for the newly encoded output. A second output of the same time range using streamcopy also shows 2.4 seconds, but contains 90 stored video frames. This is a concrete result specific to this test file, not a guarantee regarding display across all players.

For a technical assessment, for example: ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,duration,nb_frames -of json "ausschnitt.mp4". Some formats do not provide all of these fields. Even a reasonable frame count does not guarantee that the correct moment has been selected.

FFprobe: Examine streams and selected fields

Check the final version against the cut edges.

  • Play the beginning slowly or frame by frame: Is the required initial condition present without an external pre-run?
  • Check the ending: Is the action complete, and is no dialogue cut off?
  • Listen for existing audio sync problems and abrupt transitions. Our silent test does not verify these characteristics.
  • Check the exported clip in the actual target player. When dealing with variable frame rates, use the real time stamps rather than converting seconds into frame numbers using a general formula.

The newly exported file from the cut project differs

Check constant and variable frame rates

Topics

Sources and further reading

  1. https://ffmpeg.org/ffmpeg.html
  2. https://ffmpeg.org/ffprobe.html