#!/usr/bin/env zsh # compat: -ash -bash -dash +zsh 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