Skip to content

Commit dac9935

Browse files
authored
Avisynth+64, Multithreading, Etc. (#7)
* Updates for AviSynth+, multithreading, and 64-bitness. Use AviSynth+ functions for plugin loading. Use new multithreading functions. Update all plugins to 64-bitness. Remove avs2pipemode.exe entirely and replace with ffprobe.exe. Replace all audio encoding with custom ffmpeg.exe. * Add build files/instructions for custom ffmpeg. * Remove some comments. * Fix AAC audio lag. Docs. * Move docs to their own folders. * Forgot timecodefps docs. * x264_x264_feos_edition
1 parent 61c35ef commit dac9935

73 files changed

Lines changed: 6124 additions & 293 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

encode.avs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# The downloadable/HD encoding script
22
# http://tasvideos.org/EncodingGuide/PublicationManual.html
33

4+
SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
5+
AddAutoloadDir("MAINSCRIPTDIR/programs/plugins")
6+
Import(ScriptDir() + "programs/functions.avsi")
7+
48
AviSource("movie.avi")
59

610
# Dolphin (with FFMPEG). Use FFV1 patch for dumping:
711
# https://github.com/vadosnaprimer/dolphin/releases
812
# AviSource("movie.avi", pixel_type="RGB24")
913
# AudioDub(last, wavsource("dspdump.wav"))
1014

15+
threads = 4 # manual, how many threads avisynth should use.
1116
trimFrame = 654321 # manual, discards logo lengh automatically
1217
handHeld = false # auto, but set it for preview
1318
hd = false # auto, but set it for preview
@@ -92,7 +97,6 @@ k = 1
9297
N = 525
9398
b = 0
9499
D = (k * N + b) * floor(floor(M / F) / N) # don't edit this formula
95-
LoadCPlugin("./programs/timecodefps.dll")
96100
video = last.TimecodeFPS("timecodes.txt", fpsnum=M, fpsden=D)
97101
audio = \
98102
WavSource("dspdump0.wav") + \
@@ -118,15 +122,6 @@ originalWidth = last.width
118122
originalHeight = last.height
119123
hdvb = hd && vb
120124

121-
root = ScriptDir()
122-
Import (root + "programs\functions.avsi")
123-
LoadPlugin (root + "programs\ExactDedup.dll")
124-
LoadPlugin (root + "programs\mvtools2.dll")
125-
LoadPlugin (root + "programs\mt_masktools-26.dll")
126-
LoadPlugin (root + "programs\autolevels_0.6_20110109.dll")
127-
LoadCPlugin(root + "programs\freesub.dll")
128-
LoadCPlugin(root + "programs\assrender.dll" )
129-
130125
# Make too dark scenes brighter
131126
# AutoLevels(filterRadius=1000, sceneChgThresh=200, gamma=1.1)
132127

@@ -365,6 +360,8 @@ hdvb ? yt3d(left, right).AudioDub(left) : 0
365360

366361
Trim(0, trimFrame)
367362

363+
# pass == 1 ? assrender("subtitles.ass") : 0
364+
368365
# Youtube can't hanble fps above 60
369366
hd && last.FrameRate > 60 ? ChangeFPS(60) : 0
370367

@@ -377,8 +374,6 @@ ConvertToYV24(chromaresample="point", matrix=(hd \
377374
? "Rec601" \
378375
: "PC.601")))
379376

380-
# pass == 1 ? assrender("subtitles.ass") : 0
381-
382377
# Remove duplicate frames for primary
383378
pass == 1 ? ExactDedup(firstpass=true, dupinfo="./temp/dup.txt",times="./temp/times.txt") : 0
384379
pass == 2 ? ExactDedup(firstpass=false,dupinfo="./temp/dup.txt" ) : 0
@@ -390,3 +385,5 @@ i444 ? last : ConvertToYV12(chromaresample="lanczos", matrix=(hd \
390385
: (pass == 0 \
391386
? "Rec601" \
392387
: "PC.601")))
388+
389+
pass != 1 ? Prefetch(threads) : last

global.bat

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ for /f "tokens=2 skip=2 delims== " %%G in ('find "hAspect = " "%~dp0encode.avs"'
9999

100100
".\programs\replacetext" "encode.avs" "handHeld = true" "handHeld = false"
101101
".\programs\replacetext" "encode.avs" "pass = 0" "pass = 1"
102-
".\programs\avs2pipemod" -info encode.avs > ".\temp\info.txt"
102+
".\programs\ffprobe" -hide_banner -v error -select_streams v -of default -show_entries stream=width,height,r_frame_rate encode.avs > ".\temp\info.txt"
103+
104+
for /f "tokens=2 delims==" %%G in ('FINDSTR "width" "%~dp0temp\info.txt"') do (set width=%%G)
105+
for /f "tokens=2 delims==" %%G in ('FINDSTR "height" "%~dp0temp\info.txt"') do (set height=%%G)
103106

104-
for /f "tokens=2" %%G in ('FIND "width" "%~dp0temp\info.txt"') do (set width=%%G)
105-
for /f "tokens=2" %%G in ('FIND "height" "%~dp0temp\info.txt"') do (set height=%%G)
106107
set /a "SAR_w=%ar_w% * %height%"
107108
set /a "SAR_h=%ar_h% * %width%"
108109
set VAR=%SAR_w%:%SAR_h%
@@ -113,6 +114,7 @@ goto ENCODE_OPTIONS
113114
: handHeld_SAR
114115
set VAR=1:1
115116
".\programs\replacetext" "encode.avs" "handHeld = false" "handHeld = true"
117+
".\programs\ffprobe" -hide_banner -v error -select_streams v -of default -show_entries stream=r_frame_rate encode.avs > ".\temp\info.txt"
116118
goto ENCODE_OPTIONS
117119

118120
: ENCODE_OPTIONS
@@ -205,24 +207,27 @@ echo C'mon! Let's finish this already!
205207
goto get_extrahq_type
206208

207209
: HD
208-
title Starting up...
209-
title
210-
:: Audio ::
211-
".\programs\avs2pipemod" -wav encode.avs | ".\programs\venc" -q10 - ".\temp\audio_youtube.ogg"
210+
title Processing YouTube
212211
echo.
213212
echo ----------------------------
214213
echo Encoding YouTube HD stream
215214
echo ----------------------------
216215
echo.
216+
:: Audio ::
217+
echo Encoding audio...
218+
".\programs\ffmpeg" -y -hide_banner -v error -stats -i encode.avs -vn -c:a libvorbis -q 10 ".\temp\audio_youtube.ogg"
219+
217220
:: Video ::
221+
echo Encoding video...
218222
".\programs\replacetext" "encode.avs" "hd = false" "hd = true"
219-
".\programs\avs2pipemod" -y4mp encode.avs | ".\programs\x264_x64" --qp 5 -b 0 --keyint infinite --output ".\temp\video_youtube.mkv" --demuxer y4m -
223+
".\programs\x264_x64" --qp 5 -b 0 --keyint infinite --output ".\temp\video_youtube.mkv" encode.avs
220224
".\programs\replacetext" "encode.avs" "hd = true" "hd = false"
225+
221226
:: Muxing ::
222227
".\programs\mkvmerge" -o ".\output\encode_youtube.mkv" --compression -1:none ".\temp\video_youtube.mkv" ".\temp\audio_youtube.ogg"
223228

224229
if "%VIRTUALBOY%"=="1" (set VBPREF="_vb_") else (set VBPREF="_")
225-
if "%VIRTUALBOY%"=="1" (".\programs\ffmpeg" -i ".\output\encode_youtube.mkv" -c copy -metadata:s:v:0 stereo_mode=1 ".\output\encode%VBPREF%youtube.mkv")
230+
if "%VIRTUALBOY%"=="1" (".\programs\mkvmerge.exe" -o ".\output\encode%VBPREF%youtube.mkv" --compression -1:none --stereo-mode 0:1 ".\temp\video_youtube.mkv" ".\temp\audio_youtube.ogg")
226231

227232
echo.
228233
echo -----------------------------
@@ -234,94 +239,99 @@ rem start "" cmd /c echo todo ^| "%~dp0programs\tvcman.exe" "%~dp0output\encode%
234239
if "%EncodeChoice%"=="3" goto Defaults
235240

236241
: 10bit444
237-
title Starting up...
238-
title
239-
:: Audio ::
240-
".\programs\avs2pipemod" -wav encode.avs | ".\programs\sox" -t wav - -t wav - trim 0.0065 | ".\programs\opusenc" --bitrate 64 --padding 0 - ".\temp\audio.opus"
241-
echo.
242-
echo ----------------------
243-
echo Generating timecodes
244-
echo ----------------------
245-
:: Timecodes ::
246-
".\programs\replacetext" "encode.avs" "i444 = false" "i444 = true"
247-
".\programs\replacetext" "encode.avs" "pass = 0" "pass = 1"
248-
".\programs\avs2pipemod" -benchmark encode.avs
249-
".\programs\replacetext" "encode.avs" "pass = 1" "pass = 2"
242+
title Processing Modern
250243
echo.
251244
echo --------------------------------
252245
echo Encoding 10bit444 downloadable
253246
echo --------------------------------
254247
echo.
248+
:: Audio ::
249+
echo Encoding audio...
250+
".\programs\ffmpeg" -y -hide_banner -v error -stats -i encode.avs -vn -c:a libopus -b:a 64K ".\temp\audio.opus"
251+
252+
:: Timecodes ::
253+
echo Generating timecodes...
254+
".\programs\replacetext" "encode.avs" "i444 = false" "i444 = true"
255+
".\programs\replacetext" "encode.avs" "pass = 0" "pass = 1"
256+
".\programs\ffmpeg" -hide_banner -v error -stats -i encode.avs -an -f null -
257+
".\programs\replacetext" "encode.avs" "pass = 1" "pass = 2"
258+
255259
:: Video ::
256-
".\programs\avs2pipemod" -y4mp encode.avs | ".\programs\x264_x64" --threads auto --sar "%VAR%" --crf 20 --keyint 600 --ref 16 --no-fast-pskip --bframes 16 --b-adapt 2 --direct auto --me tesa --merange 64 --subme 11 --trellis 2 --partitions all --no-dct-decimate --input-range pc --range pc --tcfile-in ".\temp\times.txt" -o ".\temp\video.mkv" --colormatrix smpte170m --output-csp i444 --profile high444 --output-depth 10 --demuxer y4m -
260+
echo Encoding video...
261+
".\programs\x264_x64" --threads auto --sar "%VAR%" --crf 20 --keyint 600 --ref 16 --no-fast-pskip --bframes 16 --b-adapt 2 --direct auto --me tesa --merange 64 --subme 11 --trellis 2 --partitions all --no-dct-decimate --input-range pc --range pc --tcfile-in ".\temp\times.txt" -o ".\temp\video.mkv" --colormatrix smpte170m --output-csp i444 --profile high444 --output-depth 10 encode.avs
262+
257263
:: Muxing ::
258264
".\programs\mkvmerge" -o ".\output\encode.mkv" --timecodes -1:".\temp\times.txt" ".\temp\video.mkv" ".\temp\audio.opus"
259265
if "%EncodeChoice%"=="1" goto Defaults
260266

261267
: 512kb
262-
title Starting up...
263-
title
264-
:: Audio ::
265-
".\programs\avs2pipemod" -wav encode.avs | ".\programs\qaac64" -v 0 --he -q 2 --delay -5187s --threading --no-smart-padding - -o ".\temp\audio.mp4"
268+
title Processing Compatability
266269
echo.
267270
echo -------------------------------
268271
echo Encoding Archive 512kb stream
269272
echo -------------------------------
270273
echo.
274+
:: Audio ::
275+
echo Encoding audio...
276+
".\programs\ffmpeg" -y -hide_banner -v error -stats -i encode.avs -vn -af atrim=start_sample=7107 -c:a libfdk_aac -profile:a aac_he_v2 -vbr 2 ".\temp\audio.mp4"
277+
271278
:: Video ::
279+
echo Encoding video...
272280
".\programs\replacetext" "encode.avs" "pass = 2" "pass = 0"
273281
".\programs\replacetext" "encode.avs" "i444 = true" "i444 = false"
274-
".\programs\avs2pipemod" -y4mp encode.avs | ".\programs\x264_x64" --threads auto --crf 20 --keyint 600 --ref 16 --no-fast-pskip --bframes 16 --b-adapt 2 --direct auto --me tesa --merange 64 --subme 11 --trellis 2 --partitions all --no-dct-decimate --range tv --input-range tv --colormatrix smpte170m -o ".\temp\video_512kb.h264" --demuxer y4m -
282+
".\programs\x264_x64" --threads auto --crf 20 --keyint 600 --ref 16 --no-fast-pskip --bframes 16 --b-adapt 2 --direct auto --me tesa --merange 64 --subme 11 --trellis 2 --partitions all --no-dct-decimate --range tv --input-range tv --colormatrix smpte170m -o ".\temp\video_512kb.h264" encode.avs
283+
275284
:: Muxing ::
276-
for /f "tokens=2" %%i in ('^""%~dp0programs\avs2pipemod" -info "%~dp0encode.avs" ^|find "fps"^"') do (set fps=%%i)
285+
for /f "tokens=2 delims==" %%i in ('FINDSTR "r_frame_rate" "%~dp0temp\info.txt"') do (set fps=%%i)
277286
for /f %%k in ('^""%~dp0programs\div" %fps%^"') do (set double=%%k)
278287
".\programs\mp4box_x64" -hint -add ".\temp\video_512kb.h264":fps=%double% -add ".\temp\audio.mp4" -new ".\output\encode_512kb.mp4"
279288
goto Defaults
280289

281290
: ExtraHQ_10bit444
282-
title Starting up...
283-
title
284-
:: Extra 10bit444 ::
285-
:: Audio ::
286-
".\programs\avs2pipemod" -wav encode.avs | ".\programs\sox" -t wav - -t wav - trim 0.0065 | ".\programs\opusenc" --bitrate 128 --padding 0 - ".\temp\audio_extra.opus"
287-
echo.
288-
echo ----------------------
289-
echo Generating timecodes
290-
echo ----------------------
291-
echo.
292-
:: Timecodes ::
293-
".\programs\replacetext" "encode.avs" "pass = 0" "pass = 1"
294-
".\programs\avs2pipemod" -benchmark encode.avs
295-
".\programs\replacetext" "encode.avs" "pass = 1" "pass = 2"
291+
title Processing ExtraHQ Modern
296292
echo.
297293
echo ----------------------------------------
298294
echo Encoding ExtraHQ 10bit444 downloadable
299295
echo ----------------------------------------
300296
echo.
297+
:: Audio ::
298+
echo Encoding audio...
299+
".\programs\ffmpeg" -y -hide_banner -v error -stats -i encode.avs -vn -c:a libopus -b:a 128K ".\temp\audio_extra.opus"
300+
301+
:: Timecodes ::
302+
echo Generating timecodes...
303+
".\programs\replacetext" "encode.avs" "pass = 0" "pass = 1"
304+
".\programs\ffmpeg" -hide_banner -v error -stats -i encode.avs -an -f null -
305+
".\programs\replacetext" "encode.avs" "pass = 1" "pass = 2"
306+
301307
:: Video ::
308+
echo Encoding video...
302309
".\programs\replacetext" "encode.avs" "i444 = false" "i444 = true"
303-
".\programs\avs2pipemod" -y4mp encode.avs | ".\programs\x264_x64" --threads auto --sar "%VAR%" --crf 20 --keyint 600 --preset veryslow --input-range pc --range pc --tcfile-in ".\temp\times.txt" -o ".\temp\video_%ExtraScale%x.mkv" --colormatrix smpte170m --output-csp i444 --profile high444 --output-depth 10 --demuxer y4m -
310+
".\programs\x264_x64" --threads auto --sar "%VAR%" --crf 20 --keyint 600 --preset veryslow --input-range pc --range pc --tcfile-in ".\temp\times.txt" -o ".\temp\video_%ExtraScale%x.mkv" --colormatrix smpte170m --output-csp i444 --profile high444 --output-depth 10 encode.avs
311+
304312
:: Muxing ::
305313
".\programs\mkvmerge" -o ".\output\encode_%ExtraScale%x.mkv" --timecodes -1:".\temp\times.txt" ".\temp\video_%ExtraScale%x.mkv" ".\temp\audio_extra.opus"
306314
if "%ExtraType%" NEQ "3" goto check_more_hqfactors
307315

308316
: ExtraHQ_512kb
309-
title Starting up...
310-
title
311-
:: Extra 512kb ::
312-
:: Audio ::
313-
".\programs\avs2pipemod" -wav encode.avs | ".\programs\qaac64" -q 0.5 --delay -2112s --threading --no-smart-padding - -o ".\temp\audio_extra.mp4"
317+
title Processing ExtraHQ Compatability
314318
echo.
315319
echo ---------------------------------------
316320
echo Encoding ExtraHQ Archive 512kb stream
317321
echo ---------------------------------------
318322
echo.
323+
:: Audio ::
324+
echo Encoding audio...
325+
".\programs\ffmpeg" -y -hide_banner -v error -stats -i encode.avs -vn -af atrim=start_sample=7107 -c:a libfdk_aac -profile:a aac_he_v2 -vbr 5 ".\temp\audio_extra.mp4"
326+
319327
:: Video ::
328+
echo Encoding video...
320329
".\programs\replacetext" "encode.avs" "pass = 2" "pass = 0"
321330
".\programs\replacetext" "encode.avs" "i444 = true" "i444 = false"
322-
".\programs\avs2pipemod" -y4mp encode.avs | ".\programs\x264_x64" --threads auto --crf 20 --keyint 600 --preset veryslow --range tv --input-range tv --colormatrix smpte170m -o ".\temp\video_%ExtraScale%x_512kb.h264" --demuxer y4m -
331+
".\programs\x264_x64" --threads auto --crf 20 --keyint 600 --preset veryslow --range tv --input-range tv --colormatrix smpte170m -o ".\temp\video_%ExtraScale%x_512kb.h264" encode.avs
332+
323333
:: Muxing ::
324-
for /f "tokens=2" %%i in ('^""%~dp0programs\avs2pipemod" -info "%~dp0encode.avs" ^|find "fps"^"') do (set fps=%%i)
334+
for /f "tokens=2 delims==" %%i in ('FINDSTR "r_frame_rate" "%~dp0temp\info.txt"') do (set fps=%%i)
325335
for /f %%k in ('^""%~dp0programs\div" %fps%^"') do (set double=%%k)
326336
".\programs\mp4box_x64" -hint -add ".\temp\video_%ExtraScale%x_512kb.h264":fps=%double% -add ".\temp\audio_extra.mp4" -new ".\output\encode_%ExtraScale%x_512kb.mp4"
327337
goto check_more_hqfactors

programs/ASL.dll

-85.3 KB
Binary file not shown.

programs/CoreAudioToolbox.dll

-8.69 MB
Binary file not shown.

programs/CoreFoundation.dll

-2.14 MB
Binary file not shown.

programs/ExactDedup.dll

-13 KB
Binary file not shown.

programs/assrender.dll

-2.93 MB
Binary file not shown.
-188 KB
Binary file not shown.

programs/avs2pipemod.exe

-49.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)