ffmpeg


ffmpeg Commonly Used Commands

Trimming Files Without Re-encoding

The following steps is how I trim recorded Zwift rides and/or races. I aim to eliminate the setup at the beginning and the teardown at the end without having to re-encode the video as that’s an expensive process. Using the nearest key frame allows skipping the re-encode and I do it in two separate steps to avoid math caused by the initial seek changing the end time of the video.

Trim Beginning to Nearest Key Frame

Look at the output video to ensure it starts approximately where you want.

ffmpeg -ss hh:mm:ss -i input.mkv -c:v copy -c:a copy beginning.mkv

Trim End to Nearest Key Frame

ffmpeg -i beginning.mkv -t hh:mm:ss -c:v copy -c:a copy trimmed.mkv

Convert from 60 FPS to 30 FPS

ffmpeg -i input.mkv -c:v h264_qsv -filter:v fps=fps=30 -c:a copy output.mkv

This utilizes the h264_qsv Intel Quick Sync Video acceleration hardware. I haven’t figured out a way to get rid of the following extra video metadata components:

Standard        : Component
Writing library : Lavc61.19.101 h264_qsv

Worthless extra metadata as far as I can tell.