Categories: DevelopmentTechnology

Cutting a part from a video with FFmpeg

FFmpeg allows you to choose a start time for a video and a finish time or duration and it will chop that part out and save it. There are two ways to do this, the first will cut the video and do no re-encoding, meaning it will be quick but the video most likely will be large and uncompressed. The second method will do a cut and re-encode, taking longer but compressing the file.

Cut with no re-encoding, quickest!

ffmpeg -ss 01:20:44 -i input.mp4 -t 00:02:00  -c copy output.mp4

The above command will make a 2 minute file called output.mp4 running from 1 hour, 20 minutes and 44 seconds through to 1 hour, 22 minutes and 44 seconds from input.mp4.

Cut with re-encoding, smaller file but longer time

ffmpeg -ss 01:22:44 -i input.mp4 -c:v libx264 -preset slow -crf 23 -t 00:02:00 output.mp4

The above command does the same as the first one except it will compress the file, it takes longer but the end file will be smaller.

To read up on FFmpeg and encoding settings read here.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago