clip encoding

short piece on my opinions about encoding gameplay videos

written
2025-07-15T01:00:00Z
last modified
2025-07-16T01:05:32Z
tags
link
back to home

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:

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.