back to home
clip encoding
short piece on my opinions about encoding gameplay videos
clip encoding
video encoding is a mess. i record video game clips from time to time and getting them into a form that i can share with people is annoyingly difficult. real ones will remember the screen recording & transcoding tool i wrote 2 years ago.
the solution i've landed on is storing two copies:
- one for sending over discord or a file host, preferring file size and compatibility over quality
- libx264 for video
- CRF rate control @ quality 23
- 60 FPS
- yuv420p
- slow preset
- libopus for audio
- CBR rate control @ 192 kbit/s
- libx264 for video
- one for remastering eg. in a clip compilation. this copy should retain more details
- libx264 for video
- CRF rate control @ quality 18
- source FPS
- yuv444p
- slow preset
- flac for audio
- libx264 for video
yes, both are h264. this is because h265 sucks, vp9 is too cpu intensive, all av1 encoders have at least one fatal flaw, and h264 plays on anything. while not ideal, this at least gives you a lot more flexibility for transcoding clips into better formats in the future.
here's a bash function i wrote to make encoding clips easier:
encode() {
local input=${1?input file required} output=${2?output prefix required} from=${3?from is required} to=${4?to is required}
shift 4
# sq for sharing
ffmpeg -hide_banner -ss "${from}" -to "${to}" -i "${input}" \
-c:v libx264 -pix_fmt yuv420p -crf 23 -r 60 -preset slow \
-c:a libopus -b:a 192k \
-movflags +faststart "$@" "${output}".mp4
# hq for remastering later
ffmpeg -hide_banner -ss "${from}" -to "${to}" -i "${input}" \
-c:v libx264 -pix_fmt yuv444p -crf 18 -preset slow \
-c:a flac \
-movflags +faststart "$@" "${output}"_hq.mkv
}
youtube notes
it seems that youtube lets you have 4:2:0 8–bit (yuv42p) ONLY for measly, insignificant commoners like us. if you try uploading 10–bit video, it will apply hideous hdr-on-sdr and convert it back down to 8–bit. it does this even at 1440p.