Skip to main content

ffmpeg

OptionDescription
-encodersshow available encoders
-h encoder=<encoder>show help about the <encoder>
-h decoder=<decoder>show help about the <decoder>
-hide_bannerhide banner

Input

  • place option before -i
OptionDescription
-vsync 0prevent duplicate and extra frames (fix sync issue?)
-i <URL>Input stream

Output

  • place option before <output URL>
OptionDescription
-c:a <codec>Select audio encoder
-c:v <codec>Select video encoder
-c <codec>Select encoder

Codec

  • copy

Bit Rate

CBR

Constant Bit Rate

VBR

Variable Bit Rate

CRF

Constant Rate Factor

Ref

  • Good for offline video
  • Recommended CRF ≈ 20 ~ 30

AVC

Advanced Video Coding

  • H.264

HEVC

High Efficiency Video Coding

  • H.265

Video Encoder

libx264

Software H.264

h264_nvenc

NVIDIA NVENC H.264 encoder

libx265

Software H.265

OptionDescription
-crf <CRF>Constant Rate Factor

hevc_nvenc

NVIDIA NVENC HEVC encoder

  • -preset {slow|medium|fast|p1|...|p7}
    • p1 fastest
    • p7 slowest

Hardware accelerator

Ref

OptionDescription
-hwaccel cudachooses appropriate hw accelerator
-hwaccel_output_format cudakeeps the decoded frames in GPU memory

Pixel format

Ref

Show pixel format

ffmpeg -pix_fmts

Common format

OptionDescription
-vf format=<format>set pixel format
yuv420p8-bit 4:2:0
yuv420p10le10-bit 4:2:0

Extract subtitle

ffmpeg -an -vn -i <video.mkv> -map 0:s:0 <sub.srt>
OptionDescription
-an -vnno audio, no video (faster)
-map 0the first input
:ssubtitle
:s:0the first subtitle