45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
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
 | 
						|
 | 
						|
use_gpu=$1
 | 
						|
filename=$(basename -- "$2")
 | 
						|
output_name="$3"
 | 
						|
start_time="$4"
 | 
						|
end_time="$5"
 | 
						|
 | 
						|
if [[ $use_gpu == "" || $2 == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
 | 
						|
    printf "${BOLD}${RED}Usage: $0 <use-gpu (1|0)> <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
 | 
						|
use_crf=25
 | 
						|
if [[ $use_gpu -eq 1 ]]; then
 | 
						|
    use_crf=27
 | 
						|
fi
 | 
						|
 | 
						|
compress-video-with-crf $use_gpu $use_crf "$filename" "$output_name" "$start_time" "$end_time"
 | 
						|
 |