techtalk 06.11 FFmpeg入门

参考课件

基础

Tools

命令 功能
ffmpeg
ffprobe 查看视频信息
ffplay 视频播放
ffserver 不再维护
功能
libavformat 封装音视频
libavcodec 音视频编解码
libavfilter 视频编辑

Architecture

image

image

封装格式

封装 细节
MP4: MPEG-4 Part 14 container for H.264, H.264, AAC audio, …
MKV: Versatile container for any media format
WebM: Subset of MKV, usage in Web streaming
TS MPEG transport stream
AVI: Legacy container

ffmpeg -formats

编码格式

Currently mostly used, standardized by ITU/ISO:

🎥 H.262 / MPEG-2 Part H: Broadcasting, TV, used for backwards compatibility
🎥 H.264 / MPEG-4 Part 10: The de-facto standard for video encoding today
🎥 H.265 / HEVC / MPEG-H: Successor of H.264, up to 50% better quality
🔊 MP3 / MPEG-2 Audio Layer III: Used to be the de-facto audio coding standard
🔊 AAC / ISO/IEC 14496-3:2009: Advanced Audio Coding standard
Competitors that are royalty-free:

🎥 VP8: Free, open-source codec from Google (not so much in use anymore)
🎥 VP9: Successor to VP8, almost as good as H.265
🎥 AV1: A successor to VP9, claims to be better than H.265

ffmpeg -codecs

Encoders 编码器

🎥 libx264: most popular free and open-source H.264 encoder
🎥 NVENC: NVIDIA GPU-based H.264 encoder
🎥 libx265: free and open-source HEVC encoder
🎥 libvpx: VP8 and VP9 encoder from Google
🎥 libaom: AV1 encoder
🔊 libfdk-aac: AAC encoder
🔊 aac: native FFmpeg AAC encoder
ffmpeg -encoders

encoding with the ffmpeg command line tool

GENERAL SYNTAX

ffmpeg <global-options> <input-options> -i <input> <output-options> <output>

Global options for log output, file overwriting, ...
Input options for reading files
Output options for:
conversion (codec, quality, ...)
filtering
stream mapping

Full help: ffmpeg -h full or man ffmpeg – but it's huge!(10000)

TRANSCODING AND TRANSMUXING

Transcoding from one codec to another (e.g. H.264 using libx264):

ffmpeg -i -c:v libx264 output.mp4
Transmuxing from one container/format to another – without re-encoding:

ffmpeg -i input.mp4 -c copy output.mkv
ffmpeg will take one video, audio, and subtitle stream from the input and map it to the output.

Explanation:

  • -c sets the encoder (see ffmpeg -encoders)
  • -c copy only copies bitstream
  • -c:v sets only video encoders
  • -c:a sets only audio encoders
  • -an and -vn would disable audio or video streams

SEEKING AND CUTTING

Cut a video from timestamp for , or until :

ffmpeg -ss -i -t -c copy
ffmpeg -ss -i -to -c copy
Examples:

ffmpeg -ss 00:01:50 -i -t 10.5 -c copy
ffmpeg -ss 2.5 -i -to 10 -c copy

CRF Control Quality

posted @ 2021-06-11 14:00  小康要好好学习  阅读(100)  评论(0编辑  收藏  举报