Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # 01/14/11
- # ./autopad_spaces.sh /full/path/to/media
- # make sure you are "priveleged" enough to write symlinks in the directory from which you are # running this script
- ##########-=DEFAULTS=-#########
- channel="kingdomheartsforever"
- username=""
- password=""
- x264Preset=$2
- if [ "$x264Preset" = "" ]; then
- x264Preset="faster"
- fi
- ################################
- #########-=Functions and Declarations=-##########
- declare -a playlist
- entry="0"
- function listGen
- {
- echo "generating playlist"
- ls -1 "$moviePath" | grep -i -e "\.avi$" -e "\.mkv$" -e "\.mpeg$" -e "\.mpg$" -e "\.mov$" > playlist.txt
- }
- function listRefresh
- {
- while read lolname; do
- playlist[$entry]=$lolname
- # echo $entry": "${playlist[$entry]}
- let entry++
- done < playlist.txt
- echo "Number of files in playlist: ${#playlist[@]}"
- # echo ${playlist[@]}
- exit
- }
- #################################################
- ##########-=Input File Analysis=-###########
- moviePath=$1
- if [ -f "$moviePath" ]; then
- echo "Reading moviePath as ${moviePath##*.} file"
- if [ ${moviePath##*.} = "txt" ]; then
- echo "loading txt file as playlist"
- cat $moviePath > playlist.txt
- else
- echo $moviePath > playlist.txt
- fi
- elif [ -d "$moviePath" ]; then
- echo "Reading moviePath as directory"
- listGen
- else
- echo "$moviePath not identified as either file or directory"
- exit
- fi
- listRefresh
- ############################################
- ffprobe -show_streams "$moviePath" > /tmp/probetmp.txt
- width=$(cat /tmp/probetmp.txt | grep width | sed 's/width=//')
- height=$(cat /tmp/probetmp.txt | grep height | sed 's/height=//')
- echo "width: $width"
- echo "height: $height"
- if [ "$(echo "scale=0; (1000*$width*9)/($height*16)" | bc)" -ge "1000" ];then
- mode="widescreen"
- scaleFactor=$(echo "scale=0; $width*9/16" | bc)
- padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
- padPixel=$(echo "scale=0; $padTotal/2" | bc)
- #padString=" -padtop "$padPixel" -padbottom "$padPixel
- padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
- else
- if [ "$(echo "scale=0; $width*3/4" | bc)" -gt "$height" ]; then
- mode="letterbox"
- scaleFactor=$(echo "scale=0; $width*3/4" | bc)
- padTotal=$(echo "scale=0; $scaleFactor - $height" | bc)
- padPixel=$(echo "scale=0; $padTotal/2" | bc)
- #padString=" -padtop "$padPixel" -padbottom "$padPixel
- padString=" -vf pad="$width":"$scaleFactor":0:"$padPixel":black"
- else
- mode="tallscreen"
- scaleFactor=$(echo "scale=0; $height*4/3" | bc)
- padTotal=$(echo "scale=0; $scaleFactor - $width" | bc)
- padPixel=$(echo "scale=0; $padTotal/2" | bc)
- #padString="-padleft "$padPixel" -padright "$padPixel
- padString=" -vf pad="$scaleFactor":"$height":"$padPixel":0:black"
- fi
- fi
- echo "scaleFactor: $scaleFactor"
- echo "mode: $mode"
- echo "Widescreen test number: $(echo "scale=0; (1000*$width*9)/($height*16)" | bc)"
- echo "padTotal: $padTotal"
- echo "padPixel: $padPixel"
- echo "x264Preset: $x264Preset"
- #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"
- #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