This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 23rd, 2011  |  syntax: Bash  |  size: 1.03 KB  |  views: 239  |  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. # Run this script in the dir containing all the flv files you wish to convert to x264.
  3. # There are no arguments. The script will copy both the audio and video bitrates into
  4. # the new file via mediainfo.
  5.  
  6. IFS=$'\012'
  7. for file in $(find -maxdepth 1 -mindepth 1 -iname '*.flv'); do
  8.         # find flv bitrate for video and audio
  9.         vkbps=$(perl -e "print $(mediainfo --inform="Video;%BitRate%" "${file}") / 1000")
  10.         akbps=$(perl -e "print $(mediainfo --inform="Audio;%BitRate%" "${file}") / 1000")
  11.         outputname="${file%.*}.mkv"
  12.  
  13.         echo filename is ${file}
  14.         echo videobit rate set to ${vkbps}
  15.         echo audobit rate set to ${akbps}
  16.  
  17.         # do not overwrite existing mkv's
  18.         if [[ -e $outputname ]]; then
  19.                 echo >&2 Output file already exists: $outputname
  20.                 echo >&2 Skipping...
  21.                 echo >&2
  22.  
  23.                 continue
  24.         fi
  25.  
  26.         HandBrakeCLI -i "${file}" -o "${outputname}" --encoder x264 bframes=2:subme=6:mixed-refs=0:weightb=0:ref=5:8x8dct=0:me=umh:direct=temporal:trellis=0:b-adapt=2 --vb ${vkbps} -2 -T --aencoder faac -B ${akbps} || rm -f -- "$outputname"
  27. done
clone this paste RAW Paste Data