Introduction 1. FFmepg
ffmepg is an audio and video development tools.
It can be set for recording, processing a digital audio, video, and converts it into the open frame stream. Using LPL, GPL licensing system, provides the recording, a complete solution to convert and stream audio and video.
1.1 Command-Line Tools Overview
The following are some basic commands when FFmepg use, is the most basic content, we are not too familiar with FFmpeg inside the code is written, as we just call:
ffmpge -i input.avi -r 24 output.avi
You can put input.avi the frame rate becomes 24, output 24fps video is output.avi
- ffmpeg
various functions comprising the FFmpeg, such as gif, format conversion, theme, like codecs - ffmpeg -all
contains ffmpeg and ffmpeg tool assembly - ffplay
a FFmpeg and SDL library using simple, portable media player - ffplay-all
comprising fflpay tool assembly and ffmpeg - ffprobe
to display information about multimedia file - ffprobe-all
comprising ffprobe tool assembly and FFmpeg - ffserver
related streaming service responds to the client streaming request, the streaming media data transmitted to the client - ffserver-all
comprising ffserver tool assembly and FFmpeg
1.2 Component Overview
- Utilities
General of features and tools offered libavutils - Video scaling and pixel format converter
video scaling and pixel format converter - Audio resampler
audio resampling - Encoders and decoders
for encoding and decoding - Bitstream filters
Stream filters - Muxers and demuxers
data and data separation Synthesis - Protocols
agreement - Input and output devices
input and output devices - Filters
filter
1.3 Class Library Overview
- libavutil
contains some common utility functions - libswscale
for scaling the video scene, a color conversion mapping, image color format conversion control or - libswresample
original audio format transcoding - libavcodec
various types sound / image transcoding, audio and video coding is the library core library - libavformat
used to generate and parse the various audio and video formats package. - libavdevice
acquisition hardware, acceleration, display. - libavfilter
audio and video filter development. - libavresample
audio and video codecs default encapsulation and the like. - libpostproc
for post effect processing, such as image deblocking
1.4 Overview document
- Frequently Asked Questions
Frequently Asked Questions - Support External Libraries, Formats, Codecs or Features
support for extensions, formats, codecs or properties - Platform Specific Information
Platform-specific information - Developer Documentation
Developer Overview - Git How-To
Git - Automated Testing Enviroment FFmpeg
FFmpeg automated test environment.
2. In Windows10, NDK under r20 compile FFmpeg
In Windows compile FFmpeg need tools MSYS2
and Yasm
MSYS2 integrated Pacman, MinGW-w64 is Cygwin
an upgraded version of Download at: MSYS2 Download
Yasm is an assembler. In the address: yasm Download , download the corresponding .exe
file after downloading to put under the Windows \ System32 folder on the line.
About After installing MSYS2, you need to configure something, to see the focus of this Blog: msys2 in windows10 compiled install ffmpeg + x265
As 265 can be considered first installed.
In this place (use WIN10 compilation) I stepped on countless pit, took a few days to rest finally compiled out.
I stepped here to list all the pit:
- Books, online method is too old to compile
the book, used the online FFmpeg, ndk are relatively old, such as FFmpeg is 3.xx, ndk or r10 r12 is
the new version of ndk is r20, ffmpeg is 4.2
their difference is that the old version of the gcc compiler, the new version must use clang compiler. - About msys2
It is a command-line tool that you can use./
to perform the file, its role and terminal linux, like, very powerful
we use it to compile ffmpeg. - When using clang, going to change the configure file, but also the old version, but the old and the new reform law has been completely different.
Here is not to explore why how how to change. Specific can refer to this article (totally ok): compile FFmpeg the clang
2.1 Editing configure file
Under the first purpose: to use after ffmpeg4 clang compiler to compile, but it does not have a program specifically for clang statement, which results in its configuration file if we do not add some statements clang of the next, we will lead the latter to compile ffmpeg unsuccessful.
First found in the ffmpeg configure the file, open with a text.
Find --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
his party in its following:
--corss-prefix-clang=PREFIX use PREFIX for compilation clang tools [$cross_prefix]
Then find CMDLINE_SET="..... corss_prefix
beneath it add the line:
cross_prefix_clang
Then find
set_default target_os
if test "$target_os" = android; then
cc_default="clang"
fi
ar_default="${cross_prefix}${ar_default}"
cc_default="${cross_prefix}${cc_default}"
cxx_default="${cross_prefix}${cxx_default}"
nm_default="${cross_prefix}${nm_default}"
pkg_config_default="${cross_prefix}${pkg_config_default}"
Replaced by:
set_default target_os
if test "$target_os" = android; then
cc_default="clang"
cxx_default="clang++"
fi
ar_default="${cross_prefix}${ar_default}"
cc_default="${cross_prefix_clang}${cc_default}"
cxx_default="${cross_prefix_clang}${cxx_default}"
nm_default="${cross_prefix}${nm_default}"
pkg_config_default="${cross_prefix}${pkg_config_default}"
Save the file, use ffmpeg msys2 into the root directory of execution ./configure
to run side profile
2.2 build_android.sh script writing
Create a directory named in the root temp
folder as a temporary file during compilation.
In the root directory ffmpeg write a script called build_android.sh
, used to compile ffmpeg.
Inside editor (see note Notes):
#!/bin/bash
make clean
#指定ndk路径
export NDK=C:/Users/msn/AppData/Local/Android/Sdk/ndk-bundle
#指定ffmpeg路径
export FFMPEG=C:/Users/msn/Desktop/ffmpeg-4.2.1
#指定临时文件夹
export TMPDIR=$FFMPEG/temp
#指定sysroot
export SYSROOT=$NDK/toolchains/llvm/prebuilt/windows-x86_64/sysroot
#指定平台
export PLATFORM=$NDK//toolchains/llvm/prebuilt/windows-x86_64
#指定cpu(如果用clang编译,必须指定cpu为armv7-a)
export CPU=armv7-a
#指定产出文件
export PREFIX=C:/Users/msn/Desktop/ffmpeg-4.2.1/android/$cpu
function build
{
./configure \
--prefix=$PREFIX \
--target-os=android \
--arch=$CPU \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-avdevice \
--disable-symver \
--enable-cross-compile \
--sysroot=$SYSROOT \
--cross-prefix=$PLATFORM/bin/arm-linux-androideabi- \
#指定为android28编译,当然也可以把28换成16以上的其他数字
--cross-prefix-clang=$PLATFORM/bin/armv7a-linux-androideabi28- \
--extra-cflags="-I$SYSROOT/usr/include" \
--extra-ldflags="-L$SYSROOT/usr/lib" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make -j2
make install
}
build
After editing save.
Operates under the root directory of ./build_android
the result after the operation, will see output files in the directory:
what's inside is the result after compilation.