How to Install FFmpeg on CentOS 8 / RHEL 8

How to install FFmpeg on CentOS 8 / RHEL 8 Linux system? FFmpeg is a free and open source multimedia framework used for playing, encoding, decoding, streaming, transcoding, multiplexing, demultiplexing and filtering multimedia files of various formats including MPEG1 audio and video, MPEG4, h263, ac3, asf, avi, real, mjpeg and Flash.

How to install RHEL 8 on CentOS 8 Install on systemFFmpeg is a free and open source multimedia framework for playing, encoding, decoding, streaming, transcoding, multiplexing, demultiplexing and filtering multimedia files in various formats, including MPEG1 audio and video, MPEG4, h263, ac3, asf, avi, real, mjpeg and Flash.
FFmpeg is a cross-platform application that runs on Linux, macOS, Windows, BSD, Solaris, etc., in a wide variety of build environments, configurations, and machine architectures. Most media players available for Linux, as well as audio/video downloaders and converters (such as youtube-dl) require FFmpeg to work.
FFmpeg Tools
These are the main building blocks of FFmpeg:
ffmpeg – a command-line tool for converting multimedia files between formats
ffplay – A simple media player based on SDL and FFmpeg libraries
ffprobe – a simple multimedia stream analyzer
FFmpeg also contains developer libraries – libavutil, libavcodec, libavformat, libavdevice, libavfilter, libswscale, and libswresample.
The following diagram of ffmpeg describes the transcoding process for each output:

How to Install FFmpeg on CentOS 8 / RHEL 8
Before installing FFmpeg on CentOS 8 / RHEL 8 Linux, make sure the system environment is fully configured.
Install RPMfusion Yum Repository
The RPM Fusion data source was created to provide software that is not available in Fedora and Red Hat based distributions. The software applications available in this data source are provided in the form of precompiled RPM files. In this article, we will use the RPMfusion data source to install FFmpeg on CentOS 8 / RHEL 8.
Before installing the RPM Fusion repository, you need to install the EPEL repository on your system.

sudo dnf -y install https://download.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm sudo dnf localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm sudo dnf install --nogpgcheck https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm

Install FFmpeg on CentOS 8 / RHEL 8 Linux
After adding EPEL and RPM Fusion repository, run the following commands in terminal to install FFmpeg on CentOS 8 / RHEL 8 Linux system.

sudo dnf install http://rpmfind.net/linux/epel/7/x86_64/Packages/s/SDL2-2.0.10-1.el7.x86_64.rpm sudo dnf install ffmpeg sudo dnf -y install ffmpeg-devel

Use the following command to check the FFmpeg version installed on your RHEL/CentOS system.

rpm -qi ffmpeg ffmpeg -version


Order
1: Recording Video:


-f: specifies to collect data from avfoundation using mac.

-i: stands for input, input stream, and the following 1 is the device number, indicating the screen (recording)

i handles the input stream).

-r: specifies the frame rate. Generally speaking, 25 frames is smoother, and 15 frames is barely enough.

out.yuv: The collected data is saved in yuv format, which is a raw format of data and is relatively large.

ffmpeg -f avfoundation -i 1 -r 30 out.yuv

Play video:


-s specifies the resolution

-pix_fmt specifies the original video format

ffplay -s 2560*1600 -pix_fmt uyvy422

Capture Audio


The device before the colon represents the video device, and the device after the colon represents the audio device

ffmpeg -f avfoundation -i :1 out.wav

Play Audio


Since this is formatted audio data, you can just play it directly.

ffplay out.wav

2: Decomposition and reuse
Used to change the format of multimedia data (packaging format)
Demultiplexing - essentially the separation of audio and video data.
Multiplexing - Repackaging audio and video data.
Convert audio and video formats


-vcodec video demultiplexing

-acodec audio demultiplexing

copy means not to change the encoding format after demultiplexing, completely copy

ffmpeg -i test.mp4 -vcodec copy -acodec copy out.flv

Extract video stream


-an means no audio stream

ffmpeg -i test.mp4 -an -vcodec copy out.h264

Extracting audio stream

ffmpeg -i test.mp4 -acodec copy -vn out.h264

3: Processing raw data
Extract video raw data


-c:v decodes the video, the codec used is rawvideo

-pix_fmt encodes each frame of the image as yuv 4:2:0

ffmpeg -i input.mp4 -an -c:v rawvideo -pix_fmt yuv420p out.yuv

Play video raw data
Extracting audio raw data


-ar means audio read, the audio sampling rate is 44100

-ac means audio channel, ac2 means dual channel

-f The format of the extracted audio pcm data, s16le s means signed, 16 bits, le-little end means little end.

ffmpeg -i out.mp4 -vn -ar 44100 ac 2 -f s16le out.pcm

Play audio raw data

ffplay -ar 44100 -ac 2 -f s16le out.pcm

4: Filter Commands


-vf specifies the filter

crop, the name of a filter, = is followed by a parameter, in_w means the width is reduced by 200, in_h means the height is reduced by 200

-c:v specifies the codec to be used, as mentioned earlier

-c:a copy does not process the audio

ffmpeg -i test.mov -vf crop=in_w-200:in_h-200 -c:v libx264 -c:a copy out.mp4

5: ffmpeg cropping and merging commands
Crop:


-ss crop time point

-t The duration of the cropping, in seconds

ffmpeg -i in.mp4 -ss 00:00:00 -t 10 out.ts

merge:


-f concat means to concatenate the following files

-i specifies the input file. inputs.txt is a file list that specifies the video to be spliced.

out.flv output

ffmpeg -f concat -i inputs.txt out.flv

Among them, the format of the file in inputs.txt is

file '1.mp4' file '2.mp4'

Adding copy will use the current encoding method and will not perform the decoding process, which is faster:

ffmpeg -f concat -i files.txt -c copy output.mp4

6: Image and video conversion commands
Video to Image


-r 1 means transferring one picture per second

-f specifies the output file format, here is image2

image-%3d.jpeg 表示图片名,%3d表示图片编号由3个数字组成。

ffmpeg -i in.flv -r 1 -f image2 image-%3.jpeg

Convert image to video

ffmpeg -i image-%3d.jpeg out.mp4

7: Live push/pull streaming
Live streaming

#-c audio and video codec, -a is audio codec -v is video codec #-f specifies the format
#-re means the frame rate is synchronized with the real frame rate ffmpeg -re -i out.mp4 -c copy -f flv rtmp://server/live/streamName

Live streaming

ffmpeg -i rtmp://server/live.streamName -c copy dump.flv

For more operation methods, please refer to the help. Or browseFFmpeg official documentation

ffmpeg --help

Well, FFmpeg has been installed successfully!

1/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *