# 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. ## Install Save as a script file and run: # FFmpeg — The Universal Multimedia Processing Toolkit ## Quick Use ```bash # Install FFmpeg # macOS brew install ffmpeg # Linux sudo apt install ffmpeg # Common operations # Convert video format ffmpeg -i input.mov output.mp4 # Extract audio from video ffmpeg -i video.mp4 -vn -acodec mp3 audio.mp3 # Resize video ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4 # Create GIF from video ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1" output.gif ``` ## Introduction FFmpeg is the backbone of digital media. Created by Fabrice Bellard in 2000, it is a complete multimedia framework that handles virtually every audio and video format in existence. VLC, YouTube, Netflix, Chrome, Firefox, OBS, HandBrake, Audacity, and thousands of other applications depend on FFmpeg for media processing. With over 59,000 GitHub stars on its mirror (development happens on git.ffmpeg.org), FFmpeg is the most essential media tool in computing. If you have ever watched a video on the internet, FFmpeg was almost certainly involved somewhere in the pipeline. ## What FFmpeg Does FFmpeg provides three command-line tools: ffmpeg (converter/transcoder), ffprobe (media analyzer), and ffplay (media player). Under the hood, libavcodec provides codec implementations, libavformat handles container formats, and libavfilter provides audio/video filtering. Together, they can process any media workflow. ## Architecture Overview ``` [Input File/Stream/Device] | [libavformat] Demuxer: read container (MP4, MKV, AVI, FLV...) | [libavcodec] Decoder: decompress (H.264, H.265, VP9, AV1...) | [libavfilter] Filter chain: transform (scale, crop, overlay, color, denoise, stabilize) | [libavcodec] Encoder: compress (x264, x265, libvpx, libaom) | [libavformat] Muxer: write container | [Output File/Stream/Device] ``` ## Self-Hosting & Configuration ```bash # Advanced FFmpeg recipes # Concatenate videos echo "file 'part1.mp4'" > list.txt echo "file 'part2.mp4'" >> list.txt ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 # Add subtitles ffmpeg -i video.mp4 -vf subtitles=subs.srt output.mp4 # Stream to RTMP (e.g., YouTube Live) ffmpeg -re -i video.mp4 -c:v libx264 -preset veryfast \ -f flv rtmp://a.rtmp.youtube.com/live2/your-key # Screen recording (macOS) ffmpeg -f avfoundation -i "1:0" -c:v libx264 -preset ultrafast screen.mp4 # Compress video for web (H.265, good quality) ffmpeg -i input.mp4 -c:v libx265 -crf 28 -preset medium \ -c:a aac -b:a 128k -movflags +faststart output.mp4 # Extract frames as images ffmpeg -i video.mp4 -vf "fps=1" frame_%04d.png # Hardware-accelerated encoding (NVIDIA) ffmpeg -i input.mp4 -c:v h264_nvenc -preset p4 output.mp4 ``` ## Key Features - **Universal Format Support** — hundreds of codecs and container formats - **Transcoding** — convert between any supported formats - **Streaming** — RTMP, HLS, DASH, RTP/RTSP live streaming - **Filter System** — extensive audio/video filter graph processing - **Hardware Acceleration** — NVENC, QSV, VAAPI, VideoToolbox, AMF - **Batch Processing** — scriptable for automated media workflows - **Media Analysis** — ffprobe for detailed format and stream information - **Cross-Platform** — runs on Linux, macOS, Windows, and embedded systems ## Comparison with Similar Tools | Feature | FFmpeg | HandBrake | GStreamer | ImageMagick | sox | |---|---|---|---|---|---| | Type | CLI framework | GUI transcoder | Pipeline framework | Image processing | Audio processing | | Media Types | Audio + Video | Video | Audio + Video | Images | Audio | | Flexibility | Maximum | Preset-based | Pipeline | Filter-based | Filter-based | | Scripting | Excellent | Limited | Good | Good | Good | | Learning Curve | High | Low | High | Moderate | Moderate | | Used By | Everything | End users | Embedded/Linux | Web apps | Audio apps | ## FAQ **Q: How do I learn FFmpeg commands?** A: Start with the basic pattern: "ffmpeg -i input output". Add -vf for video filters, -af for audio filters, -c:v for video codec, -c:a for audio codec. The wiki and documentation cover every option. **Q: How do I reduce video file size?** A: Use H.265 (libx265) or AV1 (libaom-av1) codec with a higher CRF value (e.g., -crf 28). CRF controls quality — lower is better quality but larger file. 23 is default, 28 is good for web. **Q: Can FFmpeg use GPU acceleration?** A: Yes. NVIDIA: h264_nvenc/hevc_nvenc. Intel: h264_qsv/hevc_qsv. AMD: h264_amf/hevc_amf. macOS: h264_videotoolbox. GPU encoding is much faster but slightly lower quality per bitrate. **Q: How do I stream live video?** A: Use FFmpeg with RTMP output for YouTube/Twitch, or generate HLS/DASH segments for adaptive bitrate streaming. FFmpeg handles the entire pipeline from capture to delivery. ## Sources - GitHub Mirror: https://github.com/FFmpeg/FFmpeg - Official: https://git.ffmpeg.org/ffmpeg.git - Documentation: https://ffmpeg.org/documentation.html - Created by Fabrice Bellard - License: LGPL-2.1 / GPL-2.0 --- Source: https://tokrepo.com/en/workflows/353248b1-3701-11f1-9bc6-00163e2b0d79 Author: Script Depot