How to Use FFmpeg: A Beginner's Guide for Developers in 2025

In this beginner-friendly guide, you'll learn how to use FFmpeg with practical examples for trimming, converting, resizing, and automating video tasks.
by Josephine Loo ·

Contents

    FFmpeg is a multimedia framework you definitely need to know if you’re working with anything to do with media files programmatically. It might not have a fancy website or a modern-looking interface, but it’s an amazing multimedia framework that quietly powers a lot of video and audio processing apps out there.

    If you’re building something that needs to handle video or audio, like trimming clips, converting formats, extracting audio, and more, whether it’s for a video editing app or an automation workflow, you should try FFmpeg.

    If you're a beginner, you're in the right place. This beginner-friendly guide covers all FFmpeg essentials, including what FFmpeg actually is, how the commands are structured, and the key operations you’ll need to process media files.

    Let’s get into it.

    What is FFmpeg

    FFmpeg is a powerful cross-platform command-line tool for handling video and audio files programmatically. It can decode, encode, transcode, mux, demux, stream, filter, and play media in nearly any format, and it works on all major platforms, including Linux, macOS, and Windows.

    FFmpeg comes with a set of tools and libraries that let you convert, play, and analyze media files. This allows you to:

    • Convert .mp4 videos to .mp3 audio files
    • Reduce video size
    • Automate podcast production
    • Extract audio for transcription
    • Build media-processing apps

    …and more.

    How to Install FFmpeg

    If you haven’t installed FFmpeg yet, you’ll need to get it running on your local machine first. Download FFmpeg from the official website and follow this step-by-step guide to install it on your Mac, Windows, or Ubuntu/Linux.

    Once it’s installed, open your terminal/command prompt and run the command below to verify the installation:

    ffmpeg -version
    

    If the installation is successful, you should be able to see the version number and other info:

    The Basics: What FFmpeg Commands Look Like

    If you're new to FFmpeg, the first thing to wrap your head around is how its commands are structured. FFmpeg is a command-line tool, so everything you do with it happens through written commands.

    FFmpeg commands follow a simple general pattern. Here’s how the basic structure looks:

    ffmpeg -i [input file] [operation flags] [output file]
    

    Here’s what each part means:

    • ffmpeg - This calls FFmpeg from your terminal.
    • i [input file] - This tells FFmpeg what’s the input file.
    • [operation flags] - This is where you apply different filters and settings (e.g., trimming, resizing, converting formats, changing codecs, etc.)
    • [output file] - This is the name and format of the final result.

    Depending on whether you want to resize, convert, trim, crop, extract audio, or perform other operations on the input file, constructing the FFmpeg command follows the same structure, but with combinations of different option flags. In the next sections, we'll see more practical examples using this structure.

    How to Use FFmpeg: Practical Examples

    1. Converting Formats (MKV to MP4, MP4 to GIF, etc.)

    One of the most common things people use FFmpeg for is converting media formats. For example, here’s a simple command to convert a MKV video to MP4:

    ffmpeg -i input.mkv output.mp4
    

    Here’s what the command does: -i input.mkv tells FFmpeg which file to convert, and output.mp4 is the name of the output file. FFmpeg will automatically convert it to the format based on the file extension you give, which in this case, is .mp4.

    This conversion command is useful if you're building something like:

    • A file uploader that needs to standardize formats
    • A backend job that prepares videos for display in browsers
    • A batch converter to process hundreds of videos at once

    This basic command converts the format using FFmpeg’s default settings. If you want more control, like changing the resolution, codec, or bitrate, you can add those settings in the [operation flags] section of the command.

    🐱 Meow Memo: This article (A Beginner’s Guide to FFmpeg-Python:How to Convert Video Formats) covers how to adjust the resolution, codec, bitrate, and CRF during the conversion process.

    2. Extracting Audio from a Video

    Extracting audio from a video is technically the same as doing a format conversion. The only difference is, instead of using a video extension for the output file, you use an audio extension like .mp3 or .wav. FFmpeg will save the file as audio only.

    For example, running the command below gives you an MP3 file with just the audio from the input video:

    ffmpeg -i input.mp4 output.mp3
    

    Just like the previous example, this basic command above runs using FFmpeg’s default settings. You can also add different settings in the [operation flags] section of the command to set the audio bitrate to adjust the quality, or extract the audio without re-encoding to speed up the process.

    3. Trimming a Video

    For trimming a video, you will need more detail in the command compared to converting formats or extracting audio. You’ll need to include a few extra options to tell FFmpeg exactly which part of the video you want to keep.

    Here’s the basic command structure for trimming a video using input seeking:

    ffmpeg -ss [start-time] -t [duration] -i input.mp4 output.mp4
    

    And here’s another one using output seeking:

    ffmpeg -i input.mp4 -ss [start-time] -t [duration] output.mp4
    

    For example, if you want to trim a 3-second clip from the 00:00:40 mark of a video, the command would look like this using input seeking:

    ffmpeg -ss 00:00:40 -t 3 -i input.mp4 output.mp4
    

    Placing the seeking (-ss) option before -i <input_video> performs the seeking before decoding the input, while placing it after -i <input_video> performs the seeking after decoding the input. Generally, output seeking is more accurate trimming (no keyframe dependency) but may be slower compared to input seeking.

    Here are some guides if you want to dive deeper:

    👉 How to Trim a Video Using FFmpeg

    👉 A Beginner’s Guide to FFmpeg-Python: How to Trim Videos

    4. Resizing a Video

    Resizing, or scaling, changes the dimensions of a video to match a specific resolution or aspect ratio. This involves either stretching or compressing the video to fit a particular screen size or to make it compatible with platforms such as YouTube, TikTok, or Instagram that have different video size preferences.

    And to resize a video, we’ll use the scale filter by adding -vf "scale=[resolution]" to the command. Here’s how you resize a video to 1280×720:

    ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4
    

    If you want to maintain the aspect ratio when resizing your video,  specify one of the dimensions and use -1 for the other. For example, the command below sets the width to 640px, and FFmpeg automatically calculates the height:

    ffmpeg -i input.mp4 -vf "scale=640:-1" output.mp4
    

    5. Cropping a Video

    You can also crop a video using FFmpeg. If you want to remove black bars, watermarks, or logos, or just want to show a specific area of a video, you can use the crop filter to crop out the area that you want.

    Like resizing a video, we’ll apply the crop filter using the -vf flag. Here’s how to crop a 1280×720 area from the center of a video:

    ffmpeg -i input.mp4 -vf "crop=1280:720" output.mp4
    

    By default, FFmpeg crops from the center. If you want to crop from a specific spot, you can set the x and y coordinates after the crop size like this:

    ffmpeg -i input.mp4 -vf "crop=1280:720:100:50" output.mp4
    

    This crops the video to 1280x720, starting from 100 pixels from the left and 50 pixels from the top.

    More detailed guides here:

    👉 How to Crop and Resize Videos Using FFmpeg

    👉 A Beginner’s Guide to FFmpeg-Python: How to Crop and Resize Videos

    When Not to Use FFmpeg

    For editing videos programmatically, FFmpeg is a reliable tool. It’s fast, versatile, and works well for automating editing tasks with a script. You can run it in shell scripts, Python scripts, CI/CD pipelines, or even serverless functions.

    But once your video editing gets more complex, FFmpeg can become difficult to manage. Commands can get long and messy with tons of flags, filters, and codec settings. This makes it prone to mistakes and difficult to maintain, especially across different environments. And since everything is done through the command line (or code, if you’re using the ffmpeg-python library), it’s not the most collaboration-friendly tool if you're working with designers or content teams who prefer a visual interface.

    If the task involves a lot of repeatable, dynamic editing, like generating videos from user content or turning reviews into branded clips, and you need something that’s easier to scale and collaborate on, you might want a more user-friendly solution.

    Using Clipcat API For Auto-Video Generation

    Clipcat is a video generation tool that lets you create videos programmatically using templates. You only need to design the video template once, then use its API to dynamically update elements like text (e.g., titles, captions, quotes), images (e.g, profile pictures, logos, product photos), and videos (e.g., user-uploaded clips or animated backgrounds).

    Here are some examples of the video templates:

    Customer Review Template

    Real Estate Listing Template

    Breaking News Template

    It’s like a layer on top of FFmpeg. You get:

    • A visual UI to create video templates (easy for designers or marketers)
    • An API to generate videos automatically (great for devs)
    • Hosted rendering, so you don’t need to run FFmpeg yourself

    This makes it perfect for use cases like auto-generating promotional videos for new products, creating personalized thank-you or testimonial videos, and generating UGC-style content at scale for social media.

    🐱 Meow Memo: Sign up now and get 100 free API credits to get started!

    Final Thoughts

    FFmpeg is a must-have tool for any developer working with media files programmatically. It’s free, fast, and flexible. Whether you’re building a simple video converter, a video editing tool, a marketing platform, or automating editing tasks with scripts, FFmpeg has everything you need to get the job done.

    But once your workflow grows more complex or you’re dealing with repetitive video tasks at scale, managing everything through raw FFmpeg commands can be difficult. If you reach that point, tools like Clipcat can help by giving you a visual editor, an API for integration and automation, and hosted rendering.

    If you'd like to learn more, here are some helpful articles:

    About the authorJosephine Loo
    Josephine is an automation enthusiast. She loves automating stuff and helping people to increase productivity with automation.
    How to Use FFmpeg: A Beginner's Guide for Developers in 2025
    How to Use FFmpeg: A Beginner's Guide for Developers in 2025