Development

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…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago