Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. #!/bin/bash
  2. # 01/14/11
  3. # ./autopad_spaces.sh /full/path/to/media
  4. # make sure you are "priveleged" enough to write symlinks in the directory from which you are # running this script
  5.  
  6. ##########-=DEFAULTS=-#########
  7. channel="kingdomheartsforever"
  8. username=""
  9. password=""
  10.  
  11. x264Preset=$2
  12. if [ "$x264Preset" = "" ]; then
  13. x264Preset="faster"
  14. fi
  15. ################################
  16.  
  17. #########-=Functions and Declarations=-##########
  18. declare -a playlist
  19. entry="0"
  20.  
  21. function listGen
  22. {
  23. echo "generating playlist"
  24. ls -1 "$moviePath" | grep -i -e "\.avi$" -e "\.mkv$" -e "\.mpeg$" -e "\.mpg$" -e "\.mov$" > playlist.txt
  25. }
  26.  
  27. function listRefresh
  28. {
  29. while read lolname; do
  30. playlist[$entry]=$lolname
  31. # echo $entry": "${playlist[$entry]}
  32. let entry++
  33. done < playlist.txt
  34. echo "Number of files in playlist: ${#playlist[@]}"
  35. # echo ${playlist[@]}
  36. exit
  37. }
  38. #################################################
  39.  
  40. ##########-=Input File Analysis=-###########
  41. moviePath=$1
  42.  
  43. if [ -f "$moviePath" ]; then
  44. echo "Reading moviePath as ${moviePath##*.} file"
  45. if [ ${moviePath##*.} = "txt" ]; then
  46. echo "loading txt file as playlist"
  47. cat $moviePath > playlist.txt
  48. else
  49. echo $moviePath > playlist.txt
  50. fi
  51. elif [ -d "$moviePath" ]; then
  52. echo "Reading moviePath as directory"
  53. listGen
  54. else
  55. echo "$moviePath not identified as either file or directory"
  56. exit
  57. fi
  58. listRefresh
  59. ############################################
  60.  
  61.  
  62.  
  63. ffprobe -show_streams "$moviePath" > /tmp/probetmp.txt
  64.  
  65. width=$(cat /tmp/probetmp.txt | grep width | sed 's/width=//')
  66. height=$(cat /tmp/probetmp.txt | grep height | sed 's/height=//')
  67.  
  68. echo "width: $width"
  69. echo "height: $height"
  70.  
  71. if [ "$(echo "scale=0; (1000*$width*9)/($height*16)" | bc)" -ge "1000" ];then
  72. mode="widescreen"
  73. scaleFactor=$(echo "scale=0; $width*9/16" | bc)
  74. padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
  75. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  76. #padString=" -padtop "$padPixel" -padbottom "$padPixel
  77. padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
  78. else
  79. if [ "$(echo "scale=0; $width*3/4" | bc)" -gt "$height" ]; then
  80. mode="letterbox"
  81. scaleFactor=$(echo "scale=0; $width*3/4" | bc)
  82. padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
  83. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  84. #padString=" -padtop "$padPixel" -padbottom "$padPixel
  85. padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
  86. else
  87. mode="tallscreen"
  88. scaleFactor=$(echo "scale=0; $height*4/3" | bc)
  89. padTotal=$(echo "scale=0; $scaleFactor - $width" | bc)
  90. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  91. #padString="-padleft "$padPixel" -padright "$padPixel
  92. padString=" -vf pad="$scaleFactor":"$height":"$padPixel":0:black"
  93. fi
  94. fi
  95.  
  96. echo "scaleFactor: $scaleFactor"
  97. echo "mode: $mode"
  98. echo "Widescreen test number: $(echo "scale=0; (1000*$width*9)/($height*16)" | bc)"
  99. echo "padTotal: $padTotal"
  100. echo "padPixel: $padPixel"
  101. echo "x264Preset: $x264Preset"
  102.  
  103. #ffmpeg -i "$moviePath" -re -acodec libmp3lame -ac copy -ar 44100 -vcodec libx264 -vpre $x264Preset -f flv $padString "rtmp://fme.mogulus.com/mogulus/$channel/username=$username/password=$password/isAutoLive=true/autoVOD=true/autoRecord=false app=mogulus/$channel/username=$username/password=$password/isAutoLive=true/autoRecord=false tcurl=rtmp://fme.mogulus.com/mogulus/$channel/username=$username/password=$password/isAutolive=true/autoRecord=false swfUrl=rtmp://publish.livestream.com/mogulus/$channel/username=$username/password=$password/isAutolive=true/autoRecord=false flashver=FME/2.5\20(compatible;\20FMSc/0.9) live=true"
  104. #ffmpeg -i "$moviePath" -re -acodec libmp3lame -ar 44100 -ac 2 -vcodec libx264 -vpre $x264Preset -f flv $padString -threads 0 "rtmp://fme.mogulus.com/mogulus/$channel/username=$username/password=$password/isAutoLive=true/autoVOD=true/autoRecord=false app=mogulus/$channel/username=$username/password=$password/isAutoLive=true/autoRecord=false tcurl=rtmp://fme.mogulus.com/mogulus/$channel/username=$username/password=$password/isAutolive=true/autoRecord=false swfUrl=rtmp://publish.livestream.com/mogulus/$channel/username=$username/password=$password/isAutolive=true/autoRecord=false flashver=FME/2.5\20(compatible;\20FMSc/0.9) live=true"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement