Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 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. playcount="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. entry="0"
  30. unset playlist
  31. while read lolname; do
  32. playlist[$entry]=$lolname
  33. # echo $entry": "${playlist[$entry]}
  34. let entry++
  35. done < playlist.txt
  36. echo "Currently Playing: "$playcount"/"${#playlist[@]}
  37. # echo ${playlist[@]}
  38. }
  39. #################################################
  40.  
  41. ##########-=Input File Analysis=-###########
  42. moviePath=$1
  43.  
  44. if [ -f "$moviePath" ]; then
  45. echo "Reading moviePath as ${moviePath##*.} file"
  46. if [ ${moviePath##*.} = "txt" ]; then
  47. echo "loading txt file as playlist"
  48. cat $moviePath > playlist.txt
  49. else
  50. echo ${moviePath##*/} > playlist.txt
  51. moviePath=$(echo ${moviePath%/*})
  52. fi
  53. elif [ -d "$moviePath" ]; then
  54. echo "Reading moviePath as directory"
  55. listGen
  56. else
  57. echo "$moviePath not identified as either file or directory"
  58. exit
  59. fi
  60. moviePath=$(echo "$moviePath/")
  61. listRefresh
  62. ############################################
  63.  
  64.  
  65.  
  66. ##############-=Individual File Playback=-###############
  67.  
  68. while [ $playcount -lt ${#playlist[@]} ] ; do
  69.  
  70. ffprobe -show_streams "$moviePath${playlist[$playcount]}" > /tmp/probetmp.txt
  71.  
  72. width=$(cat /tmp/probetmp.txt | grep width | sed 's/width=//')
  73. height=$(cat /tmp/probetmp.txt | grep height | sed 's/height=//')
  74.  
  75. echo "width: $width"
  76. echo "height: $height"
  77.  
  78. if [ "$(echo "scale=0; (1000*$width*9)/($height*16)" | bc)" -ge "1000" ];then
  79. mode="widescreen"
  80. scaleFactor=$(echo "scale=0; $width*9/16" | bc)
  81. padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
  82. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  83. #padString=" -padtop "$padPixel" -padbottom "$padPixel
  84. padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
  85. else
  86. if [ "$(echo "scale=0; $width*3/4" | bc)" -gt "$height" ]; then
  87. mode="letterbox"
  88. scaleFactor=$(echo "scale=0; $width*3/4" | bc)
  89. padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
  90. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  91. #padString=" -padtop "$padPixel" -padbottom "$padPixel
  92. padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
  93. else
  94. mode="tallscreen"
  95. scaleFactor=$(echo "scale=0; $height*4/3" | bc)
  96. padTotal=$(echo "scale=0; $scaleFactor - $width" | bc)
  97. padPixel=$(echo "scale=0; $padTotal/2" | bc)
  98. #padString="-padleft "$padPixel" -padright "$padPixel
  99. padString=" -vf pad="$scaleFactor":"$height":"$padPixel":0:black"
  100. fi
  101. fi
  102.  
  103. echo "scaleFactor: $scaleFactor"
  104. echo "mode: $mode"
  105. echo "Widescreen test number: $(echo "scale=0; (1000*$width*9)/($height*16)" | bc)"
  106. echo "padTotal: $padTotal"
  107. echo "padPixel: $padPixel"
  108. echo "x264Preset: $x264Preset"
  109. echo "*****************************************"
  110. echo "PLAYING FILE ${playlist[$playcount]}"
  111. echo "*****************************************"
  112. echo $moviePath
  113.  
  114.  
  115. #ffmpeg -i "$moviePath${playlist[$playcount]}" -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"
  116. #ffmpeg -i "$moviePath${playlist[$playcount]}" -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"
  117.  
  118. let playcount++
  119. listRefresh
  120. done
  121.  
  122. #########################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement