Introduction
FFmpeg is a multi-platform command line tool that allows you to convert, compress, filter and transmit virtually any audio and video format. In Linux it has become the de facto standard for multimedia tasks thanks to its large number of integrated codecs and its ability to work through scripts. This post shows the most useful commands for beginners and advanced users, explaining the basic syntax, quality parameters and some practical examples that you can adapt to your workflow.
ffmpeg installation
In most Linux ffmpeg distributions is available in official repositories. In Ubuntu or Debian just runsudo apt update && sudo apt install ffmpeg. In Fedora it is usedsudo dnf install ffmpegand in Arch Linuxsudo pacman -S ffmpeg. If you need the latest version with all the codecs, you can compile from the source code or use snap / flatpak packages. Verifies the installation withffmpeg -version.
Basic format conversion
Convert a video file to another format is as simple as specifying the input and output file. For example, to move from MKV to MP4 without recoding the video and just copying the flows, it is used:
ffmpeg -i entrada.mkv -c copy salida.mp4ffmpeg -i entrada.wav -ar 44100 -ac 2 salida.mp3to convert WAV audio to MP3 with 44.1 kHz and stereo rate.
The parameter-c copyindicates that the flow is copied without recharge, which saves time and avoids quality loss. When you need to change the resolution or the bitrate, add options like-vf scale=1280:720or-b:v 2M.
Audio processing
FFmpeg allows to extract, mix and apply effects to audio tracks. To remove the audio track from a video and save it as AAC runs:
ffmpeg -i video.mov -vn -c:a aac -b:a 192k audio.aac
The indicator-vndiscard the video. To normalize the volume you can use the filterloudnorm:
ffmpeg -i entrada.wav -af loudnorm=I=-16:TP=-1.5:LRA=11 salida.wav
In addition, it is possible to concatenate several audio files with the demanxerconcator create a fade-in / fade-out byafade.
Video processing
In the area of video, video filters (-vf) allow to scale, cut, change speed and apply color effects. A typical example is to reduce resolution to 720p and limit bitrate to 2 Mbps:
ffmpeg -i entrada.mkv -vf scale=1280:720 -b:v 2M -c:a aac -b:a 128k salida.mp4
To create a timelapse you can speed up the video withsetpts:
ffmpeg -i entrada.mkv -vf 'setpts=0.5*PTS' salida.mp4
If you need to add incorporated subtitles, use-c:s mov_textfor MP4 or-c:s srtfor MKV.
Advanced examples: filters and concatenation
FFmpeg chain multiple filters separated by commas. For example, apply a Gaussian misfocus and then a glow adjustment:
ffmpeg -i entrada.mp4 -vf 'gblur=sigma=2,eq=brightness=0.06:saturation=1.2' salida.mp4
The focus of several clips is done by creating a list file (mylist.txt) with the formfile 'clip1.mp4'and then:
ffmpeg -f concat -safe 0 -i mylist.txt -c:v copy salida.mp4
It is also possible to generate an audio-shaped wave directly from FFmpeg using the filteraevalsrcor create a progress bar withdrawtext.
Performance and good practice tips
To accelerate the coding, take advantage of the libx264 preset (-preset fast) or use hardware encoding with-c:v h264_vaapiin compatible GPUs. Always keep a copy without losing quality (e.g. using-c copy) before applying destructive transformations. Check the output log to detect warnings about discarded packages or audio-video synchronization. Finally, it automates recurrent tasks with bash scripts that accept input and output arguments, which facilitates batch processing.
Conclusion
FFmpeg is a powerful and flexible tool that, once dominated, allows to perform almost any audio and video operation from the Linux terminal. From simple conversions to complex filter chains and hardware processing, its wide set of options makes it an indispensable ally for developers, video editors and multimedia enthusiasts. Practice with the examples shown and adapt the parameters to your specific needs for professional results.


