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
d39081b4
Commit
d39081b4
authored
May 4, 2024
by
Florian Meißner
Committed by
Florian Meißner
May 25, 2024
Browse files
Options
Downloads
Patches
Plain Diff
- optimize code
- format duration to mmm:ss - add option to print bitrate in MBs
parent
1645cd21
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
video/stats.fish
+18
-15
18 additions, 15 deletions
video/stats.fish
with
18 additions
and
15 deletions
video/stats.fish
+
18
−
15
View file @
d39081b4
#!/usr/bin/env fish
argparse 'sort-by=' -- $argv
. (dirname (status --current-filename))/../helpers/numeric.fish
argparse 'sort-by=' 'm/megabytes' -- $argv
set $_flag_sort_by (set -q $_flag_sort_by && echo $_flag_sort_by || echo 3)
function __t-nil_helper_extract --argument-names key
...
...
@@ -12,25 +14,26 @@ end
filter_by_video | while read f
echo -ne $f\t
set len (ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $f | string trim)
echo -ne (math $len / 60)\t
for medium in v a
set out (ffprobe -v error -select_streams $medium -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 $f 2>/dev/null)\t
[ (string trim "$out" | string collect) = 'N/A' ] && set out (ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 $f)
echo -ne (string trim $out)\t
end
# set fish_trace 1
set blah (ffprobe -v error -select_streams v -show_entries stream=width,height,bit_rate,r_frame_rate -of default=noprint_wrappers=1 $f 2>/dev/null)
set blah (ffprobe -v error -select_streams v -show_entries stream=width,height,r_frame_rate:format=duration,bit_rate -of default=noprint_wrappers=1 $f 2>/dev/null | string trim)
set duration (__t-nil_helper_extract duration $blah)
set width (__t-nil_helper_extract width $blah)
set height (__t-nil_helper_extract height $blah)
set fps (__t-nil_helper_extract r_frame_rate $blah)
set bit_rate (__t-nil_helper_extract bit_rate $blah)
set bits_per_pixel (math $bit_rate / \( $width \* $height \* $fps \) )
echo -ne $bits_per_pixel
# if all values are there, calc bits per pixel
for x in blah width height fps bit_rate
__t-nil_helper__is_numeric $$x || set bits_per_pixel "N/A"
end
set -q bits_per_pixel && [ "$bits_per_pixel" != "N/A" ] && set bit_rate (math $bit_rate / \( $width \* $height \* $fps \) )
# formatting at the end, so values can be used for calculations until then
set duration (math --scale 0 $duration / 60):(math --scale 0 $duration % 60 | string pad --char 0 --width 2)
set -q _flag_megabytes && [ "$bit_rate" != "N/A" ] && set bit_rate (math -s 2 $bit_rate / 1024^2)' Mb/s'
echo -ne (string join \t $duration $bit_rate $width"x"$height $fps $bits_per_pixel)
echo
end | pv -l | column -s\t -o\t -t | sort -nt\t -k$_flag_sort_by
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