nighthoodie

z264 rev B

Apr 16th, 2014
1,713
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # check file for AVC encoding and flv, wmv, or mkv wrapper and rewrap in mp4 container
  4. #   otherwise, if not already am mp4, transcode to AVC mp4
  5. ########
  6. # usage:
  7. # z264 <file>
  8. # z264 *
  9. # z264 *.ext
  10. # z264 */*
  11. ##########################
  12.  
  13. # z264 has several dependencies (mediainfo, rmtrash, ffmpeg, SublerCLI, and HandBrakeCLI)
  14. # need logic here to check for dependencies
  15. # and if missing, prompt user for how to install missing dependencies (binary or source)
  16. # for now, installation is manual
  17. # uncomment appropriate section to install, but *must* re-comment these sections to use z264)
  18. # unfinished:   xcode section, so if you can manually install xcode, the macports section should
  19. #               build the dependencies from source. HandBrakeCLI binary is most recent version.
  20. #               background_transcoder functions well, yet is still evolving; pay attention to the
  21. #               unfinished ramdisk section, as it is currently manual as well. Double check the
  22. #               command definitions for all dependecies and adjust accordingly.
  23. ##########################
  24.  
  25. ####################################################################################################
  26. ############################             **binary install**             ############################
  27. ############################         <---------BEGIN--------->          ############################
  28.  
  29. #cd="/usr/bin/cd"
  30. #mkdir="/bin/mkdir"
  31. #curl="/usr/bin/curl"
  32. #sleep="/bin/sleep"
  33. #sudo="/usr/bin/sudo"
  34. #unzip="/usr/bin/unzip"
  35. #cp="/bin/cp"
  36. #rm="/bin/rm"
  37. #mv="/bin/mv"
  38. #installer="/usr/sbin/installer"
  39.  
  40. #location to install binary dependencies:
  41. #install_target="/usr/local/bin"
  42. #make sure install_target is in your path
  43. #echo 'export PATH=$PATH:"$install_target"' >> ~/.profile"
  44.  
  45. #make a working directory to collect the binary dependencies
  46. #cd; mkdir z264_binary_dependencies; cd z264_binary_dependencies/
  47.  
  48. #download wget, and install in $install_target
  49. #curl -O  http://www.statusq.org/wp-content/uploads/2008/07/wget.zip >/dev/null
  50. #sleep 1
  51. #unzip wget.zip >/dev/null
  52. #sudo mv -nv wget/wget "$install_target"/
  53. #rm -rf "__MACOSX/"; rm -rf wget/ #clean up
  54. #sudo chmod 755 "$install_target"/wget
  55. #
  56. #wget="$install_target/wget"
  57.  
  58. #download mediainfo, and install in $install_target
  59. #wget http://mediaarea.net/download/binary/mediainfo/0.7.66/MediaInfo_CLI_0.7.66_Mac.dmg >/dev/null
  60. #hdiutil attach -quiet -noverify -nobrowse -noautoopen MediaInfo_CLI_0.7.66_Mac.dmg
  61. #sleep 1
  62. #sudo installer -pkg /Volumes/MediaInfo\ CLI/MediaInfo\ CLI.pkg -target / >/dev/null
  63. #(note: MediaInfo\ CLI.pgk targets /usr/local/bin by default)
  64. #hdiutil detach -quiet /Volumes/MediaInfo\ CLI
  65. #sudo chmod 755 /usr/local/bin/mediainfo
  66. #
  67. #mediainfo="/usr/local/bin/mediainfo" #no choice, that's where it installs
  68.  
  69. #download rmtrash, and install in $install_target
  70. #wget http://www.nightproductions.net/downloads/rmtrash.tar.gz >/dev/null
  71. #tar xvfz rmtrash.tar.gz >/dev/null
  72. #sudo mv -n rmtrash/rmtrash "$install_target"/
  73. #sudo chmod 755 "$install_target"/rmtrash
  74. #rm -rf rmtrash/ #clean up
  75. #
  76. #rmtrash="$install_tartet/rmtrash"
  77.  
  78. #download ffmpeg, and install in $install_target
  79. #wget http://www.evermeet.cx/ffmpeg/ffmpeg-2.1.4.7z >/dev/null
  80. #wget http://rudix.googlecode.com/files/p7zip-9.04-0.i386.dmg >/dev/null
  81. #hdiutil attach -quiet -noverify -nobrowse -noautoopen p7zip-9.04-0.i386.dmg
  82. #sudo installer -pkg /Volumes/p7zip.pkg/p7zip.pkg -target / >/dev/null
  83. #(note: p7zip.pkg targets /usr/local/bin by default)
  84. #hdiutil detach -quiet /Volumes/p7zip.pkg
  85. #7z="/usr/local/bin/7z"
  86. #7z e ffmpeg-2.1.4.7z >/dev/null
  87. #sudo mv -n ffmpeg "$install_target"/
  88. #sudo chmod 755 "$install_target"/ffmpeg
  89. #
  90. #ffmpeg="$install_target/ffmpeg"
  91.  
  92. #download SublerCLI, and install in $install_target
  93. #wget http://subler.googlecode.com/files/SublerCLI-0.19.zip >/dev/null
  94. #unzip SublerCLI-0.19.zip >/dev/null
  95. #sudo mv -n SublerCLI $install_target"/
  96. #sudo chmod 755 "$install_target"/SublerCLI
  97. #
  98. #SublerCLI="$install_target/SublerCLI"
  99.  
  100. #download HandBrakeCLI, and install in $install_target
  101. #wget http://sourceforge.net/projects/handbrake/files/0.9.9/HandBrake-0.9.9-MacOSX.6_CLI_x86_64.dmg >/dev/null
  102. #hdiutil attach -quiet -noverify -nobrowse -noautoopen HandBrake-0.9.9-MacOSX.6_CLI_x86_64.dmg
  103. #sudo cp -np /Volumes/HandBrake-0.9.9-MacOSX.6_CLI_x86_64/HandBrakeCLI "$install_target"/
  104. #sudo chmod 755 "$install_target"/HandBrakeCLI
  105. #hdiutil detach -quiet /Volumes/HandBrake-0.9.9-MacOSX.6_CLI_x86_64.dmg
  106. #
  107. #HandBrakeCLI="$install_target/HandBrakeCLI"
  108.  
  109. #cd; rm -rf z264_binary_dependencies #clean up working directory
  110. #echo "end of binary installation"; exit
  111.  
  112. ############################             **binary install**             ############################
  113. ############################         <----------END---------->          ############################
  114. ####################################################################################################
  115.  
  116. ####################################################################################################
  117. ############################             **source install**             ############################
  118. ############################         <---------BEGIN--------->          ############################
  119.  
  120. #check for xcode
  121. ############
  122. #convention is to check if /usr/bin/xcodebuild; then xcodebuild -version && xcode-select -print-path
  123. #
  124. #developer="/Developer"
  125. #ports_dir="/opt"
  126. #echo="/bin/echo"
  127. #curl="/usr/bin/curl"
  128. #tar="/usr/bin/tar"
  129. #cd="/usr/bin/cd"
  130. #sudo="/usr/bin/sudo"
  131. #make="/usr/bin/make"
  132. #sleep="/bin/sleep"
  133. #rm="/bin/rm"
  134. #   if [ ! -d "$developer" ]; then      ##########################################
  135. #       echo ""
  136. #       echo "install xcode: http://guide.macports.org/#installing.xcode"; echo ""
  137. #       open "http://guide.macports.org/#installing.xcode"
  138. #       open "developer.apple.com"
  139. #       exit; # haven't completed this section yet, manually download xcode and install
  140. #       #check system version
  141. #       #auth to https://developer.apple.com with u264 developer accounts randomized list
  142. #       #check OS version and download appropriate xcode version dmg
  143. #       #hdiutil attach -quiet -noverify -nobrowse -noautoopen $xcode.dmg
  144. #       #verify minimal_xcode_install.sh is sufficient for building dependencies
  145. #       if [ `$[RANDOM%2+1]`!="1" ]; then
  146. #       accountname="u264.appleID.00@gmail.com"
  147. #       accountpassword="u264,ID00"
  148. #       else
  149. #       accountname="u264.appleID.01@gmail.com"
  150. #               accountpassword="u264,ID01"
  151. #       fi
  152. #       # Log in to the server.  This can be done only once.
  153. #       wget --save-cookies cookies.txt --post-data 'accountname=$account&accountpassword=$word' https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?&appIdKey=891bd3417a7776362562d2197f89480a8547b108fd934911bcbea0110d07f757&path=%2F%2Fmembercenter%2Findex.action --ignore-certificate
  154. #
  155. #   # Now grab the page or pages we care about.
  156. #   wget --load-cookies cookies.txt -p https://haven't_collected_the_target_xcode_urls_yet --ignore-certificate
  157. #
  158. #
  159. #   else
  160. #check for macports
  161. ############
  162. #       #echo ""; echo "-->   checking for macports..."; echo ""
  163. #       #install macports https://www.macports.org/install.php
  164. #       if [ ! -d "$ports_dir" ]; then
  165. #           #echo ""; echo "---->   macports is not installed"; echo ""
  166. #           #echo ""; echo "-->   building macports"; echo ""
  167. #           curl -Ok https://distfiles.macports.org/MacPorts/MacPorts-2.1.1.tar.gz >/dev/null
  168. #           tar xzvf MacPorts-2.1.1.tar.gz      >/dev/null
  169. #           cd MacPorts-2.1.1
  170. #           ./configure                 >/dev/null 2>>$HOME/error_log.txt
  171. #           sleep 5
  172. #           make                    >/dev/null 2>>$HOME/error_log.txt
  173. #           sudo make install # not war!        >/dev/null 2>>$HOME/error_log.txt
  174. #           sleep 1
  175. #           #echo ""; echo "-->   macports build complete"; echo ""
  176. #           cd ..
  177. #           rm -rf MacPorts-*
  178. #           sudo /opt/local/bin/port -qfp selfupdate    >/dev/null
  179. #           #echo ""; echo "use the built-in shell command 'export' to set your PATH follows:"; echo ""
  180. #           #echo "export PATH="$PATH:$HOME/bin:/opt/local/bin:/opt/local/sbin:"\
  181. #               "/opt/local/share/man:/Developer/usr/bin:/Developer/usr/sbin:/usr/X11/bin""
  182. #           #echo ""
  183. #           sudo chflags hidden /opt
  184. #           #echo ""
  185. #           port="/opt/local/bin/port"
  186. #           #echo ""
  187. #
  188. #install dependencies from source
  189. ############
  190. #           sudo port -qsk install mediainfo rmtrash ffmpeg `#handbrake` >/dev/null 2>$HOME/error_log.txt
  191. #          
  192. #clean up macports
  193. ############
  194. #           #echo ""; echo "-->   upgrade outdated ports..."
  195. #           sudo port -qsfuck upgrade outdated              >/dev/null
  196. #           #echo ""; echo "----> outdated ports upgraded"
  197. #
  198. #           sudo port -qfcup uninstall --follow-dependencies inactive   >/dev/null
  199. #           #echo ""; echo "----> inactive ports and dependencies uninstalled"; echo ""
  200. #
  201. #           #echo ""; echo "-->   cleaning all installed ports..."
  202. #           sudo port -qfp clean installed                  >/dev/null
  203. #           #echo ""; echo "----> all installed ports cleaned"; echo ""
  204. #
  205. #           #echo ""; echo "-->   selfupdating ports..."
  206. #           sudo port -qfp selfupdate                   >/dev/null
  207. #           #echo ""; echo "----> ports selfupdated"; echo ""
  208. #          
  209. #           #echo ""; echo "-->   repairing and verifying permissions..."
  210. #           diskutil quiet repairPermissions /              #>/dev/null
  211. #           #diskutil quiet verifyPermissions /             #>/dev/null
  212. #           #echo ""; echo "----> permissions repaired and verified"; echo
  213. #           #echo ""; echo "-->   optimizing system for installed software..."
  214. #           #echo ""; echo "-->   optimizing system for installed software..."
  215. #           /usr/bin/update_dyld_shared_cache -force            >/dev/null 2>&1 &
  216. #                      
  217. #       fi
  218. #   fi
  219. #exit
  220.  
  221. ############################             **source install**             ############################
  222. ############################         <----------END---------->          ############################
  223. ####################################################################################################
  224.  
  225.  
  226.  
  227. # Define commands
  228. ############
  229. rd_path="/Volumes/Two"
  230. ls="/bin/ls"
  231. mediainfo="/opt/local/bin/mediainfo" # deep media analysis
  232. #grep="/usr/bin/grep"
  233. echo="/bin/echo"
  234. cut="/usr/bin/cut"
  235. mv="/bin/mv"
  236. rmtrash="/opt/local/bin/rmtrash"  # move to Trash
  237. nll=`(>/dev/null)`
  238. ffmpeg="/opt/local/bin/ffmpeg"
  239. SublerCLI="$HOME/bin/SublerCLI"
  240. ########################################  HandBrake World  #########################################
  241. ############################         **background_transcoder**          ############################
  242. ############################         <---------BEGIN--------->          ############################
  243. background_transcoder () {
  244. ##########################
  245. #########################
  246. ## +-+-+-+-+-+-+-+-+-+-+-+-+ ##
  247. ##    |H|a|n|d|B|r|a|k|e|C|L|I|   ##
  248. ## +-+-+-+-+-+-+-+-+-+-+-+-+ ##
  249. #########################
  250. ##########################
  251. #
  252. # video:
  253. #   --crop T:B:L:R
  254. #   -d -5 -7 -8  - d=deinterlace, 5=decomb, 7=deblock, 8=denoise
  255. # audio:
  256. #-a 1 -E aac --audio-copy-mask aac --audio-fallback ca_aac -B $ab -R $arate
  257. #-6 $mix -4 --loose-anamorphic --audio-copy-mask acc
  258. #
  259. ############################
  260. ############################
  261. purge="/usr/bin/purge"
  262. mediainfo="/opt/local/bin/mediainfo"
  263. rmtrash="/opt/local/bin/rmtrash"
  264. time="usr/bin/time"
  265. HandBrakeCLI="$HOME/bin/HandBrakeCLI"
  266. sleep="/bin/sleep"
  267. mv="/bin/mv"
  268. #wait="/usr/bin/wait"
  269. ############################
  270. #check the amount of free RAM
  271. #vm_stat="/usr/bin/vm_stat"
  272. #awk="/usr/bin/awk"
  273. #free="$(( $(vm_stat | awk '/free/ {gsub(/\./, "", $3); print $3}') * 4096 / 1048576)) MiB free RAM"
  274. #echo $free
  275. #accurately estimate output file size
  276. ############################
  277. #first set up 4 part formula to estimate output file final_size
  278. # 1: fps x width x height x bitdepth x duration = uncompressed_size
  279. # 2: uncompressed_size / ratio = compressed_video_size
  280. # 3: audio_bitrate x duration = compressed_audio_size
  281. # 4: compressed_video_size + compressed_audio_size = final_size
  282. ########    1:
  283. #   fps=`mediainfo --Inform="Video;%FrameRate%" "$1"`
  284. #   width=`mediainfo  "--Inform=Video;%Width%" "$1"`
  285. #   height=`mediainfo  "--Inform=Video;%Height%" "$1"`
  286. #   bitdepth=`mediainfo --Inform="Video;%BitDepth%" "$1"`
  287. #   duration=`mediainfo --Inform="General;%Duration%" "$1"`
  288. #   uncompressed_size=$(expr $fps \* $width \* $height \* $bitdepth \* $duration)
  289. ########    2:
  290. #   #QLTY="20" # $QLTY is user defined HandBrakeCLI "q"
  291. #   ratio=$(expr $QLTY / 100)
  292. #   compressed_video_size=$(expr $uncompressed_size / $ratio)
  293. ########    3:
  294. #   audio_bitrate=`mediainfo --Inform="Audio;%BitRate%" "$1"`
  295. #   compressed_audio_size=$(expr $audio_bitrate \* $duration)
  296. ########    4:
  297. #   final_size=$(expr $compressed_video_size + $compressed_audio_size)
  298. #   wiggle_room=$(expr $final_size / 10)
  299. ############################
  300. ######## ramdisk
  301. #then check ram, and if enough, make a ramdisk named "$1"rd that size + 10% wiggle room
  302. #   size=$(expr $final_size + $wiggle_room)
  303. #   diskutil quiet erasevolume HFS+ '"$1"rd' `hdiutil attach -nomount ram://$size` 
  304. #   chflags hidden /Volumes/"$1"rd
  305. #   rd_path="/Volumes/"$1"rd
  306. #need logic to decide if there's enough ram, and if so, do all that---^
  307. #but for now just create a 2GB ramdisk called "Two" and leave it there
  308. #size="4194304"     # 1024 x MB you want x 2048
  309. #diskutil quiet erasevolume HFS+ 'Two' `hdiutil attach -nomount ram://$size`
  310. rd_path="/Volumes/Two"
  311. ############################     HandBrakeCLI user defined variables     ############################
  312. QLTY="20"   #-q setting (worse/smaller/faster > 20 > better/bigger/slower)
  313. #max="1024" #dimensions in pixels  -X $max "960"
  314. may="720"   #dimensions in pixels  -Y $may "640"
  315. arate="Auto"
  316.             #audio samplerate (22.05/24/32/44.1/48 kHz/Auto)
  317. fa="2"      #--rotate=< 0-none 1-xflip 2-yflop 3-flipflop/180°>
  318. pre_ab=`mediainfo "--Inform=Audio;%BitRate%" "$1"` 
  319.             #get bitrate of source file in bits/s
  320. ab=$(expr $pre_ab / 1000)
  321.             #average audio bitrate in kb/s (-B)
  322. mix="stereo"
  323.             #(mono/stereo/dpl1/dpl2/6ch, default: dpl2)
  324. sdt="placebo"
  325.             #(ultrafast, superfast, veryfast, faster, fast, medium, slow, slower,
  326.             # veryslow, placebo) "best is probably the slowest tolerable" <--Seriously?
  327. tune="fastdecode"
  328.             #(film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency)
  329. h264P="high"
  330.             #(main, high) h.264 profile
  331. h264L="3.1" #(3.1,4.1)    h.264 level
  332. dblk="7"    #-7 --deblock=<QP:M> mplayer pp7 deblock filter, default is 5
  333. x_opts="qpmin=4:cabac=0:ref=2:b-pyramid=none:weightb=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500"
  334. ############################            **background_transcoder**       ############################
  335. purge
  336. sleep 1.25
  337. width=`mediainfo "--Inform=Video;%Width%" "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v`
  338. height=`mediainfo "--Inform=Video;%Height%" "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v`
  339. nn=`(echo "$1" | cut -c1-17)`
  340. time HandBrakeCLI -i "$1" -o "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v -e x264 -q $QLTY -r 30 --pfr -Y $may -O --rotate=$fa -5 -7 $dblk -a 1 -E copy:acc --audio-copy-mask aac --audio-fallback ca_aac -B $ab -R $arate -6 $mix -4 --modulus 16 -m --x264-preset $sdt --x264-tune $tune --h264-profile $h264P --h264-level $h264L -x $x_opts >/dev/null 2>&1
  341. echo "$1"; echo ""
  342. sleep 2
  343. width=`mediainfo "--Inform=Video;%Width%" "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v`
  344. height=`mediainfo "--Inform=Video;%Height%" "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v`
  345. nn=`(echo "$1" | cut -c1-17)`
  346. mv -n "$rd_path"/"$1"_"$sdt"_q"$QLTY"_f"$fa"_.m4v ./"$nn"_"$sdt"_q"$QLTY"_f"$fa"_"$width"x"$height"p.m4v
  347. rmtrash "$1"
  348. sleep 1
  349. #hdiutil detach quiet /Volumes/"$1"rd # detach each ramdisk after each transcode and output is moved to ./
  350. }
  351. ############################         **background_transcoder**          ############################
  352. ############################         <----------END---------->          ############################
  353. ########################################  HandBrake World  #########################################
  354.  
  355. ########################################################################################################
  356. ################################################# z264 #################################################
  357. ########################################################################################################
  358.  
  359.  
  360.     while [ "$1" != "" ]
  361.       do
  362.       echo "Analyzing: "
  363.       echo "    "$1"..."
  364.       xray=`mediainfo  "--Inform=Video;%Format%" "$1"`
  365.       width=`mediainfo  "--Inform=Video;%Width%" "$1"`
  366.       height=`mediainfo  "--Inform=Video;%Height%" "$1"`
  367.       #******************************************************************
  368.       if [[ $1 == *.flv ]] || [[ $1 == *.wmv ]] || [[ $1 == *.mov ]] || \
  369.          [[ $1 == *.FLV ]] || [[ $1 == *.WMV ]] || [[ $1 == *.MOV ]]; then
  370.         #######################--- 1 ---############################
  371.         if [ "$xray" = "AVC" ]; then
  372.             bullseye="$xray"
  373.             Adv="AVC"
  374.         else
  375.             bullseye=`echo "missed"`
  376.             Adv=`echo "no_match"`
  377.         fi
  378.         #######################--- 1 ---############################
  379.  
  380.         #######################--- 2 ---############################
  381.         if [ "$Adv" = "$bullseye" ];
  382.             then
  383.                 echo "  yes," $1
  384.                 echo "  is encoded with the ("$bullseye")"
  385.                 echo "  using ffmpeg for lossless rewrap in mp4 container..."
  386.                 ffmpeg -loglevel panic -i "$1" -vcodec copy -acodec copy $rd_path/"$1".mp4 |$nll
  387.                 rmtrash "$1" #move original file to the Trash
  388.                 SublerCLI -source $rd_path/"$1".mp4 -dest "$1"_"$width"x"$height"p.mp4 -removemetadata -itunesfriendly -optimize |$nll
  389.                 rm $rd_path/"$1".mp4 #clean it off the ramdisk
  390.                 echo ""
  391.  
  392.             else
  393.                 echo "  no," $1
  394.                 echo "  is encoded with $xray"
  395.                 echo "  transcoding" $1"... with HandBrake to AVC mp4"
  396.                 echo "  in the background, please standby while process is spawned..."
  397.                 background_transcoder "$1" &
  398.                 sleep 8
  399.                 echo ""
  400.                 echo "  please remember this background process is still running!"
  401.                 echo ""; sleep 5;
  402.                 echo "      *background process has been spawned*"; sleep 2; echo ""
  403.                 echo "  moving on..."; sleep 2
  404.                 echo ""
  405.         fi
  406.         #######################--- 2 ---############################
  407.  
  408.       else
  409.         ########################--- check for matroska ---###################
  410.         if [[ $1 == *.mkv ]]; then
  411.             echo "  "$1 "is encoded with $xray"
  412.             echo "  but is wrapped in matroska!"
  413.             echo "  using ffmpeg for lossless rewrap in mp4 container..."
  414.             aray=`mediainfo  "--Inform=Audio;%Format%" "$1"`
  415.             brate=`mediainfo  "--Inform=Audio;%BitRate%" "$1"`
  416.             srate=`mediainfo  "--Inform=Audio;%SamplingRate%" "$1"`
  417.             if [ $aray = "AAC" ] && [ $brate -le 160000 ];
  418.                 then
  419.                     ffmpeg -loglevel panic -i "$1" -vcodec copy -acodec copy $rd_path/"$1".mp4 |$nll
  420.                 else
  421.                     #audio bitrate too high, transcode audio
  422.                     echo ""; echo " the audio is encoded in $aray at $brate bps and $srate Hz"
  423.                     if [ $brate -gt 160000 ]
  424.                         then
  425.                             echo ""; echo " transcoding audio to aac at 160000 bps and $srate Hz..."
  426.                             ffmpeg -loglevel panic -i "$1" -vcodec copy -c:a aac -strict -2 -ab 160k -ac 2 -ar $srate $rd_path/"$1".mp4 |$nll
  427.                         else
  428.                             echo ""; echo " transcoding audio to aac at $brate bps and $srate Hz..."
  429.                             ffmpeg -loglevel panic -i "$1" -vcodec copy -c:a aac -strict -2 -ab $brate -ac 2 -ar $srate $rd_path/"$1".mp4 |$nll
  430.                     fi
  431.  
  432.             fi         
  433.             rmtrash "$1" #move original file to the Trash
  434.             SublerCLI -source $rd_path/"$1".mp4 -dest "$1"_"$width"x"$height"p.mp4 -removemetadata -itunesfriendly -optimize |$nll
  435.                 rm $rd_path/"$1".mp4 #clean it off the ramdisk
  436.             echo ""
  437.              ###################--- check other filetypes ---###################
  438.         else
  439.              if [[ $1 == *.mpg ]] || [[ $1 == *.mpeg ]] || [[ $1 == *.vob ]] || \
  440.             [[ $1 == *.MPG ]] || [[ $1 == *.MPEG ]] || [[ $1 == *.VOB ]] || \
  441.                         [[ $1 == *.avi ]] || [[ $1 == *.AVI ]]; then
  442.                 echo "  no,"$1
  443.                             echo "  is encoded with $xray"
  444.                             echo "  transcoding" $1"... with HandBrake to AVC mp4"
  445.                             echo "  in the background, please standby while process is spawned..."
  446.                             background_transcoder "$1" &
  447.                             sleep 8
  448.                             echo ""
  449.                             echo "  please remember this background process is still running!"
  450.                             echo ""; sleep 5;
  451.                             echo "      *background process has been spawned*"; sleep 2; echo ""
  452.                             echo "  moving on..."; sleep 2
  453.                             echo ""
  454.                           #############--- check for mp4 ---##############
  455.             else
  456.                  if [[ $1 == *.mp4 ]] || [[ $1 == *.m4v ]] || \
  457.                  [[ $1 == *.MP4 ]] || [[ $1 == *.M4V ]]; then
  458.                  echo " "$1
  459.                  echo " is already an mp4!"
  460.                  mv "${1}" "${1%.mp4}"_"$width"x"$height"p.mp4
  461.                      echo ""
  462.               fi
  463.               #############--- check for mp4 ---##############
  464.              fi
  465.              ###################--- check other filetypes ---###################
  466.         fi
  467.         ########################--- check for matroska ---###################
  468.       fi
  469.       #******************************************************************
  470.       echo ""
  471.       shift
  472.     done
  473.  
  474. exit
RAW Paste Data