FFMPEG 基本概念
- CODEC: code, decode
- Container: file format, such as flv, mkv, avi
- Stream: audio, video, cc, …
- Freame: I P B
- Mux / Demux
- fps
- bps
ffmpeg
- 查询 h264 解码器:
ffmpeg -decoders | grep h2641
2VFS..D h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
V....D libopenh264 OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
查询 h264 编码器
ffmpeg -encoders | grep h2641
2
3
4V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V....D libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
V....D libopenh264 OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V....D h264_videotoolbox VideoToolbox H.264 Encoder (codec h264)转码示例 cpu
./ffmpeg -i ~/Downloads/a.MOV -acodec aac -ar 12000 -ab 32 -s 360x640 -qscale 6 b.mp4gpu
./ffmpeg -hwaccel videotoolbox -c:v libopenh264 -i ~/Downloads/a.MOV -c:v hevc_videotoolbox -acodec aac -ar 12000 -ab 32k -s 360x640 -qscale 6 b.mp4use gpu convert hevc to h264
./ffmpeg -hwaccel videotoolbox -c:v hevc -i ~/Downloads/a.MOV -c:v h264_videotoolbox -acodec aac -ar 24000 -ab 8k -s 720x1280 -r 12 -b 1m b.mp4
ffprobe
https://ffmpeg.org/ffprobe.html
- check the format of the container used by a multimedia stream
- check the format of and type of each media stream contained in a multimedia stream
Notice Note
- can check url
- defalut output is stdout
- output format is specified by the
print-format
option
SI unit?
Stream spedifiers
example:
1
2
3// `-codec:a:1 ac3`, `a:1` matches the 2nd audio stream
// `-b:a 128k`, `-b:a` matches all audio streams
// no stream specifier matches all streamsstream_index, stream numbering is based on the order of the streams as detected by
libavformat
except when a program ID is also specifiedstream_type[:additional_stream_specifier]:
v
orV
for videoa
for audios
for subtitled
for datat
for attachments
Note:v
matches all video streams,V
only matches video streams which are not attached pritures, video thumbnails or cover arts- if additional_stream_specifier is used, then it matches streams which both have this type and match the additional_stream_specifier
p:program_id[:additional_steam_specifier]
#stream_id or i:stream_id: e.g. PID in MPEG-TS container
m:key[:value], matches streams with the metadata tag key having the specified value
u, matches streams with usable configuration, the codes must be defined and the essential information such as video dimension or audio sample rate must be present.
Note: inffmpeg
, matching by metadata will only work properly for input files.bsf: bitstream_filter
ffprobe 示例
ffprobe [input source]
output:
1 | Metadata: |