FFmpeg — The Universal Multimedia Processing Toolkit
FFmpeg is the most powerful and widely used multimedia processing framework. It can decode, encode, transcode, mux, demux, stream, filter, and play almost every audio and video format ever created. Nearly every media application on earth uses FFmpeg.
Ready-to-run agent install
This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.
npx -y tokrepo@latest install 353248b1-3701-11f1-9bc6-00163e2b0d79 --target codexRun after dry-run confirms the install plan.
What it is
FFmpeg is the most widely used multimedia processing framework. It can decode, encode, transcode, mux, demux, stream, filter, and play almost every audio and video format ever created. Nearly every video application -- from VLC to YouTube's backend -- relies on FFmpeg's libraries or command-line tools under the hood.
The target audience spans video engineers, content creators automating batch processing, DevOps teams building media pipelines, and AI developers preparing training data from video sources.
How it saves time or tokens
FFmpeg replaces entire categories of commercial software with a single command-line binary. A video format conversion that requires a GUI tool and manual clicks becomes a one-liner. Batch processing hundreds of files uses a shell loop around a single FFmpeg command.
For AI workflows, FFmpeg is essential for extracting frames from video datasets, converting audio formats for speech models, and preparing media assets for training pipelines. Its filter graph system handles complex transformations (resize, crop, overlay, color correction) without writing code.
How to use
- Install FFmpeg:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt install ffmpeg
# Verify installation
ffmpeg -version
- Convert a video format:
ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac output.mp4
- Extract audio from video:
ffmpeg -i video.mp4 -vn -acodec libmp3lame -q:a 2 audio.mp3
Example
Extract one frame per second from a video for AI training data:
# Extract frames at 1fps, save as numbered PNGs
ffmpeg -i input.mp4 -vf fps=1 frames/frame_%04d.png
# Resize and extract frames in one pass
ffmpeg -i input.mp4 -vf 'fps=1,scale=224:224' frames/frame_%04d.png
# Trim to first 60 seconds, then extract
ffmpeg -i input.mp4 -t 60 -vf fps=1 frames/frame_%04d.png
Related on TokRepo
- AI tools for video -- Video generation and processing tools
- Automation tools -- CLI tools for batch media workflows
Common pitfalls
- The
-crfvalue controls quality vs. file size for x264/x265. Lower means higher quality. The default 23 is a reasonable starting point; going below 18 rarely produces visible improvement but doubles file size. - Forgetting
-c copywhen you only want to trim or remux wastes time re-encoding the entire stream. - Filter graph syntax uses commas for chaining filters and semicolons for separate filter chains. Mixing them up produces cryptic errors.
- Hardware acceleration (NVENC, VideoToolbox, VAAPI) requires building FFmpeg with the right flags. The default Homebrew/apt packages may not include all accelerators.
- Piping FFmpeg output to another process requires
-fto specify the output format explicitly, since FFmpeg cannot infer format from a pipe.
Frequently Asked Questions
FFmpeg supports virtually every video and audio format, including MP4, MKV, AVI, MOV, WebM, FLV, MP3, AAC, FLAC, WAV, and hundreds more. The full list depends on the codecs compiled into your FFmpeg build. Run 'ffmpeg -formats' to see all supported formats on your system.
Use the CRF (Constant Rate Factor) parameter with libx264 or libx265. For example: 'ffmpeg -i input.mp4 -c:v libx264 -crf 28 output.mp4'. Higher CRF values produce smaller files at lower quality. CRF 23 is the default; 28 gives roughly half the file size with moderate quality loss.
Yes. FFmpeg can stream to RTMP, HLS, DASH, and other protocols. For example, streaming to an RTMP server: 'ffmpeg -i input.mp4 -c copy -f flv rtmp://server/live/stream'. It also supports capturing from webcams and screen recording for live streaming setups.
Use hardware encoder names instead of software ones. For NVIDIA: '-c:v h264_nvenc'. For macOS: '-c:v h264_videotoolbox'. For AMD/Intel on Linux: '-c:v h264_vaapi'. Your FFmpeg build must include the relevant hardware acceleration library. Check with 'ffmpeg -encoders | grep nvenc'.
FFmpeg processes one input at a time, but you wrap it in a shell loop. For example: 'for f in *.mov; do ffmpeg -i "$f" -c:v libx264 "${f%.mov}.mp4"; done'. This converts every MOV file in the current directory to MP4. Combine with GNU parallel for multi-core batch processing.
Citations (3)
- FFmpeg Official Site— FFmpeg can decode, encode, transcode, mux, and stream nearly every format
- FFmpeg GitHub— FFmpeg is the leading multimedia framework used by VLC, YouTube, and others
- FFmpeg Wiki— libx264 CRF encoding documentation
Related on TokRepo
Discussion
Related Assets
SDL — Simple DirectMedia Layer for Cross-Platform Multimedia
SDL (Simple DirectMedia Layer) is a cross-platform C library for accessing graphics hardware, audio, input devices, and networking. It provides the low-level foundation used by thousands of games, emulators, and multimedia applications on Windows, macOS, Linux, iOS, and Android.
Pandoc — Universal Document Format Converter
Pandoc is a universal document converter that reads and writes dozens of markup formats. It converts between Markdown, LaTeX, HTML, DOCX, EPUB, PDF, and many more with a single command.
VLC — Free Cross-Platform Multimedia Player That Plays Everything
VLC media player is a free, open-source multimedia player developed by VideoLAN. Known for playing virtually any audio or video format without requiring additional codecs, VLC runs on all major platforms including Linux, Windows, macOS, Android, and iOS.
Expo — Universal Native Apps for iOS, Android & Web
Expo is an open-source framework and platform for making universal React Native apps. Ship to iOS, Android, and web from one codebase — OTA updates, managed workflow, EAS Build cloud service, and 100+ prebuilt native modules.