ffmpeg入门程序(ffmpeg入门常用命令分类)
今天我们学常用命令分类中的基本查询命令:
1. 基本查询命令
下面我们看看几个命令
1. version命令2. demuxers 命令 查询所有可支持的解复用格式
- ffmpeg -demuxers
- ffmpeg -demuxers | more 分屏查看 下面是一部分可支持的解复用格式
File formats:
D. = Demuxing supported
.E = Muxing supported
--
D 3dostr 3DO STR
D 4xm 4X Technologies
D aa Audible AA format Files
D aac raw ADTS AAC (Advanced Audio Coding)
D ac3 raw AC-3
D acm Interplay ACM
D act ACT Voice file format
D adf Artworx Data Format
D adp ADP
D ads Sony PS2 ADS
D adx CRI ADX
D aea MD STUDIO audio
D afc AFC
D aiff Audio IFF
D aix CRI AIX
D alaw PCM A-law
D alias_pix Alias/Wavefront PIX image
D alp LEGO Racers ALP
ffmpeg -muxers
ffmpeg -muxers | more
File formats:
D. = Demuxing supported
.E = Muxing supported
--
E 3g2 3GP2 (3GPP2 file format)
E 3gp 3GP (3GPP file format)
E a64 a64 - video for Commodore 64
E ac3 raw AC-3
E adts ADTS AAC (Advanced Audio Coding)
E adx CRI ADX
E aiff Audio IFF
E alaw PCM A-law
E amr 3GPP AMR
E apng Animated Portable Network Graphics
E aptx raw aptX (Audio Processing Technology for Bluetooth)
E aptx_hd raw aptX HD (Audio Processing Technology for Bluetooth)
E asf ASF (Advanced / Active Streaming Format)
E asf_stream ASF (Advanced / Active Streaming Format)
E ass SSA (SubStation Alpha) subtitle
E ast AST (Audio Stream)
E au Sun AU
C 音视频开发学习资料:点击领取→音视频开发(资料文档 视频教程 面试题)(FFmpeg WebRTC RTMP RTSP HLS RTP)
4.devices命令 显示可用的设备
ffmpeg -devices
Devices:
D. = Demuxing supported
.E = Muxing supported
--
D avfoundation AVFoundation input device
D lavfi Libavfilter virtual input device
E sdl,sdl2 SDL2 output device
ffmpeg -codecs
Codecs:
D..... = Decoding supported D表示解码器
.E.... = Encoding supported E表示编码器
..V... = Video codec V:视频编解码
..A... = Audio codec A:音频编解码
..S... = Subtitle codec S:字幕
...I.. = Intra frame-only codec I:帧内预测压缩编码
....L. = Lossy compression L :有损压缩
.....S = Lossless compression S:无损压缩
-------
D.VI.S 012v Uncompressed 4:2:2 10-bit
D.V.L. 4xm 4X Movie
D.VI.S 8bps QuickTime 8BPS video
.EVIL. a64_multi Multicolor charset for Commodore 64 (encoders: a64multi )
.EVIL. a64_multi5 Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5 )
D.V..S aasc Autodesk RLE
D.V.L. agm Amuse Graphics Movie
D.VIL. aic Apple Intermediate Codec
DEVI.S alias_pix Alias/Wavefront PIX image
DEVIL. amv AMV Video
D.V.L. anm Deluxe Paint Animation
我们查找一下264编码
ffmpeg -codecs | grep 264
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (encoders: libx264 libx264rgb h264_videotoolbox )
ffmpeg -formats
File formats:
D. = Demuxing supported
.E = Muxing supported
--
D 3dostr 3DO STR
E 3g2 3GP2 (3GPP2 file format)
E 3gp 3GP (3GPP file format)
D 4xm 4X Technologies
E a64 a64 - video for Commodore 64
D aa Audible AA format files
D aac raw ADTS AAC (Advanced Audio Coding)
DE ac3 raw AC-3
D acm Interplay ACM
D act ACT Voice file format
D adf Artworx Data Format
D adp ADP
D ads Sony PS2 ADS
E adts ADTS AAC (Advanced Audio Coding)
DE adx CRI ADX
D aea MD STUDIO audio
D afc AFC
DE aiff Audio IFF
查看是否支持MP3格式
ffmpeg -formats | grep mp3
DE mp3 MP3 (MPEG audio layer 3)
ffmpeg -bsfs
Bitstream filters:
aac_adtstoasc
av1_frame_merge
av1_frame_split
av1_metadata
chomp
dump_extra
dca_core
eac3_core
extract_extradata
filter_units
h264_metadata
h264_mp4toannexb
h264_redundant_pps
hapqa_extract
hevc_metadata
hevc_mp4toannexb
imxdump
mjpeg2jpeg
mjpegadump
mp3decomp
mpeg2_metadata
mpeg4_unpack_bframes
mov2textsub
noise
null
opus_metadata
pcm_rechunk
prores_metadata
remove_extra
text2movsub
trace_headers
truehd_core
vp9_metadata
vp9_raw_reorder
vp9_superframe
vp9_superframe_split
- 录制屏幕视频 ffmpeg -f avfoundation -i 1 -r 30 out.YUV ffmpeg -f avfoundation -i1 -r 30 -pixel_format yuv420p out.yuv
- 录制音频 ffmpeg -f avfoundation -i :0 out.wav ffmpeg -f avfoundation -i :0 -sample_rate 44100 -channels 2 out.wav ffmpeg -f avfoundation -i :0 -ar 44100 -ac 2 out.wav
- 查找avfoundation库下支持的设备 ffmpeg -f avfoundation -list_devices true -i ""
avfoundation库下支持的设备
[AVFoundation indev @ 0x7fb857609780] AVFoundation video devices:
[AVFoundation indev @ 0x7fb857609780] [0] FaceTime高清摄像头(内建)
[AVFoundation indev @ 0x7fb857609780] [1] Capture screen 0
[AVFoundation indev @ 0x7fb857609780] AVFoundation audio devices:
[AVFoundation indev @ 0x7fb857609780] [0] 外置麦克风
[AVFoundation indev @ 0x7fb857609780] [1] MacBook Pro麦克风
4.播放视频
ffmpeg -video_size 2880x1800 -pixel_format uyvy422 out.yuv
5.播放音频
ffmpeg out.wav
3.分解与复用命令
分解与复用
修改封装格式- 保留编码格式 ffmpeg -i input.mp4 -vcodec copy -acodec copy out.flv
抽取视频
- 保留编码格式 ffmpeg -i input.mp4 -vcodec copy -an outcopy.h264
- 强制格式 ffmpeg -i input.mp4 -vcodec libx264 -an out.h264
C 音视频开发学习资料:点击领取→音视频开发(资料文档 视频教程 面试题)(FFmpeg WebRTC RTMP RTSP HLS RTP)
抽取音频
- 保留编码格式 ffmpeg -i input.mp4 -vn -acodec copy outcopy.aac
- 强制格式 ffmpeg -i input.mp4 -vn -acodec libmp3lame out.mp3
- 数据分辨率和源视频一致 ffmpeg -i input.mp4 out.yuv
- 分辨率转为320x240 ffmpeg -i input.mp4 -video_size 320x240 out.yuv
提取RGB
ffmpeg -i input.mp4 -pixel_format rgb24 out.rgb
RGB和YUV之间的转换
ffmpeg -pixel_format yuv420p -video_size 960x544 -i input.yuv -pixel_format rgb24 out.rgb
抽取PCM
ffmpeg -i input.mp4 -vn -ar 44100 -ac 2 -f s16le out.pcm
播放pcm ffplay -ar 44100 -ac 2 -f s16le out.pcm
4.处理原始数据命令抽取YUV
ffmpeg -i input.mp4 -an -vcodec rawvideo -pixel_format yuv420p out.yuv
抽取PCM
ffmpeg -i input.mp4 -vn -ar 44100 -ac 2 -f s16le out.pcm
5.滤镜命令在学滤镜命令之前 我们先了解一下分解与复用过程
分解与复用
滤镜实际上是对解码后的数据帧进行滤镜处理 过程如下:
裁剪命令
6.裁剪与合并命令
- ffmpeg -i input.mp4 -vf crop=in_w-200:in_h-200 -c:v libx264 -c:a copy out.mp4 crop格式: crop=out_w:out_h:x:y
裁剪命令
- ffmpeg -i input.mp4 -ss 00:00:00 -t 10 out.mp4
合并命令
7. 图片、视频互转命令
- ffmpeg -f concat -i input.txt out.mp4
视频转图片
- ffmpeg -i input.mp4 -r 1 -f image2 image-=.jpeg
图片转视频
直播相关命令 推流命令
- ffmpeg -i image-=.jpeg out.mp4
- ffmpeg -re -i input.mp4 -c copy -f flv rtmp://......
拉流命令
,
- ffmpeg -i rtmp://.... -c copy out.mp4
免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com