diff --git a/.config/fish/functions/remux.fish b/.config/fish/functions/remux.fish new file mode 100644 index 0000000..35874be --- /dev/null +++ b/.config/fish/functions/remux.fish @@ -0,0 +1,22 @@ +function remux --wraps=ffmpeg --description 'remux to mp4' + mkdir -p /tmp/remux + + # download file if input path is a url + if string match -qr '^(https?://|youtu\.?be|[a-zA-Z0-9]{11}$)' $argv[1] + set argv[1] (yt-dlp -q --force-overwrites --print after_move:filepath \ + -f 'bestvideo[height<=?1080][vcodec!=?av01]+bestaudio/best' \ + -o "/tmp/remux/download.%(ext)s" $argv[1]) + or return + end + + # set output path to default one if not set + set noask + if not set -q argv[2] + set noask -y + set argv[2] /tmp/remux/out.mp4 + end + + ffmpeg $noask -i $argv[1] -c copy -movflags faststart $argv[2..] + + command -sq wl-copy; and wl-copy -t text/uri-list "file://$(realpath $argv[-1])" +end