Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 2.40 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # This shell script will process & encode a single video file, and output 3
  4. # seperate files in the following formats: WebM, Ogg Theora, & h.264 for
  5. # streaming via an HTML5 player.
  6. #
  7. # You'll need ffmpeg, ffmpeg2theora, & HandbrakeCLI installed to run this
  8. # script.  ffmpeg and ffmpeg2theora can be installed via Homebrew on a Mac.
  9. # If you're using Ubuntu, use the PPA at
  10. # https://launchpad.net/~jon-severinsson/+archive/ffmpeg
  11. # for newer versions of ffmpeg and libvpx (WebM codec).
  12. #
  13. # For the HandbrakeCLI, please visit the Handbrake website at
  14. # http://www.handbrake.fr
  15. #
  16. # Command line arguments taken from:
  17. # http://diveintohtml5.info/video.html#example
  18. #
  19. # Modifications made for resolution and quality where needed.
  20.  
  21. INPUT_FILE=$1
  22. FILENAME=${INPUT_FILE%%.*}
  23. VIDEO_WIDTH="960"
  24. VIDEO_HEIGHT="540"
  25. VIDEO_DIM=$VIDEO_WIDTH"x"$VIDEO_HEIGHT
  26.  
  27. if [ -z "$INPUT_FILE" ]; then
  28.     echo "Usage: encode4codecasts.sh FILENAME"
  29.     echo "You need to pass a video to process. Exiting"
  30.     exit
  31. fi
  32.  
  33. echo "Converting to Ogg/Theora"
  34. echo "RUNNING: ffmpeg2theora --videoquality 7 --width $VIDEO_WIDTH --output $FILENAME.ogv $INPUT_FILE"
  35.  
  36. ffmpeg2theora --videoquality 7 --width $VIDEO_WIDTH --output $FILENAME.ogv $INPUT_FILE
  37.  
  38. echo "Converting to h.264"
  39. echo "RUNNING: HandBrakeCLI --preset "iPhone 4" --width $VIDEO_WIDTH --two-pass --turbo --optimize --input $INPUT_FILE --output $FILENAME.mp4"
  40.  
  41. HandBrakeCLI --preset "iPhone 4" --width $VIDEO_WIDTH --two-pass --turbo --optimize --input $INPUT_FILE --output $FILENAME.mp4
  42.  
  43. echo "Converting to WebM"
  44. echo "RUNNING: ffmpeg -pass 1 -passlogfile $INPUT_FILE -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i $INPUT_FILE -vcodec libvpx -b 204800 -s $VIDEO_DIM -an -f webm -y NUL"
  45.  
  46. ffmpeg -pass 1 -passlogfile $INPUT_FILE -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i $INPUT_FILE -vcodec libvpx -b:v 204800 -s $VIDEO_DIM -an -f webm -y $FILENAME.webm
  47.  
  48. echo "WebM - First pass complete"
  49. echo "WebM - Starting second pass"
  50.  
  51. echo "RUNNING: ffmpeg -pass 2 -passlogfile $INPUT_FILE -threads 16  -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i $INPUT_FILE -vcodec libvpx -b 204800 -s $VIDEO_DIM -acodec libvorbis -ac 2 -y $FILENAME.webm"
  52.  
  53. ffmpeg -pass 2 -passlogfile $INPUT_FILE -threads 16  -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i $INPUT_FILE -vcodec libvpx -b:v 204800 -s $VIDEO_DIM -acodec libvorbis -ac 2 -y $FILENAME.webm
  54.  
  55. echo "DONE"