From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

FFmpeg is a cross platform, free, open source media encoder/decoder toolkit. It contains the programs and libraries necessary to convert audio and video into a wide range of formats. FFmpeg was written by Fabrice Bellard (creator of QEMU and the BPG image format).


USE flags

Some packages know the ffmpeg USE flag for enabling ffmpeg-based audio/video codec support.

USE flags for media-video/ffmpeg Complete solution to record/convert/stream audio and video. Includes libavcodec

X Add support for X11
alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
amf Enables support for AMD's Advanced Media Framework (AMF)
amr Enables Adaptive Multi-Rate Audio support
amrenc Enables Adaptive Multi-Rate Audio encoding support with media-libs/vo-amrwbenc.
appkit Enables Apple AppKit framework
bluray Enable playback of Blu-ray filesystems
bs2b Enables media-libs/libbs2b based Bauer stereo-to-binaural filter.
bzip2 Use the bzlib compression library
cdio Enables audio CD grabbing with dev-libs/libcdio.
chromaprint Enables audio fingerprinting support with media-libs/chromaprint.
chromium Builds libffmpeg.so to enable media playback in Chromium-based browsers like Opera and Vivaldi.
codec2 Enables codec2 low bit rate speech codec support via media-libs/codec2.
cpudetection Enables runtime CPU detection (useful for bindist, compatibility on other CPUs)
cuda Enables CUDA-based acceleration. Mostly used for specific filters.
dav1d Enables AV1 decoding via media-libs/dav1d.
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
encode Add support for encoding of audio or video files
fdk Use external fdk-aac library for AAC encoding
flite Adds a text-to-speech filter based on app-accessibility/flite.
fontconfig Support for configuring and customizing font access via media-libs/fontconfig
frei0r Enable frei0r wrapping in libavfilter
fribidi Enables fribidi support in the drawtext filter.
gcrypt Enables gcrypt support: Needed for rtmp(t)e support if openssl, librtmp or gmp is not used.
gme Enables support for media-libs/game-music-emu for playing various video game music formats.
gmp Add support for dev-libs/gmp (GNU MP library)
gnutls Prefer net-libs/gnutls as SSL/TLS provider (ineffective with USE=-ssl)
gpl Build GPL code. Should be enabled unless you require LGPL binaries.
gsm Add support for the gsm lossy speech compression codec
hardcoded-tables Use pre-calculated tables rather than calculating them on the fly. It results in an increase of approximately 15% in the size of libavcodec, the main library impacted by this change. It enables savings in table generation time, done once at codec initialization, since by hardcoding the tables, they do not need to be computed at runtime. However, the savings are often negligible (~100k cycles is a typical number) especially when amortized over the entire encoding/decoding operation. Improvements are being made to the runtime initialization, and so over time, this option will have an impact on fewer and fewer codecs.
iconv Enable support for the iconv character set conversion library
iec61883 Support for FireWire DV/HDV input device using media-libs/libiec61883.
ieee1394 Enable FireWire/iLink IEEE1394 support (dv, camera, ...)
jack Add support for the JACK Audio Connection Kit
jpeg2k Support for JPEG 2000, a wavelet-based image compression format
jpegxl Enable JPEG XL de/encoding via media-libs/libjxl.
kvazaar Enables media-libs/kvazaar based HEVC encoder.
ladspa Enable the ability to support ladspa plugins
lcms Enable ICC profile support via media-libs/lcms.
libaom Enables media-libs/libaom based AV1 codec support.
libaribb24 Enables ARIB text and caption decoding via media-libs/aribb24.
libass SRT/SSA/ASS (SubRip / SubStation Alpha) subtitle support
libcaca Add support for colored ASCII-art graphics
libdrm Enables x11-libs/libdrm support for better screen grabbing and hardware accelerated codecs.
libilbc Enables iLBC de/encoding via media-libs/libilbc.
libplacebo Adds flexible GPU-accelerated processing filter based on media-libs/libplacebo.
librtmp Enables Real Time Messaging Protocol using librtmp (media-video/rtmpdump) in addition to FFmpeg's native implementation.
libsoxr Enables audio resampling through media-libs/soxr.
libtesseract Enables the OCR filter via app-text/tesseract.
libv4l Uses media-libs/libv4l for video4linux instead of direct calls. Adds support for more devices via the userspace library.
libxml2 Uses dev-libs/libxml2 to enable dash demuxing support.
lv2 Enables lv2 audio filter wrapper.
lzma Support for LZMA (de)compression algorithm
mipsdspr1 Enables MIPS DSP ASE R1 optimizations.
mipsdspr2 Enables MIPS DSP ASE R2 optimizations.
mipsfpu Enables floating point MIPS optimizations.
mmal Enables Multi-Media Abstraction Layer (MMAL) decoding support: Available e.g. on the Raspberry Pi.
modplug Add libmodplug support for playing SoundTracker-style music files
mp3 Add support for reading mp3 files
network Enables network streaming support
nvenc Add support for NVIDIA Encoder/Decoder (NVENC/NVDEC) API for hardware accelerated encoding and decoding on NVIDIA cards (requires x11-drivers/nvidia-drivers)
openal Add support for the Open Audio Library
opencl Enable OpenCL support
opengl Add support for OpenGL (3D graphics)
openh264 Enables H.264 encoding suppoprt via media-libs/openh264.
openssl Enables dev-libs/openssl support. Adds support for encrypted network protocols (TLS/HTTPS).
opus Enable Opus audio codec support
oss Add support for OSS (Open Sound System)
pic Force shared libraries to be built as PIC (this is slower)
postproc Build and install libpostproc.
pulseaudio Add support for PulseAudio sound server
qsv Enable Intel Quick Sync Video via media-libs/intel-mediasdk (ffmpeg versions older than, and including, 5.1) or media-libs/oneVPL (ffmpeg version newer than 5.1).
rav1e Enables AV1 encoding support via media-video/rav1e.
rubberband Adds time-stretching and pitch-shifting audio filter based on media-libs/rubberband.
samba Add support for SAMBA (Windows File and Printer sharing)
sdl Add support for Simple Direct Layer (media library)
snappy Enable app-arch/snappy support. Required for e.g. Vidvox Hap encoder.
sndio Enable support for the media-sound/sndio backend
speex Add support for the speex audio codec (used for speech)
srt Enable support for Secure Reliable Transport (SRT) via net-libs/srt
ssh Enable SSH/sftp support via net-libs/libssh.
static-libs Build static versions of dynamic libraries as well
svg Add support for SVG (Scalable Vector Graphics)
svt-av1 Enables AV1 encoding support via media-libs/svt-av1.
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
theora Add support for the Theora Video Compression Codec
threads Add threads support for various packages. Usually pthreads
truetype Add support for FreeType and/or FreeType2 fonts
twolame Enables MP2 encoding via media-sound/twolame as an alternative to the internal encoder.
v4l Enable support for video4linux (using linux-headers or userspace libv4l libraries)
vaapi Enable Video Acceleration API for hardware decoding
vdpau Enable the Video Decode and Presentation API for Unix acceleration interface
vidstab Enables video stabilization filter using vid.stab library (media-libs/vidstab).
vmaf Enables Netflix's perceptual video quality assessment filter using the library (media-libs/libvmaf).
vorbis Add support for the OggVorbis audio codec
vpx Enables VP8 and VP9 codec support using libvpx: Decoding does not require this to be enabled but libvpx can also be used for decoding; encoding requires this useflag to be enabled though.
vulkan Enables support for the vulkan API for GPU offload.
webp Add support for the WebP image format
x264 Enable h264 encoding using x264
x265 Enables HEVC encoding with media-libs/x265.
xvid Add support for xvid.org's open-source mpeg-4 codec
zeromq Enables net-libs/zeromq support with the zmq/azmq filters.
zimg Enables media-libs/zimg based scale filter.
zlib Add support for zlib (de)compression
zvbi Enables media-libs/zvbi based teletext decoder.

The above list is non-comprehensive. Use equery (part of app-portage/gentoolkit) to see all available flags:

user $equery uses media-video/ffmpeg


If not already pulled in as a dependency of other packages, and after setting appropriate USE flags, emerge FFmpeg:

root #emerge --ask media-video/ffmpeg


Media player (ffplay)

If built with the sdl USE flag, a command line media player called ffplay is available.

user $curl http://www.dradio.de/streaming/dlf_hq_ogg.m3u | xargs ffplay

For more information consult the following commands:

user $man 1 ffplay
user $ffplay -h

Convert audio with image to video

user $ffmpeg -r 1 -loop 1 -i img.jpg -i music.flac -shortest -acodec copy -vcodec vp9 o.mkv

-r 0.1 set FPS to 0.1 for faster encoding and smaller file size, but transcoding fails on PeerTube (-r 1 works but quality of art will be poor, -r 2 is better but slower).

-acodec copy will not convert audio

External resources