FFmpeg

From Gentoo Wiki
Jump to:navigation Jump to:search

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).

Installation

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

+dav1d Enable AV1 decoding support via media-libs/dav1d
+drm Enable use of x11-libs/libdrm for various hardware accelerated functions and Kernel Mode Setting screen capture
+fontconfig Support for configuring and customizing font access via media-libs/fontconfig
+gnutls Enable using net-libs/gnutls for TLS/HTTPS support and other minor functions (has no effect if USE=openssl is set)
+gpl Enable use of GPL licensed code, should be kept enabled unless LGPL binaries are needed
+libass SRT/SSA/ASS (SubRip / SubStation Alpha) subtitle support
+postproc Enable libpostproc video post processing library support (should not disable this unless need to disable USE=gpl)
+truetype Enable drawtext filter support via media-libs/freetype and media-libs/harfbuzz
+xml Enable Dynamic Adaptive Streaming over HTTP (DASH) stream support using dev-libs/libxml2
+zlib Add support for zlib compression
X Add support for X11
alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
amf Enable AMD's Advanced Media Framework support via media-video/amdgpu-pro-amf
amr Enable Adaptive Multi-Rate Audio support via media-libs/opencore-amr
amrenc Enable Adaptive Multi-Rate Audio encoding support via media-libs/vo-amrwbenc
appkit Enable Apple AppKit framework
bluray Enable Blu-ray filesystems reading support via media-libs/libbluray
bs2b Enable Bauer Stereo-to-Binaural filter support via media-libs/libbs2b
bzip2 Enable bzip2 compression support
cdio Enable audio CDs reading via dev-libs/libcdio-paranoia
chromaprint Enable audio fingerprinting support via media-libs/chromaprint
chromium Builds libffmpeg.so to enable media playback in Chromium-based browsers like Opera and Vivaldi.
codec2 Enable codec2 low bit rate speech codec support via media-libs/codec2
cuda Enable support for various GPU-accelerated filters using NVIDIA PTX compiled with llvm-core/clang
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
dvd Add support for DVDs
fdk Enable AAC (Advanced Audio Coding) encoding support via media-libs/fdk-aac in addition to FFmpeg's own implementation (warning: if USE=gpl is enabled, this produces a non-redistributable build)
flite Enable text-to-speech filter support via app-accessibility/flite
frei0r Enable use of filters through media-plugins/frei0r-plugins
fribidi Enable Bidi support for the drawtext filter via dev-libs/fribidi
gcrypt Enable using dev-libs/libgcrypt for rtmp(t)e support (not needed if using any of USE=gmp,librtmp,openssl), and for obtaining random bytes (not needed if USE=openssl)
gme Enables various game music formats support via media-libs/game-music-emu
gmp Add support for dev-libs/gmp (GNU MP library)
gsm Add support for the gsm lossy speech compression codec
iec61883 Enable FireWire DV/HDV input device support via 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 Add JPEG XL image support
kvazaar Enable H.265/HEVC encoding support via media-libs/kvazaar
ladspa Enable the ability to support ladspa plugins
lame Add support for MP3 encoding using LAME
lcms Enable ICC profile support via media-libs/lcms
libaom Enable AV1 de/encoding via media-libs/libaom (warning: this is the reference implementation and is slower than the alternatives)
libaribb24 Enable ARIB text and caption decoding via media-libs/aribb24
libcaca Add support for colored ASCII-art graphics
libilbc Enable internet Low Bitrate Codec de/encoding support via media-libs/libilbc
liblc3 Enable Low Complexity Communication Codec de/encoding support via media-sound/liblc3
libplacebo Enable use of GPU-accelerated filters from media-libs/libplacebo
librtmp Enable Real Time Messaging Protocol support via media-video/rtmpdump in addition to FFmpeg's own implementation
libsoxr Enable use of the audio resampler from media-libs/soxr
libtesseract Enable Optical Character Recognition (OCR) filter support via app-text/tesseract
lv2 Enable use of filters through media-libs/lv2
lzma Support for LZMA compression algorithm
modplug Add libmodplug support for playing SoundTracker-style music files
npp Enable Nvidia Performance Primitives-based filters via dev-util/nvidia-cuda-toolkit (warning: if USE=gpl is enabled, this produces non-redistributable build)
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 (computation on GPU)
opengl Add support for OpenGL (3D graphics)
openh264 Enable H.264 encoding support via media-libs/openh264
openmpt Enable MPTM tracked music files decoding support via media-libs/libopenmpt
openssl Enable using dev-libs/openssl for TLS/HTTPS support and other minor functions (USE=gnutls has no effect if set)
opus Enable Opus audio codec support
pulseaudio Add sound server support via media-libs/libpulse (may be PulseAudio or PipeWire)
qrcode Enable QR encode generation support via media-gfx/qrencode
qsv Enable Intel Quick Sync Video support via media-libs/libvpl
quirc Enable QR decoding support via media-libs/quirc
rabbitmq Enable AMQP stream support via net-libs/rabbitmq-c
rav1e Enable AV1 encoding support via media-video/rav1e
rubberband Enable time-stretching and pitch-shifting audio filter support via media-libs/rubberband
samba Add support for SAMBA (Windows File and Printer sharing)
sdl Enable use of the Simple Direct Layer library (required for the ffplay command)
shaderc Enable support for various GPU-accelerated filters using Vulkan compiled with media-libs/shaderc
snappy Enable Snappy compression support via app-arch/snappy (required for Vidvox Hap encoder support)
sndio Enable audio output support via media-sound/sndio
soc Apply additional patches for efficient playback on some SoCs (e.g. ARM, RISC-V)
speex Add support for the speex audio codec (used for speech)
srt Enable Secure Reliable Transport (SRT) support via net-libs/srt
ssh Enable SSH/SFTP support via net-libs/libssh
svg Add support for SVG (Scalable Vector Graphics)
svt-av1 Enable AV1 encoding support via media-libs/svt-av1
theora Add support for the Theora Video Compression Codec
twolame Enable MP2 encoding support via media-sound/twolame in addition to FFmpeg's own implementation
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
verify-sig Verify upstream signatures on distfiles
vidstab Enable video stabilization filter support via media-libs/vidstab
vmaf Enable Netflix's perceptual video quality assessment filter support via media-libs/libvmaf
vorbis Add support for the OggVorbis audio codec
vpx Enable VP8 and VP9 de/encoding support via media-libs/libvpx in addition to FFmpeg's own implementation (for decoding only)
vulkan Add support for 3D graphics and computing via the Vulkan cross-platform API
webp Add support for the WebP image format
x264 Enable h264 encoding using x264
x265 Enable H.265/HEVC encoding support via media-libs/x265
xvid Add support for xvid.org's open-source mpeg-4 codec
zeromq Enable ZMQ command receiver filter and streaming support via net-libs/zeromq
zimg Enable zscale filter support using media-libs/zimg
zvbi Enable teletext decoding support via media-libs/zvbi

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

user $equery uses media-video/ffmpeg

Emerge

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

Usage

Media player (ffplay)

user $ffplay -h
Note
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

Watch YouTube videos

ffplay can also play YouTube videos directly with the help of youtube-dl

user $youtube-dl -o - "https://www.youtube.com/watch?v=dQw4w9WgXcQ" | ffplay -

Play a sequence of images as a video

If you have a series of images (for instance, a sequence of frames from an animation), you can use `ffplay` to play them as a video:

user $ffplay -framerate 24 -pattern_type glob -i 'path_to_your_images/*.png'

Display webcam output

user $ffplay /dev/video0

Video Encoding

This section provides advanced FFmpeg commands for video encoding, allowing users to manipulate video files with precision and flexibility.

Convert video to AVI with specific codecs

This command converts a video file (input_demo.ogv) to the AVI format using the MPEG-4 video codec and MP3 audio codec. The resulting output file will be named my-demo-video.avi. The video codec ensures efficient compression while maintaining good quality, and the audio codec provides compatibility and reasonable file size.

user $ffmpeg -i input_demo.ogv -vcodec mpeg4 -qscale 0 -acodec libmp3lame my-demo-video.avi

Extract frames from video

This command extracts frames from a video file (my-demo-video_cropped.mp4) and saves them as individual images. The "-r" option specifies the frame rate for capturing frames, and the output filenames will be in the format "pic001.png", "pic002.png", and so on. Extracting frames from a video is useful for creating thumbnails, analyzing specific moments, or creating image-based summaries of the video content.

user $ffmpeg -i my-demo-video_cropped.mp4 -r 15/1 pic%03d.png

Create video from frames

This command creates a video file from a sequence of images. It reads a series of images (pic.%04d.png) using the "image2" demuxer and combines them into a video file (out.mp4) using a frame rate of 15 frames per second (-r 15) and a video bitrate of 8Mbps (-b:v 8M). This command allows users to convert a collection of images into a video with customizable settings such as frame rate and video quality.

user $ffmpeg -f image2 -r 15 -i pic.%04d.png -r 15 -b:v 8M out.mp4

Convert video to 3GP format

This command converts a video file (file.flv) to the 3GP format with specific video and audio settings (-r 15, -b 128k, -s qcif, -acodec amr_nb, -ar 8000, -ac 1, -ab 13). The resulting output file is out.3gp. The specified settings optimize the video for mobile devices, ensuring compatibility and efficient storage utilization.

user $ffmpeg -i file.flv -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y out.3gp

Capture screen video using FFmpeg

This command captures the screen video using x11grab and the dimensions of the screen obtained from xwininfo. The captured video is saved as /tmp/out.mpg. This command is useful for recording desktop activities, creating video tutorials, or capturing any content displayed on the screen:

user $ffmpeg -f x11grab -s $(xdpyinfo | grep 'dimensions:'|awk '{print $2}') -r 25 -i :0.0 -sameq /tmp/out.mpg > ~/howto/capture_screen_video_ffmpeg

With system sound plus mic (converted to mono with "amerge"), for the right display, h264 hardware encoding:

FILE grab.sh
ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1200 -i :0.0+2566,720 \
	-f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
	-f pulse -i alsa_input.usb-Focusrite_Scarlett_Solo_USB_Y7D1J3F0A66336-00.analog-stereo \
	-filter_complex "amerge" -ac 1 \
	-c:v h264_vaapi -vf 'format=nv12,hwupload' ~/record/$(date +%Y-%b-%d%a--%H-%M-%S | tr A-Z a-z).mp4

# Press q to finish the recording.

With system sound plus mic, another display configuration, av1 software encoding (more efficient than hardware encoding):

FILE grab.sh
ffmpeg -f x11grab -video_size 1920x1200 -i :0.0+1200 \
	-f pulse -i alsa_output.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_00113735E82E0A-00.analog-stereo.monitor \
	-f pulse -i alsa_input.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_00113735E82E0A-00.mono-fallback \
	-filter_complex "amerge" -ac 1 \
	-c:v libsvtav1 -preset 6 \
	-c:a libopus \
	~/record/out/$(date +%Y-%b-%d%a--%H-%M-%S | tr A-Z a-z).mkv

# Press q to finish the recording.

Filename will be like 2023-dec-31fri--23-59-59.mkv

See related pages

Convert video to WebM format

This command converts a video file (input_file.avi) to the WebM format and saves it as output_file.webm. WebM is a popular video format suitable for web streaming and HTML5-based video players.

user $ffmpeg -i input_file.avi output_file.webm

Create MPEG video from a sequence of images

This command creates an MPEG video file from a sequence of images (frame/$num.ppm). The images are combined with a frame rate of 30000/1001 (-r 30000/1001), and the resulting MPEG video files are saved as frame/%02d.mpeg. MPEG video format is widely supported and suitable for various applications, including DVD authoring and video distribution.

user $ffmpeg -loop_input -f image2 -r 30000/1001 -t $seconds -i frame/$num.ppm -y frame/%02d.mpeg 2>/dev/null

Create video with images and audio

This command creates a video file by combining a series of images (head-%03d.png) and an audio file (../foo.mp3). It sets the frame rate to 0.5 (-r '0.5') for the images and uses the copy codec (-acodec copy) for the audio. The resulting video is saved as muxed.flv. This command is useful for creating slideshows or image-based presentations with synchronized audio.

user $ffmpeg -t 300 -r '0.5' -i head-%03d.png -i ../foo.mp3 -acodec copy muxed.flv

Convert AVI video to WebM format with experimental codec

This command converts an AVI video file (input_file.avi) to the WebM format using the experimental codec (-strict experimental) and saves it as output_file.webm. The experimental codec provides access to cutting-edge video encoding algorithms and features, although its usage may come with potential risks or limited compatibility.

user $ffmpeg -i input_file.avi -strict experimental output_file.webm

Convert video to MP4 format for iPod

This command converts a video file (source.avi) to the MP4 format with specific video and audio settings. The resulting MP4 file will be compatible with iPod devices. The video codec used is MPEG-4 (-vcodec mpeg4) with a bitrate of 250000 (-b 250000), a resolution of 480x320 (-s 480x320), and an aspect ratio of 4:3 (-aspect 16:9). The audio codec used is AAC (-acodec aac) with a sample rate of 24000 Hz (-ar 24000), a bitrate of 64 (-ab 64), and 2 audio channels (-ac 2). The resulting MP4 file is saved as [destination].mp4.

user $ffmpeg -i [source].avi -f mp4 -vcodec mpeg4 -b 250000 -s 480x320 -acodec aac -ar 24000 -ab 64 -ac 2 [destination].mp4

Convert video to MPEG format for VCD

This command converts a video file (movie.avi) to the MPEG format suitable for Video CD (VCD) creation. The resulting MPEG file (movie.mpg) is encoded using the MPEG-1 video codec (-vcodec mpeg1video) with a bitrate of 1150 (-b 1150), a resolution of 352x

240 (-s 352x240), a frame rate of 29.97 frames per second (-r 29.97), a group of pictures (GOP) size of 12 (-g 12), and a quality range of 3 to 13 (-qmin 3 -qmax 13). The audio is encoded using the MP2 codec (-acodec mp2) with a bitrate of 224 (-ab 224), a sample rate of 44100 Hz (-ar 44100), 2 audio channels (-ac 2), and is mapped to the MPEG file (-map 0.1:0.1). This command is useful for creating VCDs that are compatible with standard DVD players.

user $ffmpeg -i movie.avi -y -f vcd -vcodec mpeg1video -map 0.0:0.0 -b 1150 -s 352x240 -r 29.97 -g 12 -qmin 3 -qmax 13 -acodec mp2 -ab 224 -ar 44100 -ac 2 -map 0.1:0.1 movie.mpg

Audio encoding

This section provides advanced FFmpeg commands for audio encoding, enabling users to manipulate audio files with various settings and configurations.

Convert audio to MP3

This command converts an audio file (input.flv) to the MP3 format using the specified audio quality (2). The resulting output file will be named output.mp3. MP3 is a widely supported audio format known for its efficient compression and compatibility.

user $ffmpeg -i input.flv -aq 2 output.mp3

Convert audio to FLAC

This command converts an audio file (audio.mp3) to the FLAC format using SoX. It applies various effects, such as gain adjustment and sample rate conversion, and saves the output as a FLAC file (audio.flac). FLAC is a lossless audio format that retains the original audio quality while achieving significant compression.

user $ffmpeg -loglevel 0 -y -i audio.mp3 -f sox - | sox -p -V -S -b24 -t audio.flac gain -3 rate -va 7056000 rate -v 48k

Extract audio from FLV video

This command extracts the audio stream from an FLV video file (<filename>.flv) and saves it as an MP3 file (<filename>.mp3). This is useful when you want to separate the audio track from a video file and work with it independently.

user $ffmpeg -i <filename>.flv -vn <filename>.mp3

Trim audio file

This command trims an audio file (input.mp3) by specifying the start time (00:00:30) and duration (00:02:58). The resulting trimmed audio is saved as output.mp3 without any re-encoding. Trimming audio files allows users to extract specific sections or segments of interest.

user $ffmpeg -ss 00:00:30 -t 00:02:58 -i input.mp3 -acodec copy output.mp3

Extract audio from video file and keep the same format

This command extracts the audio stream from a video file (file.ext) and saves it as a separate audio file (out.ext) without any re-encoding. The resulting audio file will have the same format as the input video file. This is useful when you want to extract the audio track from a video file while preserving its original format.

user $ffmpeg -i file.ext -acodec copy -vn out.ext

Extract audio from video and convert to MP3

This command extracts the audio stream from a video file (input.m4a) and converts it to MP3 format using the libmp3lame codec with a bitrate of 128k (-acodec libmp3lame -ab 128k). The resulting audio file is saved as output.mp3. Converting audio from a video to MP3 allows users to extract the audio track in a widely supported format.

user $ffmpeg -i input.m4a -acodec libmp3lame -ab 128k output.mp3

Extract audio and video streams and combine them

This command extracts the audio stream from a source audio file (source_audio.mp3) and the video stream from a source video file (source_video.m2v). The audio stream is offset by 10.2 seconds (-itsoffset 00:00:10.2) and combined with the video stream to create a target video file (target_video.flv). Combining audio and video streams allows users to synchronize them and create a single multimedia file.

user $ffmpeg -i source_audio.mp3 -itsoffset 00:00:10.2 -i source_video.m2v -c copy target_video.flv

Combine video and audio files into a single file

This command combines a video file (video.mp4) and an audio file (audio.mp3) into a single video file (mix.mp4). It copies the video stream (-vcodec copy) and audio stream (-acodec copy) without any re-encoding. Combining video and audio files allows users to merge separate media assets into a unified video file.

user $ffmpeg -i video.mp4 -i audio.mp3 -vcodec copy -acodec copy -map 0.0:0 -map 1.0:1 mix.mp4

Image encoding

Convert audio with image to video

This command converts an audio file (music.flac) with an accompanying image (img.jpg) into a video file (o.mkv). The resulting video will have the image displayed throughout its duration, synchronized with the audio. The command utilizes the VP9 video codec (-vcodec vp9) for efficient compression and the audio stream is copied without any conversion (-acodec copy) to maintain the original audio quality.

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

Please note that the frame rate (FPS) of the resulting video can be modified by adjusting the "-r" parameter. A lower frame rate, such as "-r 0.1", can lead to faster encoding and a smaller file size. However, it's important to note that using such low frame rates may result in compatibility issues with certain platforms, like PeerTube. For optimal compatibility, using "-r 1" or higher is recommended, although it may slightly impact the quality of the displayed image. Experimenting with values like "-r 2" can strike a balance between quality and encoding speed.

Create a slideshow with background music

This command creates a slideshow from a series of images (img%03d.jpg) and adds background music from an audio file (music.mp3). The output video file (slideshow.mp4) uses the H.264 video codec and AAC audio codec. The frame rate is set to 24 frames per second (-r 24) and the audio bitrate is set to 128 kbps (-b:a 128k). This command is useful for creating a slideshow presentation with synchronized music.

user $ffmpeg -framerate 1/5 -i img=%03d.jpg -i music.mp3 -c:v libx264 -c:a aac -r 24 -b:a 128k slideshow.mp4

Resize an image

This command resizes an image (input.jpg) to a width of 800 pixels while preserving the aspect ratio. The resulting image is saved as output.jpg. This command is useful for resizing images to fit specific dimensions or aspect ratios.

user $ffmpeg -i input.jpg -vf "scale=800:-1" output.jpg

Crop an image

This command crops an image (input.jpg) to a specified width and height (500x300) starting from the top-left corner. The resulting image is saved as output.jpg. This command is useful for removing unwanted parts or focusing on specific areas of an image.

user $ffmpeg -i input.jpg -vf "crop=500:300" output.jpg

Add a border to an image

This command adds a black border to an image (input.jpg) with a thickness of 10 pixels. The resulting image is saved as output.jpg. This command is useful for creating a visual separation or frame around an image.

user $ffmpeg -i input.jpg -vf "pad=width=iw+20:height=ih+20:color=black" output.jpg

Convert an image to grayscale

This command converts an image (input.jpg) to grayscale and saves the resulting image as output.jpg. The resulting image will be in black and white. This command is useful for creating artistic or vintage effects.

user $ffmpeg -i input.jpg -vf "format=gray" output.jpg

Apply a sepia filter to an image

This command applies a sepia filter to an image (input.jpg) and saves the resulting image as output.jpg. The sepia filter adds a warm, vintage tone to the image. This command is useful for adding an antique or nostalgic look to images.

user $ffmpeg -i input.jpg -vf "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131" output.jpg

Rotate an image

This command rotates an image (input.jpg) clockwise by 90 degrees and saves the resulting image as output.jpg. This command is useful for adjusting the orientation of images.

user $ffmpeg -i input.jpg -vf "transpose=1" output.jpg

Extract a single frame from a video

This command extracts a single frame from a video (input.mp4) at a specified time (00:00:05) and saves it as an image (output.jpg). This command is useful for capturing a specific moment or scene from a video.

user $ffmpeg -ss 00:00:05 -i input.mp4 -vframes 1 output.jpg

Apply a blur effect to an image

This command applies a blur effect to an image (input.jpg) and saves the resulting image as output.jpg. The blur effect softens the details and creates a smoother appearance. This command is useful for adding a dreamy or artistic look to images.

user $ffmpeg -i input.jpg -vf "boxblur=5:1" output.jpg

Adjust the brightness of an image

This command adjusts the brightness of an image (input.jpg) and saves the resulting image as output.jpg. The brightness value can be positive or negative, with higher values making the image brighter and lower values making it darker. This command is useful for correcting underexposed or overexposed images.

user $ffmpeg -i input.jpg -vf "eq=brightness=0.2" output.jpg

Apply a color filter to an image

This command applies a color filter to an image (input.jpg) and saves the resulting image as output.jpg. The color filter can be used to change the overall color tone or create a specific atmosphere. This command is useful for enhancing the mood or giving images a unique look.

user $ffmpeg -i input.jpg -vf "colorchannelmixer=.5:.5:0:0:.2:.8:0:0:.1:.9" output.jpg

Apply a fisheye effect to an image

This command applies a fisheye effect to an image (input.jpg) and saves the resulting image as output.jpg. The fisheye effect creates a distortion that resembles a fish-eye lens. This command is useful for creating unique and exaggerated perspectives in images.

user $ffmpeg -i input.jpg -vf "lenscorrection=k1=-0.2:k2=-0.2" output.jpg

Convert an image to a specific color space

This command converts an image (input.jpg) to a specific color space (sRGB) and saves the resulting image as output.jpg. Color space conversion can be used to ensure color accuracy or compatibility with specific devices or applications.

user $ffmpeg -i input.jpg -vf "colormatrix=bt709:bt601" output.jpg

Apply a vignette effect to an image

This command applies a vignette effect to an image (input.jpg) and saves the resulting image as output.jpg. The vignette effect darkens the corners and edges of the image, drawing attention to the center. This command is useful for adding a vintage or dramatic look to images.

user $ffmpeg -i input.jpg -vf "vignette='angle_w=PI/4:angle_h=PI/4'" output.jpg

Apply a sketch effect to an image

This command applies a sketch effect to an image (input.jpg) and saves the resulting image as output.jpg. The sketch effect simulates a hand-drawn or pencil sketch appearance. This command is useful for creating artistic or stylized images.

user $ffmpeg -i input.jpg -vf "sketch=strength=2:gamma=2" output.jpg

Apply a mosaic effect to an image

This command applies a mosaic effect to an image (input.jpg) and saves the resulting image as output.jpg. The mosaic effect creates a pixelated or blocky appearance. This command is useful for adding privacy or abstract visual effects to images.

user $ffmpeg -i input.jpg -vf "scale=iw/10:-1,scale=iw*10:-1" output.jpg

See also

External resources