1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 06:39:02 -08:00
rc/sh/cutv
Connor Olding 2c9262f77b remove cutv docs
because nobody needs to see this right now
2024-07-05 15:03:17 -07:00

28 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env zsh
# YES_ZSH NO_BASH NO_DASH NO_ASH
cutv() {
argc $# -ge 2 "$0" || return
argc $# -le 4 "$0" || return
local nel="${1?missing length parameter}"
local f="${2?missing file parameter}"
local g="cut."${${f##*/}%.*}".mp4"
ffmpeg -hide_banner -i "$f" 2>&1 \
| grep Duration \
| grep -Eo '[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]' | awk -F: '{print (($1*60+$2)*60+$3)+$4/100}' | read len
[ "$((len>0))" -eq 1 ] || return 1
echo "$g"
ffmpeg \
-hide_banner -loglevel warning -stats -stats_period 5 \
-i "$f" -ss "$(((nel<len)*(len-nel)))" \
-sn -dn -metadata = -map_chapters -1 -movflags +faststart \
-ar 44100 -acodec libfdk_aac -b:a 256k -cutoff 20000 -af alimiter=level_in=2.5:level_out=0.9 \
-maxrate 7680k -bufsize 9600k -vcodec libx264 -preset medium -crf 21 -vf scale=1280:720 \
-threads 2 -y "$g" || return 1
# -maxrate 7680k -bufsize 9600k -vcodec libx264 -preset medium -crf 21 -vf scale=1280:720
# -maxrate 9600k -bufsize 12000k -vcodec libx264 -preset medium -crf 22 -vf scale=1280:720
}
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
eval ${preload:-preload} argc
[ -n "${preload+-}" ] || cutv "$@"