FFmpeg environment deployment record under centos7

With more and more video applications on the website, more and more web servers need to support [Video Transcoding] (https://cloud.tencent.com/product/vts?from=10680), video compression, FFmpeg is currently the best web server background transcoding program, the most applications . FFmpeg is a set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams. Use LGPL or GPL license. It provides a complete solution for recording, converting, and streaming audio and video. The following describes the deployment record for FFmpeg under Centos7:

1 ) Install EPEL Release, because the installation needs to use other repo sources, so EPEL support is required
[ root@qd-vpc-op-snapshot01 ~]# yum install -y epel-release 
[ root@qd-vpc-op-snapshot01 ~]# rpm --import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7//If there is a lack of Code prompt, execute this command.[root@qd-vpc-op-snapshot01 ~]# yum repolist            //After the installation is complete, you can check whether the installation is successful 2) Install Nux-Dextop source
[ root@qd-vpc-op-snapshot01 ~]# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro         //Import a Code[root@qd-vpc-op-snapshot01 ~]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm         //Install nux-dextop source[root@qd-vpc-op-snapshot01 ~]# yum repolist      #Check whether the repo source is installed successfully

3 ) Install ffmpeg
[ root@qd-vpc-op-snapshot01 ~]# yum install -y ffmpeg
[ root@qd-vpc-op-snapshot01 ~]# ffmpeg -version
ffmpeg version 2.6.8Copyright(c)2000-2016 the FFmpeg developers
built with gcc 4.8.5(GCC)20150623(Red Hat 4.8.5-4)
configuration:--prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'--enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static--enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil      54.20.100/54.20.100
libavcodec     56.26.100/56.26.100
libavformat    56.25.101/56.25.101
libavdevice    56.4.100/56.4.100
libavfilter     5.11.102/5.11.102
libavresample   2.1.0/2.1.0
libswscale      3.1.101/3.1.101
libswresample   1.1.100/1.1.100
libpostproc    53.3.100/53.3.100

For the follow-up installation, a shell script was specially written for one-click installation**:

[ root@qd-vpc-op-snapshot01 ~]# cat ffmpeg_install.sh
#! /bin/bash
yum install -y vim
yum install -y epel-release
rpm --import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
yum repolist
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
yum repolist
yum update -y
yum install -y ffmpeg
ffmpeg -version

FFmpeg commonly used basic commands

1 ) Separate video and audio streams
ffmpeg -i input_file -vcodec copy -an output_file_video  //Split video stream
ffmpeg -i input_file -acodec copy -vn output_file_audio  //Separate audio stream 2) Video demultiplexing
ffmpeg –i test.mp4 –vcodec copy –an –f m4v test.264
ffmpeg –i test.avi –vcodec copy –an –f m4v test.2643) Video transcoding
ffmpeg –i test.mp4 –vcodec h264 –s 352*278 –an –f m4v test.264//Transcode to original file
ffmpeg –i test.mp4 –vcodec h264 –bf 0 –g 25 –s 352*278 –an –f m4v test.264//Transcode to original file
ffmpeg –i test.avi -vcodec mpeg4 –vtag xvid –qsame test_xvid.avi            //Transcode to package file//-bf B frame number control,-g Key frame interval control,-s Resolution control 4) Video packaging
ffmpeg –i video_file –i audio_file –vcodec copy –acodec copy output_file

5 ) Video cut
ffmpeg –i test.avi –r 1 –f image2 image-%3d.jpeg        //Extract picture
ffmpeg -ss 0:1:30-t 0:0:20-i input.avi -vcodec copy -acodec copy output.avi    //Cut video//-r the frequency of image extraction,-ss start time,-t Duration 6) Video recording
ffmpeg –i rtsp://192.168.3.205:5555/test –vcodec copy out.avi

7 ) YUV sequence playback
ffplay -f rawvideo -video_size 1920x1080 input.yuv

8 ) YUV sequence to AVI
ffmpeg –s w*h –pix_fmt yuv420p –i input.yuv –vcodec mpeg4 output.avi

Description of main common parameters:
- i Set the input stream
- f Set output format
- ss start time
Video parameters:
- b Set the video traffic, the default is 200Kbit/s
- r Set the frame rate, the default is 25-s Set the width and height of the screen
- aspect Set the ratio of the screen
- vn does not process video
- vcodec sets the video codec, if not set, the same codec as the input stream is used
Audio parameters:
- ar set sampling rate
- ac sets the number of sound channels
- acodec sets the sound codec, if not set, the same codec as the input stream is used
- an does not process audio

Recommended Posts

FFmpeg environment deployment record under centos7
PPTP environment deployment record under Centos
[CentOS environment deployment] Java7/Java8 deployment under CentOS
RabbitMQ cluster deployment record under Centos6.9
Elasticsearch cluster deployment record under CentOS7
SFTP dual-machine high availability environment deployment record under Centos
Complete deployment record for LDAP under Centos7.2
Django&MySQL environment deployment under Ubuntu 14.04
Build docker environment under Centos6.5
Centos7.2 deployment vnc service record
Compile FFMPEG source code under CentOS7
Erlang 20.2 installation and deployment under CentOS 7
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos-6.5 installation and deployment of LNMP environment
Zabbix installation and deployment and localization under CentOS
[PHP] Build a PHP operating environment under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Python and scrapy deployment in centos environment
CentOS big data experiment environment change record
Some Centos Python production environment deployment commands
CentOS deployment Harbor
Build Discuz Forum in LNMP Environment under CentOS7
Build LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (detailed tutorial)
Build Dedecms website in LNMP environment under CentOS7
MySQL 8.0 installation and deployment under CentOS, super detailed!
Distributed deployment of Apollo configuration center under CentOS8
Deploy GitBook under CentOS7
Compile Hadoop-2.7.6 under CentOS7.4
CentOS6.7 build LNMP environment
Build a basic environment for Java development under Centos7
Install mysql5.7 under CentOS7
Install FFmpeg on CentOS 8
Hadoop environment construction (centos7)
CentOS server deployment (YUM)
Install ActiveMQ under Centos7
Centos7.6 build LNMP environment
lamp (centos7) installation lamp environment
Install PostgreSQL12 under CentOS7
Centos6.9 install npm environment
Deploy JDK+Tomcat8 under CentOS
Install mysql under Centos 7
Configure lamp under centos6.8
Install Jenkins under Centos 7
Redis3 installation under Centos7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Centos7 configure nodejs environment
Environment configuration of JDK, mysql and tomcat under Centos7
ubuntu environment deployment project
Configure CentOS7 GPU environment
Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment
CentOS 7 build LNMP environment
CentOS7.6 server deployment VNC
Deployment of vulnerability scanning and analysis software Nessus under CentOS
Xen virtualization combat under CentOS 6.6
Centos 7 mini installation process record
Build OpenV** Server under CentOS7
Centos7.4 deployment configuration Elasticsearch5.6 cluster
CentOS 7 install JAVA environment (JDK 1.8)
Build OpenLDAP server under CentOS7
SkyWalking study notes (CentOS environment)