Trim Videos Instantly
Bernd Verst
Posted on April 4, 2020
Is your video too long for upload to Twitter or Instagram? Or do you want to export just a specific clip? Using video editors to trim videos requires reencoding the entire video which takes a long time. Instead I will show you how to instantly trim your videos and even maintain embedded subtitle tracks.
Background
A few days ago I created a post on easily adding subtitles to your videos. Today I wanted to verify that Twitter correctly shows these subtitles, but I discovered that my video was too long. Having played with FFmpeg I suspected that there may be a more efficient way for trimming videos than using a video editor. Be prepared to have your mind blown! 🤯
Requirements
FFmpeg
You will need the open-source FFmpeg tool.
FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.
Please follow the installation instructions here.
On Mac, simply use Homebrew with brew install ffmpeg
Instantly trim videos
The following command reads the source video and copies all streams contained within (video, audio, subtitles) to the output. The various time parameters ensure only a specific part of the original video is written to the output. The video and audio streams are not reencoded. The time required for reencoding would directly depend on the duration of the video, however we are simply copying parts of the video. For this reason the following operation is near instant. A huge time saving over workflows involving video editors.
Posted on April 4, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.