Article Directory
YUV data extraction
ffmpeg -i input.mp4 -an -c:v rawvideo -pix_fmt yuv420p out.yuv
-i input file
-an Audio NO
-c: v equal -vcodec
-pix_fmt pixel format
PCM data extraction
ffmpeg -i out.flv -vn -ar 44100 -ac 2 -f s16le out.pcm
-i input file
-vn Video NO
-Ar Audio Sample Rate Read
-ac audio count the number of channels
-f data format s16le s representatives numeral 16 denotes a numerical value represented by each of the 16 le expressed as little end head storage
gensees-iMac:study gensee$ ffmpeg -i out.flv -vn -ar 44100 -ac 2 -f s16le out.pcm
ffmpeg version N-94063-g86f04b918c Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.38)
configuration: --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 --cc=clang --host-cflags= --host-ldflags=
libavutil 56. 29.100 / 56. 29.100
libavcodec 58. 53.100 / 58. 53.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, flv, from 'out.flv':
Metadata:
encoder : Lavf58.27.103
Duration: 00:00:08.13, start: 0.000000, bitrate: 470 kb/s
Stream #0:0: Video: h264 (High 4:2:2), yuv422p(progressive), 1920x1080, 30 fps, 30 tbr, 1k tbn, 60 tbc
Stream #0:1: Audio: aac (HE-AACv2), 44100 Hz, stereo, fltp, 32 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, s16le, to 'out.pcm':
Metadata:
encoder : Lavf58.27.103
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc58.53.100 pcm_s16le
size= 1288kB time=00:00:08.13 bitrate=1296.4kbits/s speed= 203x
video:0kB audio:1288kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
gensees-iMac:study gensee$
Play Audio
ffplay -ar 44100 -ac 2 -f s16le out.pcm
gensees-iMac:study gensee$ ffplay -ar 44100 -ac 2 -f s16le out.pcm
ffplay version N-94063-g86f04b918c Copyright (c) 2003-2019 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.38)
configuration: --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 --cc=clang --host-cflags= --host-ldflags=
libavutil 56. 29.100 / 56. 29.100
libavcodec 58. 53.100 / 58. 53.100
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[s16le @ 0x7fc51b876c00] Estimating duration from bitrate, this may be inaccurate
Input #0, s16le, from 'out.pcm':
Duration: 00:00:07.48, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
5.88 M-A: 0.000 fd= 0 aq= 182KB vq= 0KB sq= 0B f=0/0
gensees-iMac:study gensee$
Filter
Cut - to change the width and height
ffmpeg -i out.flv -vf crop=in_w-200:in_h-200 -c:v libx264 -c:a copy out.mp4
-i input file
-vf video filter chosen here crop filter
in_w in_h width and height representing the video
Add a watermark
ffmpeg -i out.mp4 -vf "movie=timg.jpeg,scale=70x30[watermask];[in][watermask] overlay=30:10 [out]" water.mp4
movie logo specified source
scale size specified logo
overlay specified logo placement
paste it here Piece of the watermark, in the upper left corner of the video
gensees-iMac:study gensee$ ffmpeg -i out.mp4 -vf "movie=timg.jpeg,scale=70x30[watermask];[in][watermask] overlay=30:10 [out]" water.mp4
After using ffplay play water.mp4 you can see the upper left corner there is a watermark
Deleting a watermark
ffplay -i water.mp4 -vf delogo=x=30:y=10:w=70:h=30:show=1 out.flv
Description of delogo filter:
- x, y: coordinates of the top left of the watermark
- Width and height of the watermark: w, h
- show: an optional parameter is 1, a green can be seen, the x, y, w h confirmed rectangular frame, to facilitate debugging. Correct, this parameter can be removed.
- To use delogo filters, compiled ffmpge must add -enable-gpl option. Or you will be prompted when using the
upper-left corner for the watermark position
Audio and video cropping
ffmpeg -i out.flv -ss 00:00:00 -t 10 out.ts
-ss start second start time
-t time the size of the cut, cropped 10s here
Audio and video merge
ffmpeg -f concat -i inputs.txt out.flv
concat represent stitching
input.txt is a list of files, which reads 'file filename' format
if there are two ts files 1.ts 2.ts
then the content is input.txt
file '1.ts'
file '2.ts'
Video pictures Huzhuan
Video to picture
ffmpeg -i out.flv -r 1 -f image2 image-%3d.jpeg
1 frame per second frame rate -r
-f format means the format
After the terminal do you get picture
Pictures turn video
ffmpeg -i image-%3d.jpeg imageOut.mp4
The last 10 drawing to MP4
video after obtained using ffplay play