====== ffmpeg - Encoding ======
[[ffmpeg:Encoding:GPU Encoding|GPU Encoding]]
----
# Only extract Eng language.
# Set language to Eng for Video.
ffmpeg -i "input.mkv" -map 0:0 -metadata:s:v:0 language=eng -map 0:a:m:language:eng? -map 0:s:m:language:eng? -map 0:d? -map 0:t? -c:v libx265 -crf 23 -c:a copy -c:s copy -threads 8 -bufsize 8M -maxrate 8M "out.mkv"
# Set language to Eng for Audio.
# Set language to Eng for Subs.
# Set language to Eng for Video.
ffmpeg -i "input.mkv" -c:v libx265 -c:a aac -crf 23 -preset fast -metadata:s:v:0 language=eng -metadata:s:a:0 language=eng -map 0:s:m:language:eng? -metadata:s:s:0 language=eng -threads 8 -bufsize 8M -maxrate 8M "0.mkv"
----
===== GPU =====
ffmpeg -vaapi_device /dev/dri/renderD128 -i "input.mkv" -vf 'hwupload,scale_vaapi=w=1920:h=1080:format=nv12' -map 0:v -metadata:s:v:0 language=eng -c:v hevc_vaapi -map 0:a -metadata:s:a:0 language=eng -map 0:s? -metadata:s:s:0 language=eng -rc_mode CQP -global_quality 25 -c:a copy -c:s copy -profile:v main -v verbose output.mkv
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "input.mkv" -map 0:v -metadata:s:v:0 language=eng -map 0:a -metadata:s:a:0 language=eng -map 0:s? -metadata:s:s:0 language=eng -c:v hevc_vaapi -c:a copy -c:s copy -global_quality 28 "output.mkv"
----
===== OLD =====
# Only extract Eng language.
ffmpeg -i "input.mkv" -map 0:v -map 0:a:m:language:eng? -map 0:s:m:language:eng? -map 0:d? -map 0:t? -c:v libx265 -crf 23 -c:a copy -threads 12 -bufsize 4M "out.mkv"
# Set language to Eng for Audio when language of audio is not defined for English.
ffmpeg -i "input.mkv" -map 0:v -map 0:a:m:language:eng? -map 0:a -metadata:s:a:0 language=eng -map 0:s:m:language:eng? -map 0:d? -map 0:t? -c:v libx265 -crf 23 -c:a copy -threads 12 -bufsize 4M "out1.mkv"
----
[[ffmpeg:Encoding:av1|av1]]
[[ffmpeg:Encoding:h264|h264]]
[[ffmpeg:Encoding:h265|h265]]
[[ffmpeg:Encoding:5.1 Audio|5.1 Audio]]
[[ffmpeg:Encoding:Batch encode all files in a directory|Batch encode all files in a directory]]
[[ffmpeg:Encoding:Get the ffmpeg encoders available|Get the ffmpeg encoders available]]
[[ffmpeg:Encoding:Set Language|Set Language]]