From 16ea4823234365fbf1949fc603de33b89d0934d1 Mon Sep 17 00:00:00 2001 From: Arsimael Inshan Date: Wed, 2 Feb 2022 18:00:05 +0100 Subject: [PATCH] Batchconvert --- Linux Desktop scripts/batch_convert.sh | 80 ++++++++++++++++++++++++++ test.sh | 10 ++++ 2 files changed, 90 insertions(+) create mode 100755 Linux Desktop scripts/batch_convert.sh create mode 100755 test.sh diff --git a/Linux Desktop scripts/batch_convert.sh b/Linux Desktop scripts/batch_convert.sh new file mode 100755 index 0000000..d551d7a --- /dev/null +++ b/Linux Desktop scripts/batch_convert.sh @@ -0,0 +1,80 @@ +#!/bin/bash +BASEFOLDER_SOURCE="/path/to/source" +BASEFOLDER_DESTIN="/path/to/destination" +FOLDERS_TO_SCAN=( + "Folder" + "Folder 2" + "Also a Folder" +) +GPU=nv #Which Hardware to use? nv = nvidia, amd = amdgpu; intel = intel qsv; cpu = CPU encoding + +#---------- NO EDIT BELOW HERE ---------- +BFSL=$(expr length ${BASEFOLDER_SOURCE}) +BFSL=$((BFSL + 1)) + +ffmpeg_input_opts_amd=( + -init_hw_device vaapi=amdgpu:/dev/dri/renderD128 + -hwaccel vaapi + -hwaccel_output_format vaapi + -hwaccel_device amdgpu +) + +ffmpeg_output_opts_amd=( + -vaapi_device /dev/dri/renderD128 + -map 0 + -c:v hevc_vaapi + -c:a copy + -c:s copy + -vtag hvc1 +) + +ffmpeg_input_opts_nv=( +) + +ffmpeg_output_opts_nv=( + -map 0 + -c:s copy + -c:a copy + -c:v hevc_nvenc +) + +ffmpeg_input_opts_intel=( + -hwaccel qsv +) + +ffmpeg_output_opts_intel=( + -map 0 + -c:v hevc_qsv + -c:a copy + -c:s copy +) + +for i in "${FOLDERS_TO_SCAN[@]}"; do + find ${BASEFOLDER_SOURCE}/"${i}" -type f >temp.txt + while IFS= read -r LINE; do + SPATH=$(dirname "${LINE}") + DPATH="${BASEFOLDER_DESTIN}$(cut -c${BFSL}- <<<${SPATH})" + FILE="$(basename "${LINE}")" + if [ ! -d "${DPATH}" ]; then mkdir -p "${DPATH}"; fi + + case ${GPU} in + nv) + echo -n "Using nVidia cuda" + ffmpeg ${ffmpeg_input_opts_nv[@]} -i "${SPATH}/${FILE}" ${ffmpeg_output_opts_nv[@]} "${DPATH}/${FILE}" + ;; + amd) + echo -n "using AMDGPU" + ffmpeg ${ffmpeg_input_opts_amd[@]} -i "${SPATH}/${FILE}" ${ffmpeg_output_opts_amd[@]} "${DPATH}/${FILE}" + ;; + intel) + echo -n "Using Intel QSV" + ffmpeg ${ffmpeg_input_opts_intel[@]} -i "${SPATH}/${FILE}" ${ffmpeg_output_opts_intel[@]} "${DPATH}/${FILE}" + ;; + *) + echo -n "Using CPU encoding" + ;; + esac + + done < temp.txt + rm temp.txt +done \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..734cc4f --- /dev/null +++ b/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +VARIABLES=("Deine Mudda" "path/to/heacehn" "/mimiu haha/ficköön") +for i in "${VARIABLES[@]}"; do + echo ${i} + echo ${i/'path/to'/nix} | cut -c5- + +done + +