Compare commits
	
		
			2 Commits
		
	
	
		
			676831426f
			...
			dcf670070d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| dcf670070d | |||
| 121d451982 | 
							
								
								
									
										59
									
								
								.aliases
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								.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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -810,10 +823,13 @@ download_vimeo_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 --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
 | 
			
		||||
| 
						 | 
				
			
			@ -926,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.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -990,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.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1247,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-vbr'
 | 
			
		||||
alias tv='echo can just do a cv with a time range...' #trim-video-vbr'
 | 
			
		||||
 | 
			
		||||
####################################################################################################
 | 
			
		||||
# Git
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user