42 lines
940 B
Bash
Executable File
42 lines
940 B
Bash
Executable File
#!/bin/sh
|
|
set -euf
|
|
|
|
errecho() { echo "$*" >&2 ; }
|
|
|
|
vmaf() {
|
|
while getopts :s:t:T: OPT; do
|
|
case "$OPT" in
|
|
s) start="$OPTARG" ;;
|
|
t) time="$OPTARG" ;;
|
|
T) to="$OPTARG" ;;
|
|
*) : ;
|
|
esac
|
|
done
|
|
shift $((OPTIND - 1))
|
|
|
|
exec ffmpeg ${start:+-ss "$start"} ${to:+-to "$to"} \
|
|
-i "$1" -i "$2" ${time:+-t "$time"} \
|
|
-lavfi "[0:v] setpts=PTS-STARTPTS [ref]; \
|
|
[1:v] setpts=PTS-STARTPTS [dis]; \
|
|
[dis][ref] libvmaf=log_fmt=xml:log_path=/dev/stdout:n_threads=$(nproc)" \
|
|
-f null - \
|
|
}
|
|
|
|
moovcheck() {
|
|
ffprobe -v trace -i "$1" 2>&1 | grep -F -e "type:'mdat'" -e "type:'moov'"
|
|
}
|
|
|
|
cmd=$1; shift
|
|
case "$cmd" in
|
|
vmaf) vmaf "$@" ;;
|
|
moovcheck) moovcheck "$@" ;;
|
|
help|-h) cat >&2 <<-EOF
|
|
available commands:
|
|
* vmaf $1 $2 - get vmaf of $1 (ref) to $2 (distorted)
|
|
options: -s <start> -t <time> -T <to>
|
|
* moovcheck $1 - check if moov is before mdat in $1
|
|
EOF
|
|
;;
|
|
*) errecho "wrong command. use help or -h for help" ;;
|
|
esac
|