#!/bin/sh ## TODO: handle srt encoding. _printhelp() { cat <max) {max=t[$NF]; val=$NF}} END{print val}' } _cropvalue() { ## For 5 different timeslices of 1 second at every 1/6th of the video, we ## sample the crop values. We keep the values with highest frequency. STEP=$(($(_duration "$1")/6)) for i in $(seq $STEP $STEP $((5*$STEP))); do ffmpeg -ss $i -t 10 -i "$1" -vf "cropdetect=24:2:0" -f null - 2>&1 500)", the +0 is required to make sure bitrate is numeric. if [ ! -n "$(command -v mediainfo)" ]; then mediainfo "$1" | awk 'BEGIN {id=0} /^Audio/ { getline; while(getline && ! index($0,"Bit rate ")); if($4) res=$4; else res=0; print id, res; id++}' else ffmpeg -i "$1" 2>&1 500) bitrate=500; printf "-c:a:" $1 " " codec " -b:a:" $1 " " bitrate "k "} else printf "-c:a:" $1 " copy "} END {print ""}' } _tc_transcode() { echo "==> [$1]" OUTPUT="${1%.*}-$(date '+%F-%H%M%S').mkv" STREAM_TITLE="" if $OPT_REMOVE_TITLE; then STREAM_NUM=$(ffmpeg -i "$1" 2>&1