45 lines
815 B
Bash
45 lines
815 B
Bash
# CLI arguments
|
|
input_video=$1
|
|
output_video=$2
|
|
|
|
# Get video pixel format
|
|
video_pix_fmt=$(ffprobe -v error \
|
|
-select_streams v:0 \
|
|
-show_entries stream=pix_fmt \
|
|
-of flat "$input_video" \
|
|
| sed 's/\"//g' \
|
|
| awk -F= '{ print $2 }')
|
|
|
|
# Set transcode profile based on pixel format
|
|
case $video_pix_fmt in
|
|
yuv420p10le)
|
|
video_profile="main444-10"
|
|
;;
|
|
|
|
yuv420p12le)
|
|
video_profile="main444-12"
|
|
;;
|
|
|
|
yuvj420p)
|
|
video_profile="main444-8"
|
|
;;
|
|
|
|
*)
|
|
video_profile="main444-8"
|
|
;;
|
|
|
|
esac
|
|
|
|
# Transcode video
|
|
ffmpeg -v info -hide_banner -i "$input_video" \
|
|
-progress - \
|
|
-nostats \
|
|
-preset medium \
|
|
-c:s copy \
|
|
-c:a copy \
|
|
-c:v libx265 \
|
|
-profile:v $video_profile \
|
|
-crf 27 \
|
|
"$output_video"
|
|
|