The background,

I came into contact with FFMPEG by chance, when I transferred the video downloaded from B station to my notebook. Use b station mobile phone client download video format for m4S two files (video.m4s and audio. M4s), need to be converted into ordinary player support MP4 format, to know support audio and video transcoding FFMPEG this powerful open source tools.

Ii. Introduction to software

Ffmpeg supports Windows, Linux and MAC, and is easy to install and use.

Windows:

websiteffmpeg.org/Download, the official website only provides source code, the first learning can be downloaded from Github compiled executable fileGithub.com/BtbN/FFmpeg…, and decompress it to use. The directory results are as follows:

The bin directory contains executable files:

ffmpeg:

Ffmepeg for audio and video transcoding, document address: ffmpeg.org/ffmpeg.html

Enter the bin directory and execute ffmpeg to check whether the installation is successful, as shown below:

To combine audio and video output to MP4, use FFMPEG with the following commands:

M4s -C :v copy-strict experimental output name. Mp4Copy the code

Ffmpeg is mainly operated by commands, such as getting video information:

ffmpeg -i video.avi
Copy the code

Audio format to MP3:

ffmpeg -v error -i input output.mp3
Copy the code

ffplay:

Ffplay for audio and video playback, document address: ffmpeg.org/ffplay.html

ffplay.exe test.mp4
Copy the code

A play window is displayed, as shown in the following figure

ffprobe:

Ffprobe is used to view information about multimedia files. The file address is ffmpeg.org/ffprobe.htm…

ffprobe.exe test.mp4
Copy the code

Obtain the overall audio and video information: The playback duration is 20.35s, starting from 0 seconds, and the rate is 6322KB /s

Some parameters:

-v Log level (value: Error, Warning, info)

-pint_format Output format (value: defalut, CSV, JSON, or XML)

linux:

The rules for using Linux are similar to those for using Windows. The following describes the installation procedure in Linux:

1. Install the Nux Dextop Yum

CentOS does not have an official FFmpeg RPM package. However, we can do this using a third-party YUM source (Nux Dextop).

CentOS 7

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
Copy the code
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
Copy the code

Possible problems:

(1) Lack of dependence

Treatment methods:

rpm -Uvh  http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm 
Copy the code

(2) Command execution error, status code 127

Solution: Shared software shared library

  • Execute the commandvim /etc/ld.so.conf.d/ffmpeg.conf
  • Then add the content ffmpeg to the lib path (such as /root/ffmpeg-lib), save and exit
  • Then run ldconfig for the configuration to take effect

CentOS 6

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
Copy the code
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
Copy the code

2. Install FFmpeg and FFmpeg development package

sudo yum install ffmpeg ffmpeg-devel -y
Copy the code

Java example

Run batch commands in Windows and shell scripts in Linux:

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;

public static void main(String[] args) throws Exception {
    String batPath = "F:\ffmpeg\22e12ea6a66141668d2391d5a6d30b76.bat";
    DefaultExecutor executor = new DefaultExecutor();
    CommandLine line = new CommandLine(batPath);
    executor.execute(line);
}

Copy the code

Bat file contents (that is, commands to be run) :

 E:\ffmpeg\bin\ffmpeg.exe -v error -i F: \ audio \ 1. Aac "" "F: \ audio \ \ ffmpeg \ 1. Mp3." "
Copy the code

Four,

The above content is only a brief introduction to the basic use of FFMPEG software, want to integrate into the company’s products also need some front-end, operation and maintenance knowledge. Searching on the Internet, I found that there are many similar products on the market, integrating most of the document transcoding, and realizing online preview and online play functions. Yongzhong CLOUD service platform is suitable for direct integration into the enterprise production environment, such as enterprise email, OA, etc.