Last active
August 29, 2015 14:07
-
-
Save okjake/7d347f26b8bdc9496b67 to your computer and use it in GitHub Desktop.
video transcoding for the web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Produces HTML5 friendly video formats | |
| # Usage (OSX): | |
| # brew install ffmpeg --with-libvpx --with-libvorbis --with-theora | |
| # curl https://gist.githubusercontent.com/okjake/7d347f26b8bdc9496b67/raw/f2c91daf1ebacc3c117d8b304403f03b157f1109/gistfile1.txt > cnv.sh && chmod u+x cnv.sh | |
| # cnv.sh /path/to/video1.mp4 /path/to/video2.mov | |
| if [ ! $# -gt 0 ]; then | |
| echo "Usage: cnv.sh file1 [file2 file3 ...]" | |
| exit | |
| fi | |
| `mkdir converted` | |
| for path in "$@" | |
| do | |
| name="${path##*/}" | |
| ffmpeg -i $path -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -preset slower -crf 18 -vf "scale=trunc(in_w/2)*2:trunc(in_h/2)*2" converted/${name%.*}.mp4 & | |
| ffmpeg -i $path -c:v libvpx -c:a libvorbis -pix_fmt yuv420p -quality good -b:v 2M -crf 5 converted/${name%.*}.webm & | |
| ffmpeg -i $path -q 5 -pix_fmt yuv420p -acodec libvorbis -vcodec libtheora converted/${name%.*}.ogv & | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment