Compare commits
2 Commits
676831426f
...
dcf670070d
Author | SHA1 | Date | |
---|---|---|---|
dcf670070d | |||
121d451982 |
178
.aliases
178
.aliases
|
@ -437,6 +437,9 @@ download_youtube_vid() {
|
|||
return
|
||||
fi
|
||||
|
||||
printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
|
||||
opts+=" --extractor-args youtube:player-client=default,tv_simply"
|
||||
|
||||
if [[ $shortname == "1" || $transcribe == "1" ]]; then
|
||||
printf "${BOLD}Downloading Youtube vid "
|
||||
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
|
||||
|
@ -448,13 +451,10 @@ download_youtube_vid() {
|
|||
|
||||
if [[ $format == "" ]]; then
|
||||
printf "${BOLD}No format given; using best available.${NORMAL}\n"
|
||||
# Download best mp4 video.
|
||||
format="bv*[ext=mp4]+ba[ext=m4a]"
|
||||
# Download best mp4 video, best audio then merge.
|
||||
format="bv[ext=mp4]+ba[ext=m4a]"
|
||||
fi
|
||||
|
||||
# We're assuming we'll always have an mp4 video only and audio track to merge.
|
||||
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs"
|
||||
|
||||
if [[ $make_folder == "1" ]]; then
|
||||
make_vid_dir_and_cd_into $url ""
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
@ -474,6 +474,9 @@ download_youtube_vid() {
|
|||
printf "filename: $filename\n"
|
||||
|
||||
# Download the video.
|
||||
# We're assuming we'll always have an mp4 video only and audio track to merge.
|
||||
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
|
||||
|
||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||
error=$?
|
||||
|
@ -508,20 +511,22 @@ download_youtube_playlist() {
|
|||
local url="$2"
|
||||
local dir_name="$3"
|
||||
shift 3
|
||||
local opts="$@ --write-sub --sub-lang en --embed-subs"
|
||||
local opts="$@"
|
||||
|
||||
if [[ $url == "" || $dir_name == "" ]]; then
|
||||
error "Usage: <url> <directory name> <optional args>"
|
||||
return
|
||||
fi
|
||||
|
||||
printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
|
||||
opts+=" --extractor-args youtube:player-client=default,tv_simply"
|
||||
|
||||
printf "${BOLD}Downloading Youtube playlist\n\n${NORMAL}"
|
||||
|
||||
if [[ $format == "" ]]; then
|
||||
printf "${BOLD}No format given; using best available.${NORMAL}\n"
|
||||
# Download best mp4 video and best m4a audio, then merge.
|
||||
format="bv*[ext=mp4]+ba[ext=m4a]"
|
||||
opts+=" --merge-output-format mp4"
|
||||
# Download best mp4 video, best audio then merge.
|
||||
format="bv[ext=mp4]+ba[ext=m4a]"
|
||||
fi
|
||||
|
||||
make_vid_dir_and_cd_into $url "$dir_name"
|
||||
|
@ -529,6 +534,9 @@ download_youtube_playlist() {
|
|||
return
|
||||
fi
|
||||
|
||||
# We're assuming we'll always have an mp4 video only and audio track to merge.
|
||||
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
|
||||
|
||||
local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
|
||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||
|
||||
|
@ -598,6 +606,9 @@ function download_youtube_audio() {
|
|||
return
|
||||
fi
|
||||
|
||||
printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
|
||||
opts+=" --extractor-args youtube:player-client=default,tv_simply"
|
||||
|
||||
printf "${BOLD}Downloading Youtube audio\n\n${NORMAL}"
|
||||
|
||||
if [[ $make_folder == "1" ]]; then
|
||||
|
@ -680,7 +691,7 @@ download_twitch_chat() {
|
|||
# `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt`
|
||||
#
|
||||
# To extract a portion of a video, you have to first download the entire file and then use the
|
||||
# `trim-video` or `compress-video-and-trim` scripts.
|
||||
# `trim-video` or `compress-video' with a time range.
|
||||
#
|
||||
download_twitch_vid() {
|
||||
local format="$1"
|
||||
|
@ -758,6 +769,8 @@ download_twitch_vid() {
|
|||
local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --progress=force $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\""
|
||||
else
|
||||
printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
|
||||
opts+=" --embed-thumbnail --embed-metadata"
|
||||
|
||||
local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
|
||||
fi
|
||||
|
||||
|
@ -794,20 +807,29 @@ download_twitch_vid() {
|
|||
# e.g. --cookies cookies.txt --referer https://gillyandkeeves.tv https://player.vimeo.com/video/756941969
|
||||
# The vid ID can be found by looking at the embed's iframe src attribute.
|
||||
download_vimeo_vid() {
|
||||
local shortname="$1"
|
||||
local compress="$2"
|
||||
local transcribe="$3"
|
||||
local format="$4"
|
||||
local format="$1"
|
||||
local shortname="$2"
|
||||
local compress="$3"
|
||||
local transcribe="$4"
|
||||
local make_folder="$5"
|
||||
local url="$6"
|
||||
shift 5
|
||||
shift 6
|
||||
local opts="$@"
|
||||
|
||||
if [[ $format == "" || $url == "" ]]; then
|
||||
error "Usage: <format> <make folder?> <url> <optional args>"
|
||||
if [[ $url == "" ]]; then
|
||||
error "Usage: <make folder?> <url> <optional args>"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $format == "" ]]; then
|
||||
printf "${BOLD}No format given; using best available.${NORMAL}\n"
|
||||
# Download best mp4 video, best audio then merge.
|
||||
format="bv[ext=mp4]+ba[ext=m4a]"
|
||||
fi
|
||||
|
||||
# We're assuming we'll always have an mp4 video only and audio track to merge.
|
||||
opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
|
||||
|
||||
if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
|
||||
printf "${BOLD}Downloading Vimeo vid "
|
||||
if [[ $shortname == "1" ]]; then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
|
||||
|
@ -871,7 +893,7 @@ download_twitter_vid() {
|
|||
local format="$1"
|
||||
local make_folder="$2"
|
||||
local url="$3"
|
||||
local vid_name="$4"
|
||||
local vid_name="$4" # optional
|
||||
|
||||
if [[ $url == "" ]]; then
|
||||
error "Usage: <make folder?> <url> <optional filename> <optional args>"
|
||||
|
@ -882,12 +904,24 @@ download_twitter_vid() {
|
|||
|
||||
local opts=""
|
||||
|
||||
if [[ $# > 3 ]]; then
|
||||
# Since the name is optional and we might pass options, like --cookie etc
|
||||
# we need to check if the vid name is set to an option.
|
||||
if [[ $vid_name == -* ]]; then
|
||||
echo "vid name is an option"
|
||||
shift 3
|
||||
vid_name=""
|
||||
opts="$@"
|
||||
else
|
||||
shift 4
|
||||
opts="$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $vid_name == "" ]]; then
|
||||
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-twitter-%(id)s"
|
||||
else
|
||||
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-twitter-%(id)s"
|
||||
shift 4
|
||||
opts="$@"
|
||||
fi
|
||||
|
||||
if [[ $make_folder == "1" ]]; then
|
||||
|
@ -908,6 +942,7 @@ download_twitter_vid() {
|
|||
printf "filename: $filename\n"
|
||||
|
||||
# Download the video.
|
||||
opts+=" --embed-thumbnail --embed-metadata"
|
||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||
|
||||
|
@ -924,10 +959,9 @@ download_twitter_vid() {
|
|||
# Download Instagram videos.
|
||||
download_instagram_vid() {
|
||||
local transcribe="$1"
|
||||
|
||||
local make_folder="$2"
|
||||
local url="$3"
|
||||
local vid_name="$4"
|
||||
local vid_name="$4" # optional
|
||||
|
||||
if [[ $url == "" ]]; then
|
||||
error "Usage: <make folder?> <url> <optional filename> <optional args>"
|
||||
|
@ -938,12 +972,24 @@ download_instagram_vid() {
|
|||
|
||||
local opts=""
|
||||
|
||||
if [[ $# > 3 ]]; then
|
||||
# Since the name is optional and we might pass options, like --cookie etc
|
||||
# we need to check if the vid name is set to an option.
|
||||
if [[ $vid_name == -* ]]; then
|
||||
echo "vid name is an option"
|
||||
shift 3
|
||||
vid_name=""
|
||||
opts="$@"
|
||||
else
|
||||
shift 4
|
||||
opts="$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $vid_name == "" ]]; then
|
||||
local name_format="%(upload_date>%Y-%m-%d)s-%(title)s-ig-%(id)s"
|
||||
else
|
||||
local name_format="%(upload_date>%Y-%m-%d)s-${vid_name}-ig-%(id)s"
|
||||
shift 4
|
||||
opts="$@"
|
||||
fi
|
||||
|
||||
if [[ $make_folder == "1" ]]; then
|
||||
|
@ -961,6 +1007,7 @@ download_instagram_vid() {
|
|||
printf "filename: $filename\n"
|
||||
|
||||
# Download the video.
|
||||
opts+=" --embed-thumbnail --embed-metadata"
|
||||
local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
|
||||
eval $cmd # Need to eval in order to preserve the quotes wrapping the filename format string.
|
||||
|
||||
|
@ -1069,29 +1116,46 @@ alias yt-list-desc='download_youtube_uploads_list 1 '
|
|||
|
||||
alias yt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-shortname='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
alias yt-1440='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1440p60='download_youtube_vid "400+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1440-shortname='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1080='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1080-shortname='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
alias yt-720='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-720-shortname='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
|
||||
alias yt-4k='download_youtube_vid "625+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-4k-shortname='download_youtube_vid "625+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
|
||||
alias yt-1440='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1440p60='download_youtube_vid "400+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1440-shortname='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
|
||||
# Premium
|
||||
alias yt-1080p='download_youtube_vid "616+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1080p-shortname='download_youtube_vid "616+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
# Normal
|
||||
alias yt-1080='download_youtube_vid "270+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-1080-shortname='download_youtube_vid "270+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
|
||||
alias yt-720='download_youtube_vid "136+234" $SHORTNAME_OFF $TRANSCRIBE_OFF'
|
||||
alias yt-720-shortname='download_youtube_vid "136+234" $SHORTNAME_ON $TRANSCRIBE_OFF'
|
||||
|
||||
#TRANSCRIPTION ON
|
||||
alias ytt='download_youtube_vid "" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-shortname-t='download_youtube_vid "" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-1440-t='download_youtube_vid "620+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-1440-shortname-t='download_youtube_vid "620+140" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-1080-t='download_youtube_vid "137+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-1080-shortname-t='download_youtube_vid "137+140" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-720-t='download_youtube_vid "136+140" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-720-shortname-t='download_youtube_vid "136+140" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-4k-t='download_youtube_vid "625+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-4k-shortname-t='download_youtube_vid "625+234" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-1440-t='download_youtube_vid "620+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-1440-shortname-t='download_youtube_vid "620+234" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-1080p-t='download_youtube_vid "616+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-1080p-shortname-t='download_youtube_vid "616+234" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-1080-t='download_youtube_vid "270+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-1080-shortname-t='download_youtube_vid "270+234" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
alias yt-720-t='download_youtube_vid "136+234" $SHORTNAME_OFF $TRANSCRIBE_ON'
|
||||
alias yt-720-shortname-t='download_youtube_vid "136+234" $SHORTNAME_ON $TRANSCRIBE_ON'
|
||||
#---------------------------
|
||||
alias yt-playlist='download_youtube_playlist ""'
|
||||
alias yt-playlist-audio='download_youtube_playlist "140"'
|
||||
alias yt-playlist-1440='download_youtube_playlist "620+140"'
|
||||
alias yt-playlist-1080='download_youtube_playlist "137+140"'
|
||||
alias yt-playlist-720='download_youtube_playlist "136+140"'
|
||||
alias yt-playlist-tiny='download_youtube_playlist "160+140"'
|
||||
alias yt-playlist-audio='download_youtube_playlist "234"'
|
||||
alias yt-playlist-4k='download_youtube_playlist "625+234"'
|
||||
alias yt-playlist-1440='download_youtube_playlist "620+234"'
|
||||
alias yt-playlist-1080p='download_youtube_playlist "616+234"'
|
||||
alias yt-playlist-1080='download_youtube_playlist "270+234"'
|
||||
alias yt-playlist-720='download_youtube_playlist "136+234"'
|
||||
alias yt-playlist-tiny='download_youtube_playlist "160+234"'
|
||||
alias yt-playlist-list='download_youtube_playlist_list '
|
||||
#---------------------------
|
||||
alias yt-audio='download_youtube_audio'
|
||||
|
@ -1173,16 +1237,16 @@ alias tw-4k-shortname-compressed-t='download_twitch_vi "2160p" $SHORTNAM
|
|||
#-------------------------------------------------
|
||||
# Vimeo Vid DL
|
||||
#-------------------------------------------------
|
||||
alias vimeo='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
|
||||
alias vimeo-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
|
||||
alias vimeo-compressed='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
|
||||
alias vimeo-compressed-t='download_vimeo_vid $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
|
||||
alias vimeo='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_OFF'
|
||||
alias vimeo-t='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_OFF $TRANSCRIBE_ON'
|
||||
alias vimeo-compressed='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_OFF'
|
||||
alias vimeo-compressed-t='download_vimeo_vid "" $SHORTNAME_OFF $COMPRESSION_ON $TRANSCRIBE_ON'
|
||||
|
||||
#-------------------------------------------------
|
||||
# Instagram Vid DL
|
||||
#-------------------------------------------------
|
||||
alias ig='download_instagram_vid $TRANSCRIBE_OFF'
|
||||
alias igt='download_instagram_vid $TRANSCRIBE_ON'
|
||||
alias ig='echo using my accounts with cookies to dl ig vids makes instagram think i am a bot and they might close my account. do not use your accounts' #download_instagram_vid $TRANSCRIBE_OFF'
|
||||
alias igt='echo using my accounts with cookies to dl ig vids makes instagram think i am a bot and they might close my account. do not use your accounts' #download_instagram_vid $TRANSCRIBE_ON'
|
||||
|
||||
#-------------------------------------------------
|
||||
# Twitter Vid DL
|
||||
|
@ -1194,7 +1258,6 @@ alias twitter='download_twitter_vid "" '
|
|||
#-------------------------------------------------
|
||||
alias download-mp4='download_mp4'
|
||||
alias download-from-stream='download_mp4_from_stream'
|
||||
alias download-from-m3u8='echo Use download-from-stream instead.'
|
||||
alias download-audio-from-stream='download_aac_from_stream'
|
||||
alias download-audio-from-m3u8='echo Use download-audio-from-stream instead.'
|
||||
|
||||
|
@ -1202,28 +1265,13 @@ alias download-audio-from-m3u8='echo Use download-audio-from-stream instead.'
|
|||
# Video Compression
|
||||
####################################################################################################
|
||||
|
||||
function _compress_video_hard() {
|
||||
local crf=35
|
||||
local name="$1"
|
||||
local out="$2"
|
||||
if [[ name == "" || out == "" ]]; then
|
||||
error "Usage: cmd <source> <dest>"
|
||||
return
|
||||
fi
|
||||
# 0=cpu, 1=gpu
|
||||
compress-video-with-crf $crf "$name" "$out" 0
|
||||
}
|
||||
|
||||
alias compress-video-hard='_compress_video_hard'
|
||||
|
||||
alias cv='compress-video'
|
||||
alias cvh='compress-video-hard'
|
||||
alias jv='join-video'
|
||||
alias av='analyze-volume'
|
||||
alias aa='analyze-volume'
|
||||
alias nv='normalize-volume'
|
||||
alias na='normalize-volume'
|
||||
alias tv='trim-video'
|
||||
alias tv='echo can just do a cv with a time range...' #trim-video-vbr'
|
||||
|
||||
####################################################################################################
|
||||
# Git
|
||||
|
|
|
@ -23,10 +23,10 @@ else
|
|||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
use_gpu=1
|
||||
|
||||
if [[ $# < 2 || $# > 3 ]]; then
|
||||
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
||||
if [[ $# < 2 || $# > 5 ]]; then
|
||||
printf "${BOLD}${RED}Usage: compress-video <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS> ${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -40,8 +40,8 @@ fi
|
|||
# Found the following to work best with vids containing text (e.g. programming vid): 21 for CPU encoding and 28 for GPU (similar bitrates).
|
||||
use_crf=21
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=28
|
||||
use_crf=33
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ else
|
|||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
use_gpu=1
|
||||
|
||||
if [[ "$#" < 3 || "$#" > 6 ]]; then
|
||||
printf "${BOLD}${RED}Usage: compress-video-with-crf <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
|
@ -66,18 +66,24 @@ function encode() {
|
|||
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
# RTX 3080
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
# vbr_hq is smaller file and less bitrate than vbr - strange!
|
||||
ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $crf -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
|
||||
|
||||
# GTX 1070
|
||||
#ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
# capped bitrate w/ crf is weird. gives a more compressed copy
|
||||
# ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -cq:v $crf -b:v 1200K -maxrate:v 1200K -bufsize:v 2400K -c:a copy -max_muxing_queue_size 9999 -movflags +faststart "$output"
|
||||
else
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output"
|
||||
fi
|
||||
printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n"
|
||||
|
||||
original_size=$(wc -c <"$filename.$extension")
|
||||
new_size=$(wc -c <"$output")
|
||||
printf "${BOLD}Original size: $original_size${NORMAL}\n"
|
||||
printf "${BOLD}New size: $new_size${NORMAL}\n\n"
|
||||
}
|
||||
|
||||
if [[ $use_crf -ne -1 ]]; then
|
||||
encode $use_crf
|
||||
time encode $use_crf
|
||||
else
|
||||
printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the video to get a more accurate timeline. If you want fast video joining at the expense of accuracy then use join-video-fast.
|
||||
# Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr.
|
||||
# If you want fast video joining at the expense of accuracy then use join-video-fast.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
|
@ -26,18 +27,40 @@ else
|
|||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
output="$2"
|
||||
target_crf="$3"
|
||||
max_bitrate_mb="$4"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\n$0 <list name> <output name>${NORMAL}\n"
|
||||
default_crf="20"
|
||||
default_max_bitrate="6"
|
||||
|
||||
if [[ $filename == "" || $output == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video <list filename> <output name> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M><${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output="${output_name}.mp4"
|
||||
extension="${output##*.}"
|
||||
if [[ $extension == $output ]]; then
|
||||
printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video <list filename> <output name> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M><${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
||||
if [[ $target_crf == "" || $target_crf == "0" ]] then
|
||||
target_crf=$default_crf
|
||||
fi
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
|
||||
if [[ $max_bitrate_mb == "" ]] then
|
||||
max_bitrate_mb=$default_max_bitrate
|
||||
fi
|
||||
|
||||
# bufsize is typically double the maxrate
|
||||
bufsize=$((max_bitrate_mb * 2))
|
||||
bufsize="${bufsize}M"
|
||||
max_bitrate="${max_bitrate_mb}M"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename' | output: $output | crf: $target_crf | max rate: $max_bitrate | buffer size: $bufsize ${NORMAL}\n"
|
||||
|
||||
time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda -f concat -safe 0 -accurate_seek -i "$filename" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $target_crf -maxrate:v $max_bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||
|
||||
|
|
|
@ -53,5 +53,8 @@ printf "\n${YELLOW}${BOLD}Trimming '$filename' | output: $output_name_with_exten
|
|||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -map a "$output_name_with_extension"
|
||||
|
||||
#If you want to have a specific bit rate and sample rate then you need to add it before the output filename. Might also need to remove the -map a arg. e.g.
|
||||
#ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename" -c:a aac -b:a 191k -ar 48000 "$output_name_with_extension"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
|
|
92
dotfiles/bin/trim-video-target-rate
Normal file
92
dotfiles/bin/trim-video-target-rate
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the video using a constrained bitrate/output size. If you want to
|
||||
# To target the visual quality with a variable bitrate, use trim-video-vbr
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
target_bitrate_mb="$3"
|
||||
start_time="$4"
|
||||
end_time="$5"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $target_bitrate_mb == "" || $start_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <target bitrate in MB, e.g. 6> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
|
||||
# bufsize is typically double the maxrate
|
||||
bufsize=$((target_bitrate_mb * 2))
|
||||
bufsize="${bufsize}M"
|
||||
bitrate="${target_bitrate_mb}M"
|
||||
|
||||
timing_args=""
|
||||
if [[ $start_time != "" ]]; then
|
||||
timing_args="-ss $start_time "
|
||||
fi
|
||||
if [[ $end_time != "" ]]; then
|
||||
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||
# We treat a start and end with 0 values as no op.
|
||||
timing_args=""
|
||||
elif [[ $end_time != "0" ]]; then
|
||||
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||
timing_args+="-to $end_time"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time | max rate: $bitrate | buffer size: $bufsize ${NORMAL}\n"
|
||||
|
||||
# You might have issues if the file has multiple video streams or embedded
|
||||
# subtitles. The -map 0 arg is typically given when copying a video stream, but
|
||||
# I'm not sure if it's appropriate to use here. If you want to target one of
|
||||
# the video streams then use `-map 0:v:0` and if you want to re-encode
|
||||
# subtitles then include `-c:s mov_text` with either of the `-map` args.
|
||||
|
||||
# -preset 3 and 4 are the fastest on my 3080 and have the same output file
|
||||
# size. p3 seems slightly faster. Apparently 7 is the best for 30 series
|
||||
# according to chatgpt (lol) but it was slow and compressed.
|
||||
|
||||
# -accurate_seek doesn't seem to be needed when -ss is after -i, only when -ss
|
||||
# is before -i. Having -ss after is apparently a way of enabling accurate
|
||||
# seeking. The catch is that if the trim doesn't start at 0, it can be a long
|
||||
# wait before the encoder gets to the portion you want to start trimming from.
|
||||
# To speed this up we are putting -ss and -accurate_seek before -i ... the
|
||||
# video duration might be slightly off from this but so far I haven't seen any
|
||||
# seeking issues. If they come up then we can move -ss to after -i again and
|
||||
# delete -accurate_seek.
|
||||
|
||||
# I'm using -b:v, -maxrate:v, and -bufsize:v to constrain the bitrate and
|
||||
# indirectly control quality. The bitrate won't be fixed exactly to -b:v
|
||||
# unless using CBR, but NVENC will attempt to average around it and cap the
|
||||
# bitrate at -maxrate:v, using -bufsize:v as a smoothing buffer.
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -b:v $bitrate -maxrate:v $bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
124
dotfiles/bin/trim-video-vbr
Normal file
124
dotfiles/bin/trim-video-vbr
Normal file
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Re-encodes the video using a target quality level and a variable bitrate.
|
||||
# To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate
|
||||
# Just note that it'll result in larger files for a similar max bitrate target and the
|
||||
# quality won't really be noticeably better.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
target_crf="$5"
|
||||
max_bitrate_mb="$6"
|
||||
|
||||
default_crf="20"
|
||||
default_max_bitrate="6"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: trim-video <filename> <output name> <start time HH:MM:SS> <optional: end time HH:MM:SS, use empty string or 0 for no value> <optional: crf (quality, w/ lower = more compression) - defaults to $default_crf, use 0 for no value> <optional: max bitrate in MB - defaults to ${default_max_bitrate}M>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
|
||||
if [[ $target_crf == "" || $target_crf == "0" ]] then
|
||||
target_crf=$default_crf
|
||||
fi
|
||||
|
||||
if [[ $max_bitrate_mb == "" ]] then
|
||||
max_bitrate_mb=$default_max_bitrate
|
||||
fi
|
||||
|
||||
# bufsize is typically double the maxrate
|
||||
bufsize=$((max_bitrate_mb * 2))
|
||||
bufsize="${bufsize}M"
|
||||
max_bitrate="${max_bitrate_mb}M"
|
||||
|
||||
timing_args=""
|
||||
if [[ $start_time != "" ]]; then
|
||||
timing_args="-ss $start_time "
|
||||
fi
|
||||
if [[ $end_time != "" ]]; then
|
||||
if [[ $start_time == "0" && $end_time == "0" ]]; then
|
||||
# We treat a start and end with 0 values as no op.
|
||||
timing_args=""
|
||||
elif [[ $end_time != "0" ]]; then
|
||||
# Handle having a start time but end time is set to 0, can just ignore it and it'll use the remainder of the video.
|
||||
timing_args+="-to $end_time"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time | crf: $target_crf | max rate: $max_bitrate | buffer size: $bufsize ${NORMAL}\n"
|
||||
|
||||
# You might have issues if the file has multiple video streams or embedded
|
||||
# subtitles. The -map 0 arg is typically given when copying a video stream, but
|
||||
# I'm not sure if it's appropriate to use here. If you want to target one of
|
||||
# the video streams then use `-map 0:v:0` and if you want to re-encode
|
||||
# subtitles then include `-c:s mov_text` with either of the `-map` args.
|
||||
|
||||
# -preset 3 and 4 are the fastest on my 3080 and have the same output file
|
||||
# size. p3 seems slightly faster. Apparently 7 is the best for 30 series
|
||||
# according to chatgpt (lol) but it was slow and compressed.
|
||||
|
||||
# -accurate_seek doesn't seem to be needed when -ss is after -i, only when -ss
|
||||
# is before -i. Having -ss after is apparently a way of enabling accurate seeking.
|
||||
# The catch is that if the trim doesn't start at 0, it can be a long wait before
|
||||
# the encoder gets to the portion you want to start trimming from. To speed this up
|
||||
# we are putting -ss and -accurate_seek before -i ... the video duration might be
|
||||
# slightly off from this but so far I haven't seen any seeking issues. If they come
|
||||
# up then we can move -ss to after -i again and delete -accurate_seek.
|
||||
|
||||
# I'm using -rc:v vbr -cq:v 20 (higher = more compression) to have a variable
|
||||
# bit-rate with a quality target. This gives us a good looking re-encoding that
|
||||
# does a good job preserving the quality of the source video (at least for
|
||||
# twitch streams I'm trimming) but the bitrate might be higher or lower than
|
||||
# the source. The quality metric will fluctuate during encoding because NVENC
|
||||
# does't use a fixed quantization parameter. -cq:v is a target, not a constraint.
|
||||
# So you can have quite the fluctuating (or high) bitrate with these two params.
|
||||
# In order to set a birate cap that is prioritized over visual fidelity, we can
|
||||
# add in:
|
||||
# -maxrate:v -bufsize:v
|
||||
# (with bufsize typically being double the maxrate)
|
||||
#
|
||||
# Using this with the vbr and crf params tells the NVENC encoder to try to
|
||||
# encode at a perceptual quality level around CQ=20 but keep the bitrate under
|
||||
# 6000 kbps (constrained VBR). If a scene is too complex to maintain CQ=20
|
||||
# within the bitrate cap, the encoder will:
|
||||
# * Raise the quantizer (lower quality) to obey the -maxrate
|
||||
# * Result: CQ metric fluctuates upward
|
||||
# If a scene is simple:
|
||||
# * Encoder can exceed CQ=20 (e.g. better quality) while staying under maxrate
|
||||
# * Result: CQ metric fluctuates downward
|
||||
#
|
||||
# To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate
|
||||
|
||||
time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda $timing_args -accurate_seek -i "$filename.$extension" -c:v h264_nvenc -profile:v high -preset 3 -rc:v vbr -cq:v $target_crf -maxrate:v $max_bitrate -bufsize:v $bufsize -c:a copy -movflags +faststart "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
|
@ -59,18 +59,18 @@
|
|||
127.0.0.1 www.wip2.adobe.com www.wip3.adobe.com www.wip4.adobe.com wwis-dubc1-vip60.adobe.com crl.verisign.net CRL.VERISIGN.NET ood.opsource.net
|
||||
|
||||
# Block Facebook
|
||||
127.0.0.1 www.facebook.com
|
||||
127.0.0.1 facebook.com
|
||||
127.0.0.1 static.ak.fbcdn.net
|
||||
127.0.0.1 www.static.ak.fbcdn.net
|
||||
127.0.0.1 login.facebook.com
|
||||
127.0.0.1 www.login.facebook.com
|
||||
127.0.0.1 fbcdn.net
|
||||
127.0.0.1 www.fbcdn.net
|
||||
127.0.0.1 fbcdn.com
|
||||
127.0.0.1 www.fbcdn.com
|
||||
127.0.0.1 static.ak.connect.facebook.com
|
||||
127.0.0.1 www.static.ak.connect.facebook.com
|
||||
#127.0.0.1 www.facebook.com
|
||||
#127.0.0.1 facebook.com
|
||||
#127.0.0.1 static.ak.fbcdn.net
|
||||
#127.0.0.1 www.static.ak.fbcdn.net
|
||||
#127.0.0.1 login.facebook.com
|
||||
#127.0.0.1 www.login.facebook.com
|
||||
#127.0.0.1 fbcdn.net
|
||||
#127.0.0.1 www.fbcdn.net
|
||||
#127.0.0.1 fbcdn.com
|
||||
#127.0.0.1 www.fbcdn.com
|
||||
#127.0.0.1 static.ak.connect.facebook.com
|
||||
#127.0.0.1 www.static.ak.connect.facebook.com
|
||||
|
||||
#----------------------------------------------
|
||||
|
||||
|
|
4
dotfiles/windows/disable-folder-type-auto-discovery.reg
Normal file
4
dotfiles/windows/disable-folder-type-auto-discovery.reg
Normal file
|
@ -0,0 +1,4 @@
|
|||
Windows Registry Editor Version 5.00
|
||||
|
||||
[HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell]
|
||||
"FolderType"="NotSpecified"
|
Loading…
Reference in New Issue
Block a user