FFmpeg 5 is a major release of the popular open-source multimedia framework, offering a powerful command-line tool for processing and converting audio and video files. This update has many new features and improvements that make it an attractive choice for developers, video editors, and anyone needing to work with multimedia files.
To install FFmpeg 5, users can use the command line terminal and a well-known PPA by Rob Savoury. This guide will demonstrate both installation methods, making it easy for users to start.
Table of Contents
What’s new in FFmpeg 5?
Here are some of the new features and improvements that were introduced in FFmpeg 5:
- AV1 Codec Support: FFmpeg 5.0 includes support for the AV1 codec, a royalty-free video codec developed by the Alliance for Open Media. AV1 is designed to provide high-quality video compression while being efficient and scalable, making it an attractive choice for many applications.
- WebP Animation Support: FFmpeg 5.0 can now handle WebP animations, a sequence of WebP images played back in a loop to create an animated effect. This is a great addition for anyone who works with WebP images and wants to create animated graphics for the web.
- New Filters: FFmpeg 5.0 includes several new video and audio filters, such as the chromahold filter, which replaces the chroma of a video frame with a solid color, and the balance filter, which adjusts the balance between the left and right audio channels.
- Hardware Acceleration: FFmpeg 5.0 supports hardware acceleration on various platforms and devices, including ARM Mali, VideoCore IV GPUs, and the NVIDIA Jetson platform.
- Improved Documentation: FFmpeg 5.0 features improved documentation, with more comprehensive and up-to-date information on how to use the various features and options of the tool. This will be especially helpful for newcomers to FFmpeg who are just starting with the tool.
Step 1: Update Ubuntu
Before installing FFmpeg on your Ubuntu system, it is recommended to update your system to ensure a smooth installation process and avoid potential conflicts. This will also ensure that any dependencies or packages required by FFmpeg are up-to-date and compatible with your system. You can update your system by running the following command in your terminal:
sudo apt update && sudo apt upgrade
Step 2: Import FFmpeg PPA
To begin the installation process, you need to install some necessary packages. You can do this by running the following command:
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https
If you encounter problems while importing GPG keys from Launchpad PPAs via the command line terminal, it may be due to missing directories. To fix this issue, you can run the following command to create the required directories:
sudo gpg --list-keys
Example output:
gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
Importing the GPG key is required to access the repositories. You can import the GPG key required for all the repositories using the following command:
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/rob-savoury.gpg --keyserver keyserver.ubuntu.com --recv-keys E996735927E427A733BB653E374C7797FB006459
Example output:
gpg: keybox '/usr/share/keyrings/rob-savoury.gpg' created
gpg: key 374C7797FB006459: public key "Launchpad PPA for Rob Savoury" imported
gpg: Total number processed: 1
gpg: imported: 1
It is important to note that importing the FFmpeg 4 and 5 PPA’s by Rob Savoury may involve changing and upgrading multiple system packages, which cannot be easily reversed, given you are using an LTS release; this potentially can bring instabilities. Therefore, creating a backup of your system before proceeding with the installation is crucial.
Next, import the FFmpeg 4 and 5 PPA, as both are required by running the following commands in your terminal:
echo "deb [signed-by=/usr/share/keyrings/rob-savoury.gpg] https://ppa.launchpadcontent.net/savoury1/ffmpeg4/ubuntu $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/ffmpeg-rob-savoury.list
echo "deb [signed-by=/usr/share/keyrings/rob-savoury.gpg] https://ppa.launchpadcontent.net/savoury1/ffmpeg5/ubuntu $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/ffmpeg-rob-savoury.list
After importing the PPA, run the following command to update your Ubuntu sources list:
sudo apt update
Before proceeding any further, it is recommended to run a quick upgrade by using the following command:
sudo apt upgrade
Step 3: Install FFmpeg 5
Now that the PPA repository has been added to your system, you can install FFmpeg 5. This can be done by running the following command in your terminal:
sudo apt install ffmpeg
After the installation process is complete, you can verify the installation by running the following command:
ffmpeg -version
This command will display the FFmpeg version installed on your system. You should see an output similar to the following:
Example output:
ffmpeg version 5.1.2-0ubuntu1~22.04.sav2 Copyright (c) 2000-2022 the FFmpeg developers
If you wish to view the encoders and decoders available for FFmpeg 5, you can use the following commands:
To view the available encoders:
ffmpeg -encoders
To view the available decoders:
ffmpeg -decoders
These commands will display a list of available encoders and decoders, respectively. By using these commands, you can better understand the capabilities of FFmpeg 5 and the available options for encoding and decoding media files.
FFmpeg Command Examples
Once FFmpeg 5 is installed on your system, you can use it to perform various tasks. The following commands provide some commonly used examples:
Converting a video file from one format to another:
ffmpeg -i input.mp4 output.avi
In this command, “input.mp4” is the source file’s name, and “output.avi” is the destination file’s name.
Extracting audio from a video file:
ffmpeg -i input.mp4 -vn -acodec copy output.aac
In this command, “-vn” disables video output, “-acodec copy” copies the audio stream without re-encoding, “input.mp4” is the source file, and “output.aac” is the name of the destination file.
Extracting a single frame from a video file:
ffmpeg -i input.mp4 -ss 00:00:10 -frames:v 1 output.jpg
In this command, “-ss 00:00:10” seeks to the 10th second of the video, “-frames:v 1” specifies the number of frames to output, “input.mp4” is the name of the source file, and “output.jpg” is the name of the output file.
Merging two video files together:
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]concat=n=2:v=1[outv]" -map "[outv]" output.mp4
In this command, “-filter_complex” specifies the filter graph, “n=2:v=1” specifies the number of inputs and the output video stream, “outv” is the name of the output video stream, and “output.mp4” is the name of the output file.
Scaling a video file to a specific size:
ffmpeg -i input.mp4 -vf scale=640:360 output.mp4
In this command, “scale=640:360” specifies the target size of the video, “input.mp4” is the source file, and “output.mp4” is the name of the output file.
Adding subtitles to a video file:
ffmpeg -i input.mp4 -vf subtitles=subs.srt output.mp4
In this command, “subtitles=subs.srt” specifies the path to the subtitle file, “input.mp4” is the source file, and “output.mp4” is the name of the output file.
Changing the video codec of a file:
ffmpeg -i input.mp4 -vcodec h264 output.mp4
\
In this command, “-vcodec h264” specifies the H.264 video codec, “input.mp4” is the source file, and “output.mp4” is the name of the output file.
Extracting frames from a video at regular intervals:
ffmpeg -i input.mp4 -vf fps=1/10 output%03d.jpg
In this command, “fps=1/10” specifies that one frame should be output every ten seconds, “input.mp4” is the source file, and “output%03d.jpg” is the naming pattern for the output files.
Removing the audio from a video file:
ffmpeg -i input.mp4 -an output.mp4
In this command, “-an” disables the audio output, “input.mp4” is the source file, and “output.mp4” is the name of the output file.
Extracting metadata from a video file:
ffmpeg -i input.mp4 -f ffmetadata metadata.txt
In this command, “-f ffmetadata” specifies the metadata output format, “input.mp4” is the source file, and “metadata.txt” is the name of the output file.
To learn more about what FFmpeg commands, visit their documentation page.
Conclusion
In conclusion, FFmpeg is a powerful and versatile multimedia framework that enables Ubuntu users to decode, encode, transcode, and stream audio and video files. FFmpeg 5, the latest stable release, has several new features and improvements that make it even more useful for working with media files.
In this article, we have provided a detailed guide on installing FFmpeg 5 on Ubuntu and have outlined ten commonly used terminal commands to help you get started. By mastering these commands, you can perform various tasks, from simple conversions to more complex editing operations.
FAQs on FFmpeg 5 with Ubuntu
Q: What is FFmpeg?
A: FFmpeg is a powerful multimedia framework to decode, encode, transcode, and stream audio and video files.
Q: What is FFmpeg 5?
A: FFmpeg 5 is the latest stable release of FFmpeg, which includes several new features and improvements over its predecessor.
Q: How can I install FFmpeg 5 on Ubuntu?
A: To install FFmpeg 5 on Ubuntu, add the FFmpeg PPA repository to your system and install the software. You can follow the steps outlined in the previous section to install FFmpeg 5 on Ubuntu.
Q: What common tasks can be performed using FFmpeg 5?
A: Some common tasks that can be performed using FFmpeg 5 include converting video files from one format to another, extracting audio from video files, extracting frames from a video at regular intervals, and adding subtitles to a video file.
Q: What are some commonly used FFmpeg 5 commands?
A: Some commonly used FFmpeg 5 commands include converting a video file from one format to another, extracting audio from a video file, extracting a single frame from a video file, merging two video files together, scaling a video file to a specific size, adding subtitles to a video file, changing the video codec of a file, extracting frames from a video at regular intervals, removing the audio from a video file, and extracting metadata from a video file.
Q: Is FFmpeg open-source software?
A: Yes, FFmpeg is open-source software released under the GNU Lesser General Public License (LGPL) or GNU General Public License (GPL), depending on the configuration options chosen at compile time.
Q: Is FFmpeg compatible with different operating systems?
A: Yes, FFmpeg is compatible with different operating systems, including Windows, macOS, and Linux.
Q: Can I use FFmpeg to edit audio files?
A: Yes, FFmpeg can be used to edit audio files. Some tasks that can be performed using FFmpeg on audio files include cutting, merging, and converting audio files from one format to another.
Q: Is FFmpeg difficult to use for beginners?
A: FFmpeg can be difficult for beginners due to its wide range of capabilities and complex command structure. However, with practice and the help of resources such as online tutorials and user forums, users can quickly learn to use FFmpeg.
Q: Is FFmpeg legal to use?
A: Yes, FFmpeg is legal to use. However, users should be aware of copyright laws and licensing agreements that may apply to the media files they work with.
Q: Can I undo modifications made to a media file using FFmpeg?
A: No, FFmpeg modifications made to a media file cannot be easily undone. Users should always create a backup of their original files before making any modifications to ensure they have a copy of the unmodified media file.
Q: Is FFmpeg pre-installed on Ubuntu?
A: No, FFmpeg is not pre-installed on Ubuntu. Users must install FFmpeg on their Ubuntu systems using the appropriate command-line tools.
Q: Can I use FFmpeg to crop and resize video files on Ubuntu?
A: Yes, FFmpeg can be used to crop and resize video files on Ubuntu. To crop a video file using FFmpeg, you can use the “crop” filter, and to resize a video file, you can use the “scale” filter.
Q: Does FFmpeg support hardware acceleration on Ubuntu?
A: Yes, FFmpeg supports hardware acceleration on Ubuntu for certain codecs and devices, such as NVIDIA GPUs and Intel Quick Sync Video. Hardware acceleration can significantly improve the performance and speed of FFmpeg operations.