Extract video clip using ffmpeg


I recently needed to extract a 30 second video clip, and remove the audio, from a 2 hour mkv video.

If you are on macOS,  you need to get a copy of ffmpeg, the steps are:

    1. Download the statically linked pre-compiled binary as a dmg from this page:
      https://evermeet.cx/ffmpeg/
    2. If the disk image does not automatically mount, double click the downloaded .dmg file to mount the disk image
    3. Open Applications > Utilities > Terminal and enter this command to install the ffmpeg binary into the correct location (if your version of ffmpeg is different you may need to change 4.0.1 to something else):
      sudo cp /Volumes/FFmpeg\ 4.0.1/ffmpeg /usr/local/bin

Now that you have ffmpeg installed, the Terminal command to extract the video using ffmpeg looks like this:

ffmpeg -ss HH:MM:SS.FFF -i movie.mkv -t 00:30 -qscale 0 -an out.mp4

Where HH:MMSS:FFF was the starting time code (in my case it was 2 hours, 8 minutes and 3 seconds or 02:08:03.000 into the video).

The other setting explained:

-i movie.mkv was the input video

-t 00:30 was the duration that I wanted to extract

-qscale 0 was to preserve the video quality

-an was to remove the audio

Of course it being ffmpeg you can use an input movie in a variety of different formats, it just so happened mine was an mkv

Leave a comment