#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/video-meta video-property () { local p=$1 shift local fs=($@) local v local f for f in $fs; do if [[ -f $f ]]; then v=$(exiftool -j $f | jq -a -M -r ".[].$p" 2> /dev/null) if [[ $v != "null" ]]; then echo -n ${v//\"/} [[ $# > 1 ]] && echo -n " $f[0,72]" echo fi fi done } video-chapters () { video-property ChapterList $@ } alias chap=video-chapters video-resolution () { for f in $@; do local res=$(video-property ImageSize $f) local w=$(video-property ImageWidth $f) local h=$(video-property ImageHeight $f) local cx=$(( w / 8.0 )) local cy=$(( h / 16.0 )) printf "%s [ %d x %d ] ( %.2f . %.2f ) %s\n" \ $res $w $h $cx $cy $f done } alias res=video-resolution video-width () { video-property ImageWidth $@ } alias vid-w=video-width video-height () { video-property ImageHeight $@ } alias vid-h=video-height video-length-one () { local f=$1 local len=$(video-property Duration $f | sed -E 's/^^([[:digit:]]):/0\1:/') echo $len[0,8] } alias vleno=video-length-one video-length () { local fs=($@) local lens=() local data local dataf local ldata local len local long=0 for f in $fs; do data=$(video-length-one $f) dataf="$data ${f:0:71}" echo $dataf ldata=$#dataf (( $ldata > $long )) && long=$ldata len=${(s: :)data} lens+=$len done 2> /dev/null local odata=$(time-add $lens) local lodata=$#odata (( $lodata > $long )) && long=$lodata echo ${(l:$long::-:)} echo ${(l:$long:: :)odata} } alias vlen=video-length