google style guide formatting and fixing some typos

hwip
Hugh Smalley 2 years ago
parent 6f75e5ec77
commit 221d667df4

31
.gitignore vendored

@ -0,0 +1,31 @@
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
.idea/*
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/

56
265

@ -9,32 +9,32 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu/
# parallel 'find {} -type f -name "*.mkv"' ::: /Muninn/TV /Muninn/Movies | parallel --progress ~/convert265/265 {} # parallel 'find {} -type f -name "*.mkv"' ::: /Muninn/TV /Muninn/Movies | parallel --progress ~/convert265/265 {}
for video; do for video; do
d=$(dirname "$video") d=$(dirname "$video")
filename=$(basename "$video") filename=$(basename "$video")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
audio_codec=$(mediainfo --Inform="Audio;%Format%" "${video}") audio_codec=$(mediainfo --Inform="Audio;%Format%" "${video}")
video_codec=$(mediainfo --Inform="Video;%Format%" "${video}") video_codec=$(mediainfo --Inform="Video;%Format%" "${video}")
attachment=$(mediainfo --Inform="General;%Attachments%" "${video}") attachment=$(mediainfo --Inform="General;%Attachments%" "${video}")
video_width=$(mediainfo --Inform="Video;%Width%" "${video}") video_width=$(mediainfo --Inform="Video;%Width%" "${video}")
color_primaries=$(mediainfo --Inform="Video;%colour_primaries%" "${video}") color_primaries=$(mediainfo --Inform="Video;%colour_primaries%" "${video}")
echo -e "${video} // ${video_codec} // ${audio_codec} // ${video_width} // ${attachment} // ${color_primaries}" echo -e "${video} // ${video_codec} // ${audio_codec} // ${video_width} // ${attachment} // ${color_primaries}"
if [[ -f "${d}/poster.jpg" ]]; then if [[ -f "${d}/poster.jpg" ]]; then
poster="${d}/poster.jpg" poster="${d}/poster.jpg"
elif [[ -f "${d}/${filename}.jpg" ]]; then elif [[ -f "${d}/${filename}.jpg" ]]; then
poster="${d}/${filename}.jpg" poster="${d}/${filename}.jpg"
else else
poster="" poster=""
fi fi
if [[ ! ${video_codec} =~ "HEVC" ]] || [[ ! ${audio_codec} =~ "Opus" ]]; then 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 _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 \ #-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 6 \
~/convert265/tools/ffmpeg -hide_banner -loglevel info -y -hwaccel auto -analyzeduration 20000000 -probesize 20000000 \ ~/convert265/tools/ffmpeg -hide_banner -loglevel info -y -hwaccel auto -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:v hevc_nvenc -rc-lookahead 30 -surfaces 64 -qmin 0 -qmax 24 -profile:v main10 -preset p7 -tune hq -multipass 1 \ -c:v hevc_nvenc -rc-lookahead 30 -surfaces 64 -qmin 0 -qmax 24 -profile:v main10 -preset p7 -tune hq -multipass 1 \
-c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 6 \ -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" || exit 1 -max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/$_filename" || exit 1
cmp "/dev/shm/${_filename}" "${video}" || rm -vf "${video}" cmp "/dev/shm/${_filename}" "${video}" || rm -vf "${video}"
mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}" mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
fi fi
done done

@ -9,22 +9,22 @@ IFS=$'\n\t'
# 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 {} # 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 {}
for video; do for video; do
d=$(dirname "$video") d=$(dirname "$video")
filename=$(basename "$video") filename=$(basename "$video")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
video_codec=$(mediainfo --Inform="Video;%Format%" "${video}") video_codec=$(mediainfo --Inform="Video;%Format%" "${video}")
echo -e "${video} // ${video_codec}" echo -e "${video} // ${video_codec}"
if [[ ! ${video_codec} =~ "HEVC" ]]; then 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').mkv _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 \ 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 libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio -mapping_family 1 -ac 2 \ -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 \ -c:v hevc_vaapi -profile:v main10 \
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/$_filename" || 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}" mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
if [[ -f "${d}/${_filename}" ]]; then if [[ -f "${d}/${_filename}" ]]; then
cmp "${d}/${_filename}" "${video}" || rm -vf "${video}" cmp "${d}/${_filename}" "${video}" || rm -vf "${video}"
fi fi
fi fi
done done

@ -8,9 +8,9 @@ IFS=$'\n\t'
# parallel 'find {} -type f -name "*.mkv"' ::: /Muninn/TV /Muninn/Movies | parallel --progress ~/convert265/265 {} # 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 {} # 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" 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 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" export VK_ICD_FILENAMES="${pro_dir}/amd_icd32.json:${pro_dir}/amd_icd64.json"
for video; do for video; do

@ -9,21 +9,21 @@ IFS=$'\n\t'
# 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 {} # 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 {}
for video; do for video; do
d=$(dirname "$video") d=$(dirname "$video")
filename=$(basename "$video") filename=$(basename "$video")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
video_codec=$(nice -n 19 mediainfo --Inform="Video;%Format%" "${video}") video_codec=$(nice -n 19 mediainfo --Inform="Video;%Format%" "${video}")
echo -e "${video} // ${video_codec}" echo -e "${video} // ${video_codec}"
if [[ ! ${video_codec} =~ "HEVC" ]]; then 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').mkv _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 \ 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:a -c:a copy -vf 'format=nv12,hwupload' \ -i "${video}" -map 0:v:0 -map 0:a -c:a copy -vf 'format=nv12,hwupload' \
-c:v hevc_vaapi \ -c:v hevc_vaapi \
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/$_filename" || 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}" mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
if [[ -f "${d}/${_filename}" ]]; then if [[ -f "${d}/${_filename}" ]]; then
cmp "${d}/${_filename}" "${video}" || rm -vf "${video}" cmp "${d}/${_filename}" "${video}" || rm -vf "${video}"
fi fi
fi fi
done done

@ -9,22 +9,22 @@ IFS=$'\n\t'
# 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 {} # 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 {}
for video; do for video; do
d=$(dirname "$video") d=$(dirname "$video")
filename=$(basename "$video") filename=$(basename "$video")
extension="${filename##*.}" extension="${filename##*.}"
filename="${filename%.*}" filename="${filename%.*}"
video_codec=$(nice -n 19 mediainfo --Inform="Video;%Format%" "${video}") video_codec=$(nice -n 19 mediainfo --Inform="Video;%Format%" "${video}")
echo -e "${video} // ${video_codec}" echo -e "${video} // ${video_codec}"
if [[ ! ${video_codec} =~ "HEVC" ]]; then if [[ ! ${video_codec} =~ "HEVC" ]]; then
_filename=$(echo "${filename}" | sed -e 's/h264/x265/g' -e 's/x264/x265/g' -e 's/XviD/x265/g').mkv _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 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -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 \
nice -n 19 ffmpeg -hide_banner -loglevel info -y -threads 4 -vaapi_device /dev/dri/renderD128 -analyzeduration 20000000 -probesize 20000000 \ 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' \ -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 \ -c:v hevc_vaapi \
-max_muxing_queue_size 1024 -movflags +faststart -movflags use_metadata_tags "/dev/shm/$_filename" || 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}" mv -vu "/dev/shm/${_filename}" "${d}/${_filename}" || rm -f "/dev/shm/${_filename}"
if [[ -f "${d}/${_filename}" ]]; then if [[ -f "${d}/${_filename}" ]]; then
cmp "${d}/${_filename}" "${video}" || rm -vf "${video}" cmp "${d}/${_filename}" "${video}" || rm -vf "${video}"
fi fi
fi fi
done done

@ -8,30 +8,30 @@ IFS=$'\n\t'
# parallel 'find {} -type f -name "*.mkv"' ::: /Muninn/TV /Muninn/Movies | parallel --progress ~/convert265/265 {} # 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 {} # 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" 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 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" export VK_ICD_FILENAMES="${pro_dir}/amd_icd32.json:${pro_dir}/amd_icd64.json"
for video; do for video; do
if [[ ! -f "${video}.json" ]]; then if [[ ! -f "${video}.json" ]]; then
ffprobe -v quiet -print_format json -show_streams "${video}" >"${video}.json" 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 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 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 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 done

@ -1,10 +1,10 @@
# convert265 # convert265
Script to convert media to x264 Script to convert media to x265
Edit the path for the find command in the normal one. Edit the path for the find command in the normal one.
To make it even more faster you'll want to run this kinda like this... To make it even faster you'll want to run this kinda like this...
parallel ./parallel_convert_265 . ::: $(find /mnt/ -maxdepth 25 -regex ".*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|avi\|m4v\)") parallel ./parallel_convert_265 . ::: $(find /mnt/ -maxdepth 25 -regex ".*\.\(mkv\|mp4\|wmv\|flv\|webm\|mov\|avi\|m4v\)")

Loading…
Cancel
Save