DEV Community

Brandon Rozek
Brandon Rozek

Posted on • Originally published at brandonrozek.com on

How to trim a video using FFMPEG

Recently I came across a video that I wanted to split up into multiple files. Given my love for ffmpeg the video/audio swiss army knife, I knew there had to be a solution for cutting a video on the terminal. Luckily on AskUbuntu, Luis Alvarado provides a command snippet. This post will go into slightly more detail on the flags used in the command

ffmpeg -ss 00:00:00 \
    -t 00:30:00 \
    -i input.mp4 \
    -vcodec copy \
    -acodec copy \
    output.mp4

Enter fullscreen mode Exit fullscreen mode
Command Description
-ss Position within the input file. Most file formats do not allow exact seeking, so ffmpeg will pick the closest seek point. Format is in time duration notation.
-t Limits the duration of data read from the input file. Format is in time duration notation.
-vcodec Format used to transcribe the video. Use copy to not transcribe to a different format.
-acodec Format used to transcribe the audio. Use copy to not transcribe to a different format.

Time duration notation follows the format <HH>:<MM>:<SS> where HH is the number of hours, MM is the number of minutes, and SS is the number of seconds.

For this command in general, the output video length would be the same time duration as specified in the -t flag.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay