Quick Start Guide to FFmpeg
An easy FFmpeg tutorial, hack collection and ready‑reference
- Need to process audio/video files without spending much on software?
- Need a quick tutorial or desk-side reference for FFmpeg?
FFmpeg is THE BEST software to easily create, edit, enhance and convert audio and video files. It is a free and open-source command-utility available for Linux, Mac and Windows.
Quick Start Guide to FFmpeg is THE BEST book for an extensive FFmpeg tutorial, hack collection and quick reference. It is richly illustrated with color screenshots, code examples and tables to help you work with audio, video, images, animations, fonts, subtitles and metadata like a PRO.
This book begins with a simple introduction to FFmpeg executables — ffmpeg, ffprobe and ffplay, and explains how you can use them to process multimedia containers, streams, audio channels, maps and metadata. It then describes how you can easily edit, enhance and convert audio, video, image and text files. There are dedicated chapters for filters, audio, subtitles and metadata, as well as a big collection of FFmpeg tips and tricks. Sample lists of FFmpeg filters, encoders, decoders, formats and codecs are also available as appendices. The book is richly illustrated with screenshots and syntax-highlighted code snippets, all in 𝓕𝓤𝓛𝓛 𝓒🍅𝓛🍅𝓤𝓡. It is based on the latest Long Term Support (LTS) version of FFmpeg.
Quick Start Guide to FFmpeg is for anyone who needs to edit or process multimedia files including studio professionals, broadcast personnel, video content creators (such as Youtubers), podcasters, librarians, archivists and webmasters. It will be indispensable for those wanting to process a variety of multimedia files from the command line and inside shell scripts.
You will learn to:
- Convert from one format to another video-to-video, video-to-audio, video-to-image, image-to-video, video-to-animation, animation-to-video, text-to-audio, text-to-video
- Edit video files by cutting them with and without re-encoding, appending (joining clips together), resizing, changing frame rate and aspect ratio, mixing in audio
- Use filters to rotate, flip, crop, overlay (side-by-side or inset), remove logos, blur, smooth and sharpen, apply transitions as well as speed up or down playback
- Edit audio files by changing, normalizing or compressing volume, mixing and splitting channels and detecting silence. Also, learn to generate waveforms as video or image
- Add subtitles, place them anywhere on the screen, use custom fonts and colors, and use different languages
- Set metadata such as MP3 tags for and album art, set global and stream-specific metadata. And, learn how to import, export and remove metadata
- Automate your FFmpeg tasks
Buy
Format | Store | Order |
---|---|---|
Colour paperback | Amazon (USA) | $44.99 |
Colour paperback | Barnes & Noble (USA) | $44.99 |
Colour paperback | Springer (Free worldwide shipping) | $44.99 |
PDF ebook | Springer (worldwide) | $29.99 |
Colour paperback | Bookswagon (India) | ₹2500 |
Sample pages
This sample is a low-resolution watermarked PDF with pages from both books. Also included are updated annexures and my book backlist (with no watermarks of course ;-). The annexures contain ffmpeg
output for the options -codecs
, -formats
, -filters
, -encoders
and -decoders
from Windows and Linux OSs.
The book published by Apress will not look like this PDF. (Read the release announcement.) Unlike other authors (who use Microsoft Word), I write my books in CommonMark (MarkDown) and output them as PDF using a bash
script — starting with the very first line. As I also design my own covers, I had created replica Apress covers for this PDF.
These are real pages from the paperback published by Apress/SpringerNature in 2023. (The animation is low-resolution to conserve file size.)
List of Contents
- Introduction
- Extra resources for the book
- Chapter 1: Installing FFmpeg
- Chapter 2: Starting with FFmpeg
- Chapter 3: Formats and codecs
- Chapter 4: Media containers and FFmpeg numbering
- Chapter 5: Format conversion
- Chapter 6: Editing videos
- Chapter 7: Using FFmpeg filters
- Chapter 8: All about audio
- Chapter 9: All about subtitles
- Chapter 10: All about metadata
- Chapter 11: FFmpeg tips and tricks
- Chapter 12: Annexures
- Annexure 1: Sample list of codecs
- Annexure 2: Sample list of decoders
- Annexure 3: Sample list of encoders
- Annexure 4: Sample list of filters
- Annexure 5: Sample list of formats
Extra Resources — Source code
The list of commands used in the book is available in this text file:
Extra Resources — Video demos
Stop wasting hours on expensive timeline-based video editors such as Premiere Pro or Final Cut Pro! Most video-editing tasks REQUIRE LESS THAN 5 MINUTES USING FFMPEG. (Rendering time not included.) FFmpeg can create almost all kinds of complex videos with fonts, animations, subtitles, overlays, transitions, etc. From the command line! Using just one command! FFmpeg! No problem!
-
All-in-one video demo at the end of the book
-
How to fade in fade out audio and video
-
Convert a video into an animated image
This is my software implementation for Chandler Bing's ‘Run, Yasmine! Run!’ challenge.ffmpeg -y -i baywatch.m4v \ -filter_complex "fps=7,scale=w=320:h=-1:flags=lanczos,split[v1][v2]; [v1]palettegen=stats_mode=diff[p]; [v2][p]paletteuse=dither=bayer:bayer_scale=4" \ run-yasmine-run-4.gif
This command creates a GIF animation with good frame quality and file size, but the motion is not smooth.
If you change the filter to
paletteuse=dither=bayer:bayer_scale=0
, you get smoother motion but bigger file size and a dotted texture.Instead of creating an animated GIF, which is limited to 256 colours, try creating an animated PNG. A PNG file supports millions of colours. ImageMagick is the tool you should use, not FFmpeg.
magick animated.gif animated.apng
If you convert from PNG source files (instead of the already downsampled image frames in the animated GIF), you will be able to create an animated PNG with richer colours.
For my first fiction title Unlikely Stories, I initially used an animated GIF. When I learned about APNG file, I was able to eliminate the effects of downsampling.
magick -delay 200 -loop 0 \ chapter-image-*.png \ -units PixelsPerInch -density 72 -resize '>x400' \ animation-unlikely-stories.apng
Animated GIF Animated PNG When converting from a video to an animated PNG, you can use FFmpeg.
ffmpeg -i bw.m4v \ -vf "scale=w=250:h=-2, hqdn3d, fps=6" \ -dpi 72 -plays 0 \ bw.apng
-
Generate noise in audio and video
-
Bleep part of a video
-
Add audio waveforms to video
-
Reverse audio and video
-
MP3-to-MP4 or audio-to-video conversion using audio power spectrum filter
-
How to add echo to a video
-
Blurring a portion of a video
-
Write text on video
-
Render transparent GIF on video with infinite looping
-
Replace green-screen background on another video
-
Fade into another video using a transition effect
-
Slow down a video
Ms. Lennon's original video is available on her channel.
After slowing down a Tom & Jerry video, I was able to confirm poltergeist activity in a doll.
-
Subtitle a video
In the subtitle file (SSA), I used the following style for using my own custom font and other subtitle display settings.
Style: Default,Florentia,30,&H2200CCCC,&H000000FF,&H220000EE,&HAA00CCCC,-1,-1,0,0,100,100,0,30.00,3,2,3,1,20,20,40,1
-
A stop-motion video created using Cheese and FFmpeg
- Increase volume using FFMPEG and or Audacity for Dynamic Range Compression
Acknowledgements & Thanks
- "Rowdy" Roddy Piper/John Carpenter (They Live)
- Alaska Granny
- Amazing Lucas
- Barbara 2.0
- 'Beto' O'Rourke (Born to be president… ial campaign)
- Chills
- Jack Benny (The Jack Benny Program)
- Jean-Claude Van Damme (public-domain videos)
- ‘Jerome Weiselberry’
- Jimmy Fallon (Tonight Show)
- Joking.com
- Laurie Lennon
- Naomi 'Sexy Cyborg' Wu
- Sara Gonzales Unfiltered
- Yasmine Bleeth (Baywatch)
Use an RSS feed-reader such as Liferea, Thunderbird/Seamonkey or RSS Owl if you would like to anonymously subscribe to these channels. If you have no choice but to use Android, then use my app Subhash Browser & RSS Reader. It is also FREE.
Some other videos that I have created using FFmpeg
- Climate Change teen's message - improved, expletives deleted, bleeped & subtitled
In 2018, a Linux update ensured that all swear words in the kernel code submits will be automatically replaced. For example, 'f***' would be replaced with the word 'hug'. I did the same to a speech by a Swedish climate teen.
- Alexandria Ocasio-Cortez, meet Garbage Disposal
-
FAA under AOC Socialist administration
ffmpeg -y -i Prime-Time.mp4 \ -ss 0:43:51 -t 0:0:33 \ -filter_complex "color=c=green:s=640x360[c]; [c]drawtext=x=20:y=20:fontcolor=yellow:alpha=0.6:shadowx=1:shadowy=1:textfile=t1.txt:fontsize=22:fontfile=Dummies_.ttf[t1]; [t1]drawtext=x=270:y=320:fontcolor=yellow:alpha=0.6:shadowx=1:shadowy=1:textfile=t2.txt:fontsize=22:fontfile=Dummies_.ttf[t2]; [t2]drawtext=x=10:y=330:fontcolor=white:alpha=0.6:textfile=t3.txt:fontsize=16:fontfile=SourceSerifPro-It.ttf[t3]; [0:v:0]crop=640:250:0:35[v]; [t3][v]overlay=0:55" \ aoc-faa.mp4
- Rachel Maddow crying offscreen footage
- "So many people don't share Google's values!"
- Can the New York Times legally copy Naomi Wu's video without permission?
- Joe Biden is US comedy relief
- Jennifer Lawrence and Steve Buscemi deep-fake videos composited with images, text, background colour boxes
Check my blog post for theffmpeg
command that created this video.
Companion book
FFmpeg is a command-line program. If you are going to use it a lot, then you might as well become an expert at the command-line. Here is is one of my other books that will make your terminal time more fun and easy. The ebook is FREE and the paperback is syntax-highlighted in FULL-COLOUR.