This is the third article I participated in novice entry. I have done audio and video related development for a period of time. Just take advantage of this gold digging activity to sort out and record it.
Download and install FFmpeg
1, the official website path and download
Website ffmpeg.org/ github.com/FFmpeg/FFmp…
Download git clone git.ffmpeg.org/ffmpeg.git ffmpeg git clone github.com/FFmpeg/FFmp…
Download the SDL www.libsdl.org/release/
2. Configure instructions
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-videotoolbox --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --cc=clang --host-cflags= --host-ldflags=
Copy the code
3. Installation instructions
sudo make && sudo make install
Copy the code
4. Modify ~/.bash_profile
unset PKG_CONFIG_PATH
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/ffmpeg/lib/pkgconfig
export PATH=$PATH:/usr/local/ffmpeg/bin
Copy the code
Two, FFmpeg common commands
Here are some commonly used FFmpeg commands
1, FFmpeg screen recording command
Ffmpeg -f avfoundation -i 1 -r 30 out. Yuv -f: indicates that avfoundation is used to collect data. -I: indicates which file to collect data fromCopy the code
2. Play videos with ffPlay
ffplay -s 2880x1800 -pix_fmt uyvy422 out.yuv
Copy the code
3. Query the avFoundation device list
ffmpeg -f avfoundation -list_devices true -i ""
Copy the code
4, FFmpeg recording command
Ffmpeg-f avfoundation -i :0 out.wav :0 indicates an audio deviceCopy the code
5. Play sound with ffPlay
ffplay out.wav
Copy the code
6. Multimedia format conversion
Ffmpeg-i out-mp4-vCOdec copy -acodec Copy out-flv -i: input file - vCOdec copy: video encoding processing mode -acodec copy: audio encoding processing mode // Extract video data from file ffmPEG-i out.mp4-an-vcodec copy out.h264 // Extract audio data from file ffmPEG-I out.mp4-acodec copy -vn out.aacCopy the code
7. Ffmpeg extract YUV data
Ffmpeg-i input. Mp4-an-c :v rawvideo-pix_fmt YUv420p out. Yuv-pix_fmt: Pixel formatCopy the code
8. Ffmpeg extract PCM data
Mp4-vn-ar 44100-AC2-F S16LE out. Pcm-ar: Audio sampling rate -AC: Number of audio channels -F: Data storage format S16LE: signed, 16-bit, small enjoinedCopy the code
9. Ffplay plays audio
ffplay -ar 44100 -ac 2 -f s16le out.pcm
Copy the code
Video cropping command
Mpeg-i in.mov-vf crop= in_W-200: in_H-200-c :v libx264-c :a copy out. Mp4-vf: video filter in_W: input video width in_H: Input video height -C :v: video encoder -C :a: audio encoder COPY: no processing. Crop Format: CROP = OUT_W: out_H :x:yCopy the code
11. Ffmpeg audio and video cropping
Ffmpeg-i in. Mp4-ss 00:00:00:00 -t 10 out. Ts-ss: indicates the start time of clippingCopy the code
12. Ffmpeg audio and video merge
Ffmpeg -f concat -i identity.txt out. FLV -f:concat concatenation. TXT: file list in the format of 'file filename'Copy the code
13, FFMPEG video transfer pictures
Ffmpeg-i in.flv-r 1-f image2 image-% 3D.jpeg -r: image2 image-% 3D.jpegCopy the code
14, FFMPEG picture to video
ffmpeg -i image-%3d.jpeg out.mp4
Copy the code
15, live push stream
Ffmpeg - re - I out. FLV mp4 - c copy - f RTMP: / / server/live/streamName - re: slow frame rate of speed, ensure the frame rate synchronization - c: audio and video codec - f: file formatCopy the code
16, live pull stream
ffmpeg -i rtmp://server/live/streamName -c copy dump.flv
Copy the code