mirror of https://gitlab.com/hsmalley/convert265
Cleanup Time
parent
3cf578d04a
commit
108c3bf3d5
@ -1,35 +1,118 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu/
|
|
||||||
|
|
||||||
for video; do
|
pro_dir="/opt/amdgpu-pro/etc/vulkan/icd.d"
|
||||||
d=$(dirname "$video")
|
export LD_LIBRARY_PATH="/opt/amdgpu/libdrm/lib64:/opt/amdgpu/libdrm/lib32:$LD_LIBRARY_PATH"
|
||||||
filename=$(basename "$video")
|
export VK_ICD_FILENAMES="${pro_dir}/amd_icd32.json:${pro_dir}/amd_icd64.json:$VK_ICD_FILENAMES"
|
||||||
extension="${filename##*.}"
|
|
||||||
|
function get_subtitles() {
|
||||||
|
# Try to get english subs if not then get all of them
|
||||||
|
jq -r '.streams[] | select(.codec_type=="subtitle") | select(.tags.language | contains("en")) | .index' <"${video}.json" ||
|
||||||
|
jq -r '.streams[] | select(.codec_type=="subtitle") | .index' <"${video}.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
function getinfo() {
|
||||||
|
if [[ ! -f "${video}.json" ]]; then
|
||||||
|
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
||||||
|
fi
|
||||||
|
d=$(dirname "${video}")
|
||||||
|
filename=$(basename "${video}")
|
||||||
filename="${filename%.*}"
|
filename="${filename%.*}"
|
||||||
audio_codec=$(mediainfo --Inform="Audio;%Format%" "${video}")
|
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
||||||
video_codec=$(mediainfo --Inform="Video;%Format%" "${video}")
|
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
||||||
attachment=$(mediainfo --Inform="General;%Attachments%" "${video}")
|
sub_indexes=$(get_subtitles)
|
||||||
video_width=$(mediainfo --Inform="Video;%Width%" "${video}")
|
video_size=$(stat -c%s "${video}")
|
||||||
color_primaries=$(mediainfo --Inform="Video;%colour_primaries%" "${video}")
|
video_size_50=$((video_size * 50 / 100))
|
||||||
echo -e "${video} // ${video_codec} // ${audio_codec} // ${video_width} // ${attachment} // ${color_primaries}"
|
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/AVC/x265/g' -e 's/XviD/x265/g')
|
||||||
if [[ -f "${d}/poster.jpg" ]]; then
|
echo -e "${video} // ${video_codec} // ${video_height} // ${video_size}"
|
||||||
poster="${d}/poster.jpg"
|
}
|
||||||
elif [[ -f "${d}/${filename}.jpg" ]]; then
|
|
||||||
poster="${d}/${filename}.jpg"
|
function extract_subtitles() {
|
||||||
else
|
for subtitle in ${sub_indexes}; do
|
||||||
poster=""
|
nice -n 18 ffmpeg -hide_banner -loglevel error -n -threads 4 -i "${video}" -map "0:${subtitle}" "${video}_${subtitle}.srt"
|
||||||
fi
|
done
|
||||||
if [[ ! ${video_codec} =~ "HEVC" ]] || [[ ! ${audio_codec} =~ "Opus" ]]; then
|
}
|
||||||
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/XviD/x265/g' -e 's/AAC/Opus/g' -e 's/DTS/Opus/g' -e 's/EAC3/Opus/g' -e 's/AC3/Opus/g' -e 's/TrueHD/Opus/g' -e 's/Vorbis/Opus/g' -e 's/Atmos//g').mkv
|
|
||||||
#-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 6 \
|
function convert_video_memory() {
|
||||||
~/convert265/tools/ffmpeg -hide_banner -loglevel info -y -hwaccel auto -analyzeduration 20000000 -probesize 20000000 \
|
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_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 \
|
-i "${video}" -map 0:v -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy \
|
||||||
-c:v hevc_nvenc -rc-lookahead 30 -surfaces 64 -qmin 0 -qmax 24 -profile:v main10 -preset p7 -tune hq -multipass 1 \
|
-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920:-2' -c:v hevc_vaapi -profile:v main10 \
|
||||||
-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 6 \
|
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/${_filename}.mkv" || exit 1
|
||||||
-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}.mkv"
|
||||||
cmp "/dev/shm/${_filename}" "${video}" || rm -vf "${video}"
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
|
if ((file_size >= video_size_50)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_video_audio_problems() {
|
||||||
|
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_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 \
|
||||||
|
-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 2 \
|
||||||
|
-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920:-2' -c:v hevc_vaapi -profile:v main10 \
|
||||||
|
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "${d}/${_filename}.mkv" || exit 1
|
||||||
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
|
if ((file_size >= video_size_50)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_video() {
|
||||||
|
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_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 -c:a copy \
|
||||||
|
-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920:-2' -c:v hevc_vaapi -profile:v main10 \
|
||||||
|
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "${d}/${_filename}.mkv" || exit 1
|
||||||
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
|
if ((file_size >= video_size_50)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_video_qsv_memory() {
|
||||||
|
nice -n 19 ~/Downloads/ffmpeg/ffmpeg -hide_banner -loglevel quiet -y -threads 4 -hwaccel qsv -hwaccel_output_format qsv -analyzeduration 20000000 -probesize 20000000 \
|
||||||
|
-i "${video}" -map 0:v:0 -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy \
|
||||||
|
-c:v hevc_qsv -low_power false -preset 4 -profile:v 1 -scenario 3 -look_ahead 1 -global_quality 20 \
|
||||||
|
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/${_filename}.mkv" || exit 1
|
||||||
|
mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}.mkv"
|
||||||
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
|
if ((file_size >= video_size_50)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_video_qsv() {
|
||||||
|
nice -n 19 ~/Downloads/ffmpeg/ffmpeg -hide_banner -loglevel quiet -y -threads 4 -hwaccel qsv -hwaccel_output_format qsv -analyzeduration 20000000 -probesize 20000000 \
|
||||||
|
-i "${video}" -map 0:v:0 -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy \
|
||||||
|
-c:v hevc_qsv -low_power false -preset 4 -profile:v 1 -scenario 3 -look_ahead 1 -global_quality 20 \
|
||||||
|
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "${d}/$_filename.mkv" || exit 1
|
||||||
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
|
if ((file_size >= video_size_50)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function remux_video() {
|
||||||
|
extract_subtitles
|
||||||
|
ffmpeg -hide_banner -loglevel info -y -threads 4 -i "${video}" -c: copy -movflags +faststart -movflags use_metadata_tags "${d}/${_filename}.mp4" || exit 1
|
||||||
|
find "${d}" -size 0 -delete
|
||||||
|
file_size=$(stat -c%s "${d}/${_filename}.mp4")
|
||||||
|
if ((file_size >= video_size)); then
|
||||||
|
cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
find "${d}" -size 0 -delete
|
||||||
|
rm -vf "${video}" "${video}.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
for video; do
|
||||||
|
getinfo
|
||||||
|
if [[ ${video_codec} =~ "av1" ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; then
|
||||||
|
convert_video_qsv
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; 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').mkv
|
|
||||||
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_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 \
|
|
||||||
-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 2 \
|
|
||||||
-c:v hevc_vaapi -profile:v main10 \
|
|
||||||
-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
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; 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
|
|
@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; 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').mkv
|
|
||||||
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -vaapi_device /dev/dri/renderD128 -analyzeduration 20000000 -probesize 20000000 \
|
|
||||||
-i "${video}" -map 0:v:0 -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy -vf 'format=nv12,hwupload' \
|
|
||||||
-c:v hevc_vaapi -profile:v main10 \
|
|
||||||
-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}" "${video}.json"
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${d}/${_filename}" >"${d}/${_filename}.json"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; then
|
|
||||||
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/XviD/x265/g').mkv
|
|
||||||
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -vaapi_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 -c:a copy -vf 'format=nv12,hwupload' \
|
|
||||||
-c:v hevc_vaapi \
|
|
||||||
-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
|
|
@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; 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').mkv
|
|
||||||
nice -n 19 ~/Downloads/ffmpeg/ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel qsv -hwaccel_output_format qsv -analyzeduration 20000000 -probesize 20000000 \
|
|
||||||
-i "${video}" -map 0:v -map 0:a -map 0:s? -map 0:d? -map 0:t? -c:s copy -c:a copy \
|
|
||||||
-vf 'scale_qsv=w=1920:1080' -c:v hevc_qsv -low_power false -preset 1 -profile:v 1 -scenario 3 -look_ahead 1 -global_quality 20 \
|
|
||||||
-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}" "${video}.json"
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${d}/${_filename}" >"${d}/${_filename}.json"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,34 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
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
|
|
||||||
if [[ ! -f "${video}.json" ]]; then
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
fi
|
|
||||||
d=$(dirname "$video")
|
|
||||||
filename=$(basename "$video")
|
|
||||||
filename="${filename%.*}"
|
|
||||||
video_codec=$(jq -r '.streams[0].codec_name' <"${video}.json")
|
|
||||||
video_height=$(jq -r '.streams[0].height' <"${video}.json")
|
|
||||||
echo -e "${video} // ${video_codec} // ${video_height}"
|
|
||||||
if [[ ${video_codec} =~ "av1" ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
if [[ ! ${video_codec} =~ "hevc" || ${video_height} -gt 1080 ]]; 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').mkv
|
|
||||||
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_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 -c:a copy \
|
|
||||||
-vf 'scale_vaapi=format=p010,scale_vaapi=w=1920:-2' -c:v hevc_vaapi -profile:v main10 \
|
|
||||||
-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}" "${video}.json"
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${d}/${_filename}" >"${d}/${_filename}.json"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
for video; do
|
|
||||||
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json"
|
|
||||||
sub_indexes=$(jq -r '.streams[] | select(.codec_type=="subtitle") | .index' <"${video}.json")
|
|
||||||
for subtitle in ${sub_indexes}; do
|
|
||||||
nice -n 18 ~/Downloads/ffmpeg/ffmpeg -hide_banner -loglevel quiet -y -threads 4 -analyzeduration 20000000 -probesize 20000000 \
|
|
||||||
-i "${video}" -map "0:${subtitle}" use_metadata_tags "${video}.${subtitle}.srt" || exit 1
|
|
||||||
done
|
|
||||||
done
|
|
Loading…
Reference in New Issue