Raspberry Pi

How to Install FFmpeg on Raspberry Pi

The ffmpeg is an open-source tool used for audio or video file processing. It includes various suites of libraries that let you convert audio and video files from one format to another. You can also use this tool to stream your audio or video files, resize them, or make other media file changes.

Raspberry Pi users can install this tool on their systems through this article’s guidelines.

How to Install ffmpeg on Raspberry Pi

To install ffmpeg on your Raspberry Pi system, make sure to update your system repository from the following command:

$ sudo apt update && sudo apt upgrade -y

Now you have updated the packages on your system, you can install ffmpeg through the following command:

$ sudo apt install ffmpeg -y

After the installation, ensure that ffmpeg is successfully installed on your system and you can use the version command to confirm it.

$ ffmpeg -version

You can also confirm the installation of ffmpeg encoder and decoder from the following commands:

$ ffmpeg -encoders

$ ffmpeg -decoders

How to Convert Video on Raspberry Pi Using ffmpeg

To convert an audio or video file through ffmpeg, you can use the following command:

$ ffmpeg -i <source_video/audio_file>.format <output_filename>.format

Make sure to replace the file name and format with the source file you want to convert. You should also provide the converted file name with the format you want the file to be converted.

In my case, I am converting a video file in mp4 format to mkv format just to give you an idea of how the process should be done.

You can see your converted file at “/home/pi”.

To extract audio from a video file, you can use the following command:

$ ffmpeg -i <source_video_file> -vn <output_audio_file>

If you want to change the video resolution inside the video file, you can apply the following command:

$ ffmpeg -i <source_video_file> -s <reosultion> <output_file_name>

How to Remove ffmpeg from Raspberry Pi

To remove ffmpeg from Raspberry Pi, you can issue the following command whenever you want:

$ sudo apt remove ffmpeg -y

Conclusion

ffmpeg is a perfect tool for processing your audio or video files, as it allows you to convert them into a different format easily. This tool can be installed directly from the Raspberry Pi source repository through a single command, which requires updating the repository first so that you can install an updated version on your system. After the installation, you can easily convert your video or audio files using the “ffmeg -i” command with the source and converted file names with their formats.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.