Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env zsh
- set -e
- while getopts "a:p:w:" o
- do
- case $o in
- a) if=$OPTARG
- n=${if:t:r}
- t="$(ffprobe $if 2>&1|sed -n 's/.*Duration: \([^,]\+\),.*/\1/p')"
- ;;
- p) p=$OPTARG;;
- w) vopts=(-vf "scale=$OPTARG:-1");;
- *) cat<<END
- Usage: $0 [options]
- -a song.flac - audio source
- by default will be taken from audio player (mocp or deadbeef)
- -p image.png - picture
- by defalt path will be taken from clipboard
- -w width - scale picture
- END
- exit 1
- esac
- done
- shift $((OPTIND - 1))
- if [[ -n $if ]]
- then
- :
- elif pgrep mocp > /dev/null
- then
- if="$(mocp -i | sed -n 's/^File: //p')"
- n="$(mocp -i | sed -n 's/^Title: //p')"
- [[ -z $n ]] && n=${if:h:t}
- t="$(mocp -i | sed -n 's/^TotalTime: //p')"
- elif pgrep deadbeef > /dev/null
- then
- if="$(deadbeef --nowplaying %F)"
- n="$(deadbeef --nowplaying %t)"
- t="$(deadbeef --nowplaying %l)"
- else
- echo "nothing to do"
- exit 1
- fi
- [[ -n $p ]] || p="$(xclip -o| tr -d \')"
- aopts=(-q:a 5)
- #aopts=(-c:a libopus -application audio -vbr on -b:a 95k -strict -2)
- #aopts=(-c:a copy)
- [[ -f "$n.webm" ]] && echo "$n exists" && false
- ffmpeg -hide_banner -loop 1 -r 1 -t $t -i $p \
- -c:v vp9 -pix_fmt +yuv420p -g 9999 -b:v 0 -qmax 16 -qmin 16 -y /tmp/v.webm
- ffmpeg -hide_banner -i $if $@ -vn -sn $aopts -map_metadata 0 -y /tmp/a.webm
- #for pass in 1 2
- # ffmpeg -hide_banner -loop 1 -r 1 -i $p \
- # $@ $vopts \
- # -t $t -pass $pass -g 9999 -auto-alt-ref 1 -lag-in-frames 16 -y /tmp/v.webm
- # #-vf 'setpts=10*PTS' \
- mkvmerge /tmp/v.webm /tmp/a.webm -o $n.webm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement