Skip to content
Snippets Groups Projects
Commit 82f57288 authored by Florian Meißner's avatar Florian Meißner
Browse files

WIP

parent 676e11c0
Branches
No related tags found
No related merge requests found
function _error --description 'Call with `_error <msg> <var1> <var2> … <var_n>` to abort the program' --no-scope-shadowing
for i in $argv[2..]
set out $out {$i}={$$i}
end
echo $argv[1] '('(string join ', ' $out)')'
exit 1
end
function _fish_gen_cleanup_fn --argument name body
if [ (count $argv) -ne 2 ] || [ -z "$argv[1]" ] || [ -z "$argv[2]" ]
echo Invalid params '(expected 2, name and body, both non-empty)'
return 1
end
set current_filename (status filename)
if [ "$current_filename" = "Standard input" ]
set -e current_filename
else
set current_filename (systemd-escape --path (basename $current_filename))
set name _cleanup_"$(string escape --style=var {$current_filename}_ | string collect
)"(string escape --style=var $name)_(uuidgen)
# need \; and \<newline> for line break escaping and command delimiting
echo \
function $name --on-event fish_exit \;\
$body \;\
functions --erase $name \;\
end | source
end
#!/usr/bin/env fish
set FZF_PROMPT 'Select original file> '
set FZF_STARTING_QUERY 'orig'
set FFMPEG_ARGS (string trim '
-i $vid -i $ORIG -filter_complex \
"[0:v]setpts=PTS-STARTPTS[distorted]; \
[1:v]setpts=PTS-STARTPTS[ref]; \
[distorted][ref]libvmaf=feature='name=psnr':n_threads=8:log_fmt=json"
' | string collect)
. (dirname (status --current-filename))/helpers/_error.function.fish
switch (count $argv)
case 1
set ORIG $argv
case \*
_error 'need original video' argv[3..]
end
set ORIG (realpath (fzf --prompt $FZF_PROMPT --query $FZF_STARTING_QUERY))
set -q MAXDEPTH || set MAXDEPTH 1
set VIDEO_VILES (find . -maxdepth $MAXDEPTH -type f | filter_by_video | string match )
for vid in (find . -maxdepth $MAXDEPTH -type f | filter_by_video)
set vid (realpath $vid)
[ -r "$vid" ] || _error "sanity check failed: video '$vid' not readable" ORIG PWD MAXDEPTH
set output_file {$vid}_vmaf.txt
echo touch $output_file
#TODO comment in [ -w "$output_file" ] || _error "cannot write to '$output_file'" vid
set args_tmp (mktemp --suffix .fish); function ___cleanup_args_tmp --on-event fish_exit; rm -rf $args_tmp; end
echo $FFMPEG_ARGS >$args_tmp
nano $args_tmp
[ ! -s $args_tmp ] && _error
echo $ffmpeg_args
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment