2
0
mirror of https://github.com/webgefrickel/dotfiles synced 2024-11-17 09:25:52 +00:00
steffen-dotfiles/zsh/functions

94 lines
3.9 KiB
Plaintext
Raw Normal View History

2015-06-05 12:39:13 +00:00
# convert a video to mp4 + webm in one go for web
2015-09-16 11:54:33 +00:00
function webvideo() {
2015-10-26 10:08:51 +00:00
ffmpeg -i $1 -acodec libvorbis -ac 2 -b:a 128k -ar 44100 -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 2M -maxrate 2M -bufsize 4M -s 1280x720 $1.webm
ffmpeg -i $1 -movflags +faststart -acodec libfdk_aac -ac 2 -b:a 128k -ar 44100 -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 2M -maxrate 2M -bufsize 4M -s 1280x720 $1.mp4
}
function webvideohigh() {
ffmpeg -i $1 -acodec libvorbis -ac 2 -b:a 160k -ar 44100 -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 3M -maxrate 3M -bufsize 6M -s 1280x720 $1--high.webm
ffmpeg -i $1 -movflags +faststart -acodec libfdk_aac -ac 2 -b:a 160k -ar 44100 -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 3M -maxrate 3M -bufsize 6M -s 1280x720 $1--high.mp4
}
function webvideolow() {
ffmpeg -i $1 -acodec libvorbis -ac 2 -b:a 96k -ar 44100 -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 1M -maxrate 1M -bufsize 2M -s 1280x720 $1--low.webm
ffmpeg -i $1 -movflags +faststart -acodec libfdk_aac -ac 2 -b:a 96k -ar 44100 -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 1M -maxrate 1M -bufsize 2M -s 1280x720 $1--low.mp4
}
# convert a video to mp4 + webm in one go for web
function webvideonoaudio() {
ffmpeg -i $1 -an -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 2M -maxrate 2M -bufsize 4M -s 1280x720 $1--no-audio.webm
ffmpeg -i $1 -movflags +faststart -an -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 2M -maxrate 2M -bufsize 4M -s 1280x720 $1--no-audio.mp4
}
function webvideohighnoaudio() {
ffmpeg -i $1 -an -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 3M -maxrate 3M -bufsize 6M -s 1280x720 $1--high--no-audio.webm
ffmpeg -i $1 -movflags +faststart -an -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 3M -maxrate 3M -bufsize 6M -s 1280x720 $1--high--no-audio.mp4
}
function webvideolownoaudio() {
ffmpeg -i $1 -an -vcodec libvpx -pix_fmt yuv420p -r 25 -qmin 10 -qmax 42 -cpu-used 0 -quality best -b:v 1M -maxrate 1M -bufsize 2M -s 1280x720 $1--low--no-audio.webm
ffmpeg -i $1 -movflags +faststart -an -vcodec libx264 -vprofile high -preset slower -pix_fmt yuv420p -r 25 -b:v 1M -maxrate 1M -bufsize 2M -s 1280x720 $1--low--no-audio.mp4
2015-01-04 16:25:29 +00:00
}
2013-07-19 17:17:05 +00:00
# a small function for finding stuff
2014-09-19 16:08:36 +00:00
function fname() {
find . -iname "*$@*";
2013-07-19 17:17:05 +00:00
}
2014-11-19 11:08:43 +00:00
# create and change to directory/folder
function take() {
mkdir -p $1
cd $1
}
2015-06-05 12:41:05 +00:00
# a function to get the current branch for git shortcuts etc
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
2015-07-10 15:05:25 +00:00
# easy vim/terminal switch
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
2013-07-19 17:17:05 +00:00
# open changed files in git index
function gch () {
nvim `git status | grep modified | awk '{print $3}'`
2013-07-19 17:17:05 +00:00
}
# creates an archive from given directory
mktar() { tar cvf "${1%%/}.tar" "${1%%/}"; }
mktgz() { tar cvzf "${1%%/}.tgz" "${1%%/}"; }
mkzip() { zip -r "${1%%/}" "${1%%/}"; }
# easy extract
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tgz) tar xvzf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tbz) tar xvjf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}