You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
convert265/265_personal

41 lines
2.0 KiB
Bash

#!/bin/bash
set -o pipefail
IFS=$'\n\t'
# You'll want to run this kinda like this...
# find /mnt/ -maxdepth 25 -regex ".*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|avi\|m4v\)" | parallel ./parallel_convert_265 {}
# OR
# parallel 'find {} -type f -name "*.mkv"' ::: /Muninn/TV /Muninn/Movies | parallel --progress ~/convert265/265 {}
# parallel 'find {} -type f -maxdepth 5 -regex ".*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|avi\|m4v\)"' ::: /Muninn/TV /Muninn/Movies | parallel --jobs 2 --progress ~/convert265/265 {}
pro_dir="/opt/amdgpu-pro/etc/vulkan/icd.d"
export LD_LIBRARY_PATH="/opt/amdgpu/libdrm/lib64:/opt/amdgpu/libdrm/lib32:$LD_LIBRARY_PATH"
export VK_ICD_FILENAMES="${pro_dir}/amd_icd32.json:${pro_dir}/amd_icd64.json"
for video; do
d=$(dirname "$video")
filename=$(basename "$video")
extension="${filename##*.}"
filename="${filename%.*}"
video_codec=$(nice -n 19 mediainfo --Inform="Video;%Format%" "${video}")
echo -e "${video} // ${video_codec}"
if [[ ! ${video_codec} =~ "HEVC" ]]; then
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/AVC/x265/g' -e 's/XviD/x265/g')_H265.mkv
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device /dev/dri/renderD128 -analyzeduration 20000000 -probesize 20000000 \
-i "${video}" -map 0:v -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy \
-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920:-2' \
-c:v hevc_vaapi -profile:v main10 \
-c:a copy \
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags \
"/dev/shm/$_filename" || exit 1
mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
if [[ -f "${d}/${_filename}" ]]; then
cmp "${d}/${_filename}" "${video}" || rm -vf "${video}"
fi
fi
done
#-vf 'format=p010,hwupload,scale=1920x1080:flags=lanczos' -c:v hevc_vaapi -profile:v main10 \
#-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920' \
#-c:v hevc_vaapi -profile:v main10 -b:v 15M \