nanogyth

Untitled

Apr 10th, 2012
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @ECHO OFF & ECHO NGcode version BETA 0
  2. IF [%1]==[] ECHO drag+drop .avs & PAUSE & GOTO :EOF
  3. set AR_num=4
  4. set AR_den=3
  5. set sar=--sar 7:6
  6. set x264_flags=--crf 20 --keyint 600 --preset veryslow --no-fast-pskip --merange 64 --rc-lookahead 250 --bframes 16
  7. :: fast flags when debugging, comment out line for submissions
  8. :: set x264_flags=--preset ultrafast
  9.  
  10. set NGcode=%~dp0
  11. set PATH=C:\Users\vehi\Desktop\lib;%PATH%
  12. set ng_lib="%NGcode%\NGcode.avs"
  13.  
  14. set avs="%~1"
  15. call :clean_filename %avs% fn
  16.  
  17. ::%NGcode% is where the bat file is
  18. ::%CD% is where the .avs is
  19. ::set working_dir=C:\temp\%fn%
  20. set working_dir=%NGcode%\tmp\%fn%
  21. set finish_dir=%CD%
  22. :: set finish_dir=%CD%\%fn%_done
  23.  
  24. set mp45="%finish_dir%\%fn%_512kb.mp4"
  25. set mp4p="%finish_dir%\%fn%.mp4"
  26. set mp4x="%finish_dir%\%fn%_10bit444.mp4"
  27. set mkvy="%finish_dir%\%fn%_YT.mkv"
  28.  
  29. if not exist "%working_dir%\" mkdir "%working_dir%"
  30. if not exist "%finish_dir%\" mkdir "%finish_dir%"
  31. cd "%working_dir%"
  32.  
  33. call :make_your_time
  34. call :make_audio
  35. call :make_512
  36. call :make_primary
  37. call :make_10bit
  38. call :make_YT
  39.  
  40. echo.
  41. echo ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
  42. echo ] Remember to delete the temp files [
  43. echo [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
  44. echo.
  45.  
  46. pause
  47. goto:eof
  48.  
  49. :make_your_time
  50. if exist times.txt if exist dupinfo.txt goto:eof
  51. (
  52.   echo Import^(%ng_lib%^)
  53.   echo TestSource^(%avs%^)
  54.   echo ExactDedup
  55. ) > times.avs
  56. avs2pipemod -benchmark times.avs
  57. goto:eof
  58.  
  59. :make_audio
  60. if exist a.mp4 if exist a_track1.nhml goto:eof
  61. (
  62.   echo Import^(%ng_lib%^)
  63.   echo AviSource^(%avs%^)
  64.   echo AudioTrimSample^(4672^)
  65. ) > aac.avs
  66. avs2pipemod -extwav aac.avs | neroAacEnc -q 0.25 -ignorelength -if - -of a.mp4
  67. MP4Box a.mp4 -nhml 1
  68. goto:eof
  69.  
  70. :make_512
  71. if exist %mp45% goto:eof
  72. (
  73.   echo Import^(%ng_lib%^)
  74.   echo AviSource^(%avs%^)
  75.   echo Resize512^(%AR_num%, %AR_den%^)
  76.   echo RGBtoYV12
  77. ) > 5.avs
  78. set flags=%x264_flags% 5.avs -o 5.mp4 --input-range pc --range pc
  79. x264_8 %flags% --slow-firstpass --pass 1 2>&1 | mtee x264_1pass.log
  80. FOR /F "tokens=7 delims=. " %%G IN ('TYPE x264_1pass.log ^| FIND "encoded"') DO (
  81.     IF %%G GTR 520 (
  82.         x264_8 %flags% --bitrate 512 --pass 2 --nr 1000
  83.     )
  84. )
  85. MP4Box -add 5.mp4 -add a.mp4 -hint -new %mp45%
  86. goto:eof
  87.  
  88. :make_primary
  89. if exist %mp4p% goto:eof
  90. (
  91.   echo Import^(%ng_lib%^)
  92.   echo AviSource^(%avs%^)
  93.   echo ExactDedup^(firstpass=false^)
  94.   echo RGBtoYV12
  95. ) > p.avs
  96. x264_8 %x264_flags% p.avs -o p.264 --tcfile-in times.txt %sar% --input-range pc --range pc
  97. MP4Box -add p.264 -new p.mp4
  98. MP4Box p.mp4 -nhml 1
  99. NHMLFixup2 -t times.txt p_track1.nhml a_track1.nhml
  100. MP4Box -add p_track1.nhml -add a_track1.nhml -new %mp4p%
  101. goto:eof
  102.  
  103. :make_10bit
  104. if exist %mp4x% goto:eof
  105. (
  106.   echo Import^(%ng_lib%^)
  107.   echo AviSource^(%avs%^)
  108.   echo ExactDedup^(firstpass=false^)
  109. ) > x.avs
  110. x264_10 %x264_flags% x.avs -o x.264 --tcfile-in times.txt %sar% --output-csp i444 --range pc
  111. MP4Box -add x.264 -new x.mp4
  112. MP4Box x.mp4 -nhml 1
  113. NHMLFixup2 -t times.txt x_track1.nhml a_track1.nhml
  114. MP4Box -add x_track1.nhml -add a_track1.nhml -new %mp4x%
  115. goto:eof
  116.  
  117. :make_YT
  118. if exist %mkvy% goto:eof
  119. avs2pipemod -extwav %avs% > a.wav
  120. (
  121.   echo Import^(%ng_lib%^)
  122.   echo AviSource^(%avs%^)
  123.   echo TASBlend
  124.   echo PointResize^(8 * width, 8 * height^)
  125. ) > y.avs
  126. x264_8 y.avs -o y.mkv --qp 0 --keyint infinite --output-csp i420 --range tv --colormatrix bt470bg
  127. mkvmerge -o %mkvy% y.mkv a.wav
  128. goto:eof
  129.  
  130. :clean_filename
  131. :: %1 - input filename
  132. :: %2 - return varible name
  133. :: !% ^& these chars could break the batch
  134. :: \/:*?"<>| these could to, but they shouldn't appear in valid file names
  135. SETLOCAL EnableDelayedExpansion
  136. :clean_filename_loop
  137. SET "filename=%~n1"
  138. SET "filename=G!filename:&=!G"
  139. SET filename=%filename:!=%
  140. SET filename=!filename: =_!
  141. SET filename=!filename:%%=!
  142. SET filename=!filename:^^=!
  143. SET filename=!filename:~1,-1!
  144. ENDLOCAL & SET %~2=%filename%
  145. GOTO:EOF
Add Comment
Please, Sign In to add comment