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

fixes :D

parent 82f57288
No related branches found
No related tags found
No related merge requests found
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
. (status dirname)/_error.function.fish
# workaround for `status filename` not returning the script that sourced
[ (count $argv) -eq 1 ] || _error 'Need to supply script name to source command'
set current_filename $argv[1]
set current_filename (status filename)
if [ "$current_filename" = "Standard input" ]
set -e current_filename
else
set current_filename (systemd-escape --path (basename $current_filename))
end
function _defer --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 name _cleanup_"$(string escape --style=var {$current_filename}_ | string collect
)"(string escape --style=var $name)_(uuidgen)
set name __cleanup__"$current_filename"__(string escape --style=var "$name")__(uuidgen)
# need \; and \<newline> for line break escaping and command delimiting
echo \
function $name --on-event fish_exit \;\
......
#!/usr/bin/env fish
set FZF_PROMPT 'Select original file> '
set FZF_STARTING_QUERY 'orig'
set REPORT_EXT '_vmaf.txt'
set FZF_PROMPT 'Select video files> '
set FFMPEG_ARGS (string trim '
-i $vid -i $ORIG -filter_complex \
#!/usr/bin/env fish
set vid $argv[1]
set ORIG $argv[2]
ffmpeg -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"
[distorted][ref]libvmaf=feature=\'name=psnr\':n_threads=10:log_fmt=json" \
-f null - &| tee $vid"'$REPORT_EXT'"
' | string collect)
. (dirname (status --current-filename))/helpers/_error.function.fish
set HELPERS (dirname (status --current-filename))/helpers/
. $HELPERS/_error.function.fish
. $HELPERS/_defer.function.fish (status filename)
switch (count $argv)
case 1
set ORIG $argv
set ORIG (path normalize $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 )
set VIDEO_FILES_PRE (find . -maxdepth $MAXDEPTH -type f | filter_by_video | string match -v $ORIG)
for f in $VIDEO_FILES_PRE
if [ (path resolve $f) != (path resolve $ORIG) ] && [ ! -e "$f""$REPORT_EXT" ]
set VIDEO_FILES_NEW $VIDEO_FILES_NEW $f
end
end
set VIDS_SELECTED (string split \n $VIDEO_FILES_NEW | fzf --prompt $FZF_PROMPT --multi || _error 'canceled by Ctrl+C' VIDEO_FILES_PRE VIDEO_FILES_NEW)
for vid in (find . -maxdepth $MAXDEPTH -type f | filter_by_video)
set args_tmp (mktemp --suffix .fish); _defer ffmpeg_args "rm -rf $args_tmp"
chmod +x $args_tmp
echo $FFMPEG_ARGS >$args_tmp
nano $args_tmp </dev/stdin
[ ! -s $args_tmp ] && _error "ffmpeg args were empty"
set ffmpeg_args (string collect <$args_tmp)
echo $ffmpeg_args
for vid in $VIDS_SELECTED
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 output_file "$vid""$REPORT_EXT"
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
# touch is annoying in error case
# touch $output_file
# [ -w "$output_file" ] || _error "cannot write to '$output_file'" vid
echo $ffmpeg_args
set --local
# set ffmpeg_args (echo $ffmpeg_args | string replace --all \$vid (string escape $vid) | string replace --all \$ORIG (string escape $ORIG) | string collect)
$args_tmp $vid $ORIG
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment