From d5a1155f1f08b9b915633c89f1cf43daaa3eb60b Mon Sep 17 00:00:00 2001 From: esche Date: Wed, 26 Jul 2023 23:38:46 +0200 Subject: [PATCH] fixed an bug, when encoding .mkv to .mkv --- to_opus/to_opus.sh | 5 ++++- to_vp9/to_vp9.sh | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/to_opus/to_opus.sh b/to_opus/to_opus.sh index d0424e7..6e6117a 100755 --- a/to_opus/to_opus.sh +++ b/to_opus/to_opus.sh @@ -56,7 +56,10 @@ for file in **/*.@($extension); do # use mkv for videos and for multiple audio streams is_video=$(ffprobe -v error -select_streams V -show_entries stream=codec_type "$file") if [[ ${#channels[@]} -gt 1 || -n "$is_video" ]]; then - ffmpeg -i "$file" -map 0 -map -0:d -map -0:t -c copy -c:a libopus $bitrate_settings-v info -hide_banner "${file%.*}.mkv" && + if [[ ${file: -3} == "mkv" ]]; then + file_out="${file%.*}2.mkv" + else file_out="${file%.*}.mkv"; fi + ffmpeg -i "$file" -map 0 -map -0:d -map -0:t -c copy -c:a libopus $bitrate_settings-v info -hide_banner "$file_out" && if [[ "$delete" = true ]]; then rm "$file"; fi else ffmpeg -i "$file" $bitrate_settings-v info -hide_banner "${file%.*}.opus" && diff --git a/to_vp9/to_vp9.sh b/to_vp9/to_vp9.sh index 4819419..23b3e8c 100755 --- a/to_vp9/to_vp9.sh +++ b/to_vp9/to_vp9.sh @@ -61,13 +61,21 @@ extension="${extension[*]}" extension=${extension// /|} for file in **/*.@($extension); do + if [[ ${file: -3} == "mkv" ]]; then + file_out="${file%.*}2.mkv" + else file_out="${file%.*}.mkv"; fi + + + echo "$encoder" #VP9_vaapi #there are problems with the -global_quality:v/-q:v settings only being able to make quality worse. Help is appreciated #not enough tested. So it is still experimental - #ffmpeg -hide_banner -hwaccel vaapi -vaapi_device $gpu -i "$file" -map 0 -c copy -c:v vp9_vaapi -rc_mode CQP -bf 1 -bsf:v vp9_raw_reorder,vp9_superframe -vf 'hwupload' "${file%.*}.mkv" - + if [[ $encoder == "vp9_vaapi" ]]; then + ffmpeg -hide_banner -hwaccel vaapi -vaapi_device $gpu -i "$file" -map 0 -c copy -c:v vp9_vaapi -rc_mode CQP -bf 1 -bsf:v vp9_raw_reorder,vp9_superframe -vf 'hwupload' "$file_out" + fi + #VP9_qsv #was not able to test it. So it is still experimental #ffmpeg -hide_banner -hwaccel qsv -qsv_device $gpu -i "$file" -c:v av1_qsv -vf 'hwupload' "${file%.*}.mkv"