Advertisement
Guest User

Untitled

a guest
Dec 7th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. BITRATE=300k
  4. SOURCE=$1
  5. TARGET=$2
  6.  
  7. if [ $# -lt 2 ]; then
  8. echo "usage: $(basename $0) <input> <output>"
  9. exit 1
  10. fi
  11.  
  12. while getopts "b:t:h" flag
  13. do
  14. case $flag in
  15. b )
  16. BITRATE="$OPTARG"
  17. ;;
  18. t )
  19. THREADS="$OPTARG"
  20. ;;
  21. h )
  22. echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
  23. echo " -b Specify the Bitrate. Should be between 200k and 1500k."
  24. echo " Note: The \"k\" is needed. e.g. \"512k\""
  25. echo " -h help (this help message)"
  26. echo " -t Specify the number of threads. This will default to the number of CPUS found."
  27. echo ""
  28. echo "example: `basename $0` -b 512k -t 2 some_video_file.avi target_video_file.mp4"
  29. exit 1
  30. ;;
  31. \? )
  32. echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
  33. echo "Use \"`basename $0` -h\" for more information"
  34. exit 1
  35. ;;
  36. * )
  37. echo "Usage: `basename $0` [-b bitrate] [-t numOfThreads] [-h]"
  38. echo "Use \"`basename $0` -h\" for more information"
  39. exit 1
  40. ;;
  41. esac
  42. done
  43. shift $(($OPTIND - 1))
  44.  
  45. if [ -z "$BITRATE" ]
  46. then
  47. BITRATE=300k
  48. fi
  49.  
  50. if [ -z "$THREADS" ]
  51. then
  52. THREADS=$(grep -c "^processor" /proc/cpuinfo)
  53. fi
  54.  
  55. if [ -e ./.CONVERTED ]
  56. then
  57. echo "CONVERTED FILE Found"
  58. echo 'This has probably already been converted!'
  59. exit 1
  60. fi
  61.  
  62. #Pass 1
  63. ffmpeg -threads $THREADS -y -i "$SOURCE" -s 480x272 -vcodec libx264 -b $BITRATE -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 \
  64. -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bt $BITRATE -maxrate 4M -bufsize 4M \
  65. -level 21 -r 30000/1001 -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -f mp41 -aspect 480:272 -acodec libfaac -ac 2 -ar 48000 -ab 128k -pass 1 "$TARGET"
  66.  
  67. #Pass 2
  68. ffmpeg -threads $THREADS -y -i "$SOURCE" -s 480x272 -vcodec libx264 -b $BITRATE -flags +loop -cmp +chroma -me_range 16 -g 300 -keyint_min 25 \
  69. -sc_threshold 40 -i_qfactor 0.71 -rc_eq "blurCplx^(1-qComp)" -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 1 -bt $BITRATE -maxrate 4M -bufsize 4M \
  70. -level 21 -r 30000/1001 -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -f mp41 -aspect 480:272 -pass 2 -acodec libfaac -ac 2 -ar 48000 -ab 128k -vol 320 "$TARGET"
  71.  
  72. if [ $? -eq 0 ]
  73. then
  74. touch .CONVERTED
  75. fi
  76.  
  77. # Clean up any temporary logs created by ffmpeg
  78. rm -f *log
  79. rm -f *dump
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement