Published on

Everyday FFmpeg: Tiny Scripts That Save Hours

Authors
nginx

If you’ve ever dealt with video or audio files, chances are you’ve bumped into FFmpeg. It's a powerful command-line tool that can handle almost anything media-related. But what makes it even better is how it can save you hours of repetitive work — with just a few lines of code.

In this post, I’ll show you some real-life use cases and scripts I use regularly that automate boring media tasks.

Installing FFmpeg

Before using these commands, make sure FFmpeg is installed on your system.

Windows: Download the latest build from https://ffmpeg.org/, extract it, and add the bin folder to your system's PATH.

Linux (Debian/Ubuntu): Just run:

sudo apt install ffmpeg

macOS: Use Homebrew with:

brew install ffmpeg

That’s it — once installed, you can run FFmpeg from any terminal or command prompt.

1. Trim a Video Without Re-Encoding

Need to cut the start or end of a video? FFmpeg makes it super quick:

ffmpeg -ss 00:01:30 -to 00:05:00 -i input.mp4 -c copy trimmed.mp4

This trims the video from 1:30 to 5:00 without re-encoding, so it’s fast and keeps the original quality.


2. Convert a Video to a Smaller Size for WhatsApp or Email

Large video files can be a pain to share. Compress them with:

ffmpeg -i input.mp4 -vcodec libx264 -crf 28 smaller.mp4

The lower the CRF value, the higher the quality. I usually go with 28 for quick sharing.


3. Extract Audio from a Video (MP3)

Want just the audio from a video lecture or podcast?

ffmpeg -i input.mp4 -q:a 0 -map a output.mp3

This gives you high-quality MP3 audio from any video file.


4. Create a GIF from a Video Clip

Perfect for tutorials or quick previews:

ffmpeg -ss 00:00:02 -t 3 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" output.gif

This grabs a 3-second clip starting at 2 seconds and converts it to a GIF.


5. Batch Convert All MOV Files to MP4

If you have a folder full of videos, this loop can convert them all:

for file in *.mov; do ffmpeg -i "$file" "${file%.mov}.mp4"; done

Very handy when you’re migrating formats or cleaning up old files.


Bonus: Normalize Audio Levels

Sometimes video or podcast audio is too quiet or too loud. Use loudnorm:

ffmpeg -i input.mp4 -af loudnorm output.mp4

It automatically adjusts audio levels to be more consistent.


These are just a few of the quick scripts I’ve saved in my notes over time. FFmpeg can do a lot more — but even knowing these basics can save you loads of time and help you work more efficiently.