Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Meißner
Scripts
Commits
ed08970e
Commit
ed08970e
authored
Oct 18, 2023
by
Florian Meißner
Browse files
Options
Downloads
Patches
Plain Diff
fixes :D
parent
82f57288
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helpers/_defer.function.fish
+14
-9
14 additions, 9 deletions
helpers/_defer.function.fish
vmaf.fish
+42
-21
42 additions, 21 deletions
vmaf.fish
with
56 additions
and
30 deletions
helpers/_
fish_gen_cleanup_fn
.function.fish
→
helpers/_
defer
.function.fish
+
14
−
9
View file @
ed08970e
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 \;\
...
...
This diff is collapsed.
Click to expand it.
vmaf.fish
+
42
−
21
View file @
ed08970e
#!/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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment