2023-08-31, 04:02 AM
I am enjoying reading this discussion and if anyone is interested would like to share the scripts I use to convert files to 720/1080 HEVC for things I dont really care about (like wife's reality tv...)
These two scripts will look for supported file types and then convert them to the following settings, I could make it more precise like OPs (look for mkv or mp4 or whatever only) but this works for me well enough.
Also this is not using FFMPEG, but a custom packaged version of handbrake-CLI with intel gpu drivers built in (for *unix distro)
I also have a script where you can input whatever you want as values (for when I want to do anything custom)
These two scripts will look for supported file types and then convert them to the following settings, I could make it more precise like OPs (look for mkv or mp4 or whatever only) but this works for me well enough.
Also this is not using FFMPEG, but a custom packaged version of handbrake-CLI with intel gpu drivers built in (for *unix distro)
Code:
#!/bin/bash
#folder where files area located to be converted
rootfolder="*******"
#folder where file will be save
savefolder="*********"
echo "#####################################"
echo "Files must be located in $rootfolder"
echo "Supported file types in folder will be converted to 720p HEVC 10bit @ 1000kbps, with a CFR value of 21 using opus audio codec at 80kbps including all subtitles in the mkv file format"
echo "If file or file type is not supported it will just be skipped"
echo "After completion, all files will be located in the $savefolder"
echo "#####################################"
#Handbrake using qsv 10bit hevc with 80kbs OPUS stereo audio including all subtitles
for file in "$rootfolder"*
do
echo -e "The following file will be converted \e[36m$(basename "$file")\e[m"
final="$(basename "$file")"
finalclean="${final%.*}"
save="$savefolder$finalclean-mau5.mkv"
echo -e "File will be saved as \e[35m$finalclean-mau5.mkv\e[m and saved to \e[36m$savefolder\e[m"
sleep 5
flatpak run --command=HandBrakeCLI fr.handbrake.ghb --enable-qsv-decoding --encoder qsv_h265_10bit --width 1280 --height 720p --vb 1000 --no-multi-pass --vfr --cfr 21 --format av_mkv --aencoder opus --ab 80 --mixdown stereo --all-subtitles --input "$file" --output "$save"
done
#echo -e "finish converting \e[35m$save\e[m"
Code:
#folder where files area located to be converted
rootfolder="******************"
#folder where file will be save
savefolder="*****************"
echo "#####################################"
echo "Files must be located in $rootfolder"
echo "Supported file types in folder will be converted to 1080p HEVC 10bit @ 2500kbps, with a CFR value of 23 using 5.1 OPUS audio codec at 160kbps including all subtitles in the mkv file format"
echo "If file or file type is not supported it will just be skipped"
echo "After completion, all files will be located in the $savefolder"
echo "#####################################"
#Handbrake using qsv 10bit hevc with 80kbs OPUS stereo audio including all subtitles
for file in "$rootfolder"*
do
echo -e "The following file will be converted \e[36m$(basename "$file")\e[m"
final="$(basename "$file")"
finalclean="${final%.*}"
save="$savefolder$finalclean-mau5.mkv"
echo -e "File will be saved as \e[35m$finalclean-mau5.mkv\e[m and saved to \e[36m$savefolder\e[m"
sleep 5
flatpak run --command=HandBrakeCLI fr.handbrake.ghb --enable-qsv-decoding --encoder qsv_h265_10bit --width 1920 --height 1080 --vb 2500 --no-multi-pass --vfr --cfr 21 --format av_mkv --aencoder opus --ab 160 --mixdown 5point1 --all-subtitles --input "$file" --output "$save"
done
#echo -e "finish converting \e[35m$save\e[m"
I also have a script where you can input whatever you want as values (for when I want to do anything custom)
Code:
#folder where files area located to be converted
rootfolder="/mnt/Chun-Li/._convert/"
#folder where file will be save
savefolder="/mnt/Chun-Li/._converted/"
echo "#####################################"
echo "Supported file types in folder will be converted to whatever audio/video options specified with all included subtitles"
echo "If file or file type is not supported it will just be skipped"
echo "After completion, all files will be located in the $savefolder"
echo "#####################################"
echo -e "\e[31mVideo options\e[m"
echo " "
# width="USER INPUT"
read -p "Width of the video? " width
echo -e "You entered \e[32m$width\e[m"
# height="USER INPUT"
read -p "Height of the video? " height
echo -e "You entered \e[32m$height\e[m"
# videobitrate="USER INPUT"
read -p "What video bitrate (in kbps)? " videobitrate
echo -e "You entered \e[32m$videobitrate\e[m"
# cfr="USER INPUT"
read -p "What CFR value (21 default, RF 19-23 for 720p, RF 20-24 for 1080p, RF 22-28 for 2160p)? " cfr
echo -e "You entered \e[32m$cfr\e[m"
echo "###################################"
echo -e "\e[31mAudio Options\e[m"
echo " "
# audiocodec="USER INPUT"
read -p "What audio codec (opus, av_aac, ac3, eac3, copy:)? " audiocodec
echo -e "You entered \e[32m$audiocodec\e[m"
# audiobitrate="USER INPUT"
read -p "What audio bitrate (in kbps)? " audiobitrate
echo -e "You entered \e[32m$audiobitrate\e[m"
# audioformat="USER INPUT"
read -p "How many channel audio? (mono, stereo, dpl1, dpl2, 5point1, 7point1)? " audioformat
echo -e "You entered \e[32m$audioformat\e[m"
echo "###################################"
echo ""
echo -e "All files saved to \e[36m$savefolder\e[m"
echo -e "All files will be converted to mkv"
#Handbrake using qsv 10bit hevc with 80kbs OPUS stereo audio including all subtitles
for file in "$rootfolder"*
do
echo -e "The following file will be converted \e[36m$(basename "$file")\e[m"
final="$(basename "$file")"
finalclean="${final%.*}"
save="$savefolder$finalclean-mau5.mkv"
echo " "
echo -e "File will be saved as \e[35m$finalclean-mau5.mkv\e[m and saved to \e[36m$savefolder\e[m"
sleep 5
flatpak run --command=HandBrakeCLI fr.handbrake.ghb --enable-qsv-decoding --encoder qsv_h265_10bit --width "$width" --height "$height" --vb "$videobitrate" --cfr "$cfr" --no-multi-pass --vfr --format av_mkv --aencoder "$audiocodec" --ab "$audiobitrate" --mixdown "$audioformat" --all-subtitles --input "$file" --output "$save"
echo " "
echo -e "Finished converting \e[35m$finalclean\e[m with a resolution of \e[32m$width\e[m x \e[32m$height\e[m with a bitrate of \e[32m$videobitrate\e[mkbps using the \e[32m$audiocodec\e[m audio codec at a bitrate of \e[32m$audiobitrate\e[mkbps in \e[32m$audioformat\e[m sound to folder \e[35m$savefolder\e[m."
echo " "
echo "###################################"
echo " "
done
#echo -e "finish converting \e[35m$save\e[m"