Skip to content

Instantly share code, notes, and snippets.

@daydreamer-json
Last active July 30, 2023 06:51
Show Gist options
  • Save daydreamer-json/8e0f2bf2025db209a9727ad4f2dd983a to your computer and use it in GitHub Desktop.
Save daydreamer-json/8e0f2bf2025db209a9727ad4f2dd983a to your computer and use it in GitHub Desktop.
gi_cutscn_new Transcoding Command

FFmpeg commands used

Encode video

1080p HEVC (no-resize)

HEVC (NVEnc), Spatial / Temporal AQ, B-frames=3, GOP=60, YUV 4:2:0, BT.709
Constant Quality Mode, Min=14, Avg=16, Max=24

ffmpeg -hide_banner -hwaccel nvdec -i "{input}" -map 0:v:0 -tag:v hvc1 -c:v hevc_nvenc -preset 16 -tune 1 -profile:v 0 -tier 0 -spatial_aq 1 -temporal_aq 1 -b_ref_mode 1 -bf 3 -g 60 -cq 16 -qmin 14 -qmax 24 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -an "{output}"

720p HEVC (resize)

HEVC (NVEnc), Spatial / Temporal AQ, B-frames=3, GOP=60, YUV 4:2:0, BT.709
Lanczos Resizer (CUDA)
Constant Quality Mode, Min=20, Avg=20, Max=32

ffmpeg -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i "{input}" -map 0:v:0 -tag:v hvc1 -c:v hevc_nvenc -vf "scale_cuda=1280:720:interp_algo=lanczos" -preset 16 -tune 1 -profile:v 0 -tier 0 -spatial_aq 1 -temporal_aq 1 -b_ref_mode 1 -bf 3 -g 60 -cq 20 -qmin 20 -qmax 32 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -an "{output}"

480p, 360p, 240p HEVC (resize)

HEVC (NVEnc), Spatial / Temporal AQ, B-frames=3, GOP=60, YUV 4:2:0, BT.709
Bicubic Resizer (CUDA)
Constant Quality Mode, Min=20, Avg=20, Max=32

ffmpeg -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i "{input}" -map 0:v:0 -tag:v hvc1 -c:v hevc_nvenc -vf "scale_cuda=1280:720:interp_algo=bicubic" -preset 16 -tune 1 -profile:v 0 -tier 0 -spatial_aq 1 -temporal_aq 1 -b_ref_mode 1 -bf 3 -g 60 -cq 20 -qmin 20 -qmax 32 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -an "{output}"

Encode audio

FLAC (Lossless)

flac -f --delete-input-file -V -l 12 -b 4608 -m -r 8 -A subdivide_tukey(5)

AAC 256kbps

qaac64 --cvbr 256 -q 2 --rate keep --no-delay --gapless-mode 0 --threading

AAC 128kbps

qaac64 --cvbr 128 -q 2 --rate keep --no-delay --gapless-mode 0 --threading

Build HLS playlist / segment

Video / Audio

ffmpeg -hide_banner -i "{input}" -c:v copy -tag:v hvc1 -an -f hls -hls_time 4 -hls_playlist_type vod -hls_segment_type fmp4 -hls_fmp4_init_filename "segment/{inputName}/init.mp4" -hls_base_url "segment/{inputName}/" -hls_segment_filename "variant/vid/{resolutionLevel}/segment/{inputName}/%08d.m4s" "variant/vid/{resolutionLevel}/{inputName}.m3u8"

Generate thumbnail

ffmpeg -hwaccel nvdec -hide_banner -i "{input}" -vf "fps=4,thumbnail=3000000" -frames:v 1 "{inputName}.png"
magick convert -resize 960x540 "{input}" "{output}"
magick convert -resize 640x360 "{input}" "{output}"
cjpeg -quality 85 -optimize -progressive -outfile "{inputName}.jpg" "{inputName}.png"
cwebp -q 85 -m 6 -mt "{inputName}.png" -o "{inputName}.webp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment