-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeSuVi File Virtualizer.bat
482 lines (430 loc) · 20.5 KB
/
HeSuVi File Virtualizer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
::Script by 3DJ
::Special thanks to UnionRings, AsianAreAsian and sintrode
@ECHO OFF
SETLOCAL EnableDelayedExpansion
pushd "%~dp0"
::Version
Set "ScriptName=HeSuVi File Virtualizer"
Set "ScriptVersion=1.0"
Set "ScriptNameVersion=!ScriptName! v!ScriptVersion!"
::Store input file full path into variable
SET "InputPath=%~1"
::Extract input folder path, filename, extension and filename.extension as variables from full path
For %%I in ("!InputPath!") do (
SET "InputFolder=%%~dpI"
SET "InputFileName=%%~nI"
SET "InputFileExtension=%%~xI"
SET "InputFile=%%~nxI"
)
::Set HeSuVi executable and HRIR paths
set "HeSuViFolder=%ProgramFiles%\EqualizerAPO\config\HeSuVi"
set "HeSuViExecutable=%HeSuViFolder%\HeSuVi.exe"
set "TempFolder=Output\Temp"
set "LogFilePath=!TempFolder!\Log.txt"
set "ConfigFilePath=Config.ini"
set "ToolsFolder=Resources\Tools"
set "FFmpegExe=!ToolsFolder!\FFmpeg\ffmpeg.exe"
set "SoXExe=!ToolsFolder!\SoX\sox.exe"
set "initoolExe=!ToolsFolder!\initool\initool.exe"
::Settings
if exist !ConfigFilePath! (
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputVideoFileFormat --value-only') do set "OutputVideoFileFormat=%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputVideoFileFormat --value-only') do set "OutputVideoFileExtension=.%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputAudioFileFormat --value-only') do set "OutputAudioFileFormat=%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputAudioFileFormat --value-only') do set "OutputAudioFileExtension=.%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputAudioBitrate --value-only') do set "OutputAudioBitrate=%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings HeSuViHRIR --value-only') do set "HeSuViHRIR=%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputVideoFFmpegArguments --value-only') do set "OutputVideoFFmpegArguments=%%A"
for /f "delims=" %%A in ('!initoolExe! g !ConfigFilePath! Settings OutputAudioFFmpegArguments --value-only') do set "OutputAudioFFmpegArguments=%%A"
) else (
set "OutputVideoFileExtension=.mkv"
set "OutputVideoFileFormat=!OutputVideoFileExtension:.=!"
set "OutputAudioFileExtension=.wav"
set "OutputAudioFileFormat=!OutputAudioFileExtension:.=!"
set "OutputAudioBitrate=128k"
set "HeSuViHRIR=Common"
)
::Output/temp
IF NOT EXIST Output (
mkdir !TempFolder!
) else (
rmdir /s /q Output
mkdir !TempFolder!
)
::Check for drag and drop
IF NOT DEFINED InputPath (
::From the top
:FromTheTop
cls
::Intro
title !ScriptNameVersion!
call :PrintAndLog "[90m:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::[0m"
call :PrintAndLog "[90m::::::::::::::::::::::::::::[0m[1m !ScriptNameVersion! [0m[90m:::::::::::::::::::::::::::[0m"
call :PrintAndLog "[90m::::::::::::::::[0m [90mBy 3DJ - github.com/ThreeDeeJay / Discord: 3DJ#5426[0m [90m::::::::::::::::[0m"
call :PrintAndLog "[90m::::::::::[0m [90mScript that applies HeSuVi virtual surround to 7.1 input files[0m [90m:::::::::::[0m"
call :PrintAndLog "[90m:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::[0m"
echo.
::Window exe drag and drop
call :PrintAndLog "Ways to virtualize audio or video files (one at a time):"
call :PrintAndLog "A) Drag and drop file onto this window then press Enter."
call :PrintAndLog "B) Drag and drop file onto the .bat file to start conversion immediately, skipping this info screen."
call :PrintAndLog "C) Press Tab to cycle through files in this folder to select as input then press Enter."
echo.
call :PrintAndLog "Notes:"
call :PrintAndLog "- Input sample rate needs to match HeSuVi HRIRs' (44100hz or 48000hz)."
call :PrintAndLog "- Extra WAV files in this folder will be:"
call :PrintAndLog " - Added as new tracks, using filename without extension as label."
call :PrintAndLog " - Added without applying extra virtualization."
call :PrintAndLog "- Only input file's main video track will be used, and copied without re-encoding."
call :PrintAndLog "- Only input file's main audio track will be used, re-encoded only if required (MP4)."
call :PrintAndLog "While processing, HeSuVi will be turned on and cycle through HRIRs, which also applies to system audio."
echo.
call :PrintAndLog "Settings:"
call :PrintAndLog "- HRIR/s to use: !HeSuViHRIR:more\=!"
call :PrintAndLog "- Output container format: !OutputVideoFileFormat!"
call :PrintAndLog "- Output audio codec: !OutputAudioFileFormat!"
if not !OutputAudioFileExtension!==.wav (call :PrintAndLog "- Audio output bitrate: !OutputAudioBitrate!")
if defined OutputVideoFFmpegArguments (call :PrintAndLog "- FFmpeg video arguments: !OutputVideoFFmpegArguments!")
if defined OutputAudioFFmpegArguments (call :PrintAndLog "- FFmpeg audio arguments: !OutputAudioFFmpegArguments!")
call :PrintAndLog "*To change settings, press Enter without providing input."
::Save settings:
echo [Settings]> %ConfigFilePath%
echo OutputVideoFileFormat=!OutputVideoFileFormat!>> %ConfigFilePath%
echo OutputAudioFileFormat=!OutputAudioFileFormat!>> %ConfigFilePath%
echo OutputAudioBitrate=!OutputAudioBitrate!>> %ConfigFilePath%
echo HeSuViHRIR=!HeSuViHRIR!>> %ConfigFilePath%
echo OutputVideoFFmpegArguments=!OutputVideoFFmpegArguments!>> %ConfigFilePath%
echo OutputAudioFFmpegArguments=!OutputAudioFFmpegArguments!>> %ConfigFilePath%
::Declare variable with placeholder value
set InputPath=Null
::Check for window drag and drop
set /p InputPath=
::Remove quotes from path
set InputPath=!InputPath:"=!
::Extract folder path and filename and save to separate variables
For %%A in ("!InputPath!") do (
SET "InputFolder=%%~dpA"
SET "InputFileName=%%~nA"
SET "InputFileExtension=%%~xA"
SET "InputFile=%%~nxA"
)
::Open settings upon no input
IF "!InputPath!"=="Null" (
::SettingsConfiguration
:SettingsConfiguration
::HRIR selection
cls
call :PrintAndLog "Currently selected HeSuVi HRIR to use for virtualization: !HeSuViHRIR!"
set count=0
for %%x in ("C:\Program Files\EqualizerAPO\config\HeSuVi\hrir\*.wav") do (
set /a count=count+1
set choice[!count!]=%%~nx
)
set countmore=!count!
for %%x in ("C:\Program Files\EqualizerAPO\config\HeSuVi\hrir\more\*.wav") do (
set /a countmore=countmore+1
set choicemore[!countmore!]=%%~nx
)
pushd %~dp0
call :PrintAndLog "To change, select an option letter or number then press Enter."
echo.
::Print list of HRIRs
call :PrintAndLog "A] All (Common + More)"
echo.
call :PrintAndLog " C] Common"
for /l %%x in (1,1,!count!) do (
if %%x LEQ 9 (
echo %%x] !choice[%%x]!
) else if %%x LEQ 99 (
echo %%x] !choice[%%x]!
) else if %%x LEQ 999 (
echo %%x] !choice[%%x]!
) else (
echo %%x] !choice[%%x]!
)
)
echo.
call :PrintAndLog " M] More"
set /a count=count+1
for /l %%x in (!count!,1,!countmore!) do (
if %%x LEQ 9 (
echo %%x] !choicemore[%%x]!
) else if %%x LEQ 99 (
echo %%x] !choicemore[%%x]!
) else if %%x LEQ 999 (
echo %%x] !choicemore[%%x]!
) else (
echo %%x] !choicemore[%%x]!
)
)
::Output format
set /p selection=
cls
if !selection! LSS !count! (
for /f "delims=" %%A in ("!selection!") do set "HeSuViHRIR=!choice[%%A]!"
) else (
for /f "delims=" %%A in ("!selection!") do set "HeSuViHRIR=more\!choicemore[%%A]!"
)
if !selection!==A (set "HeSuViHRIR=All")
if !selection!==a (set "HeSuViHRIR=All")
if !selection!==C (set "HeSuViHRIR=Common")
if !selection!==c (set "HeSuViHRIR=Common")
if !selection!==M (set "HeSuViHRIR=More")
if !selection!==m (set "HeSuViHRIR=More")
::Output video format
cls
call :PrintAndLog "Currently selected output video format: !OutputVideoFileExtension!"
set /p OutputVideoFileFormat=Press Enter to keep or input new format: .
set "OutputVideoFileExtension=.!OutputVideoFileFormat!"
::Output audio format
cls
call :PrintAndLog "Currently selected output audio format: !OutputAudioFileExtension!"
set /p OutputAudioFileFormat=Press Enter to keep or input new format: .
set "OutputAudioFileExtension=.!OutputAudioFileFormat!"
::Output audio bitrate
if not !OutputAudioFileExtension!==.wav (
cls
call :PrintAndLog "Currently selected output audio bitrate: !OutputAudioBitrate!"
set /p OutputAudioBitrate=Press Enter to keep or input new bitrate:
)
::Output video FFmpeg Arguments
cls
call :PrintAndLog "Extra FFmpeg video arguments: !OutputVideoFFmpegArguments!"
set /p OutputVideoFFmpegArguments=Press Enter to keep or input new arguments:
::Output audio FFmpeg Arguments
cls
call :PrintAndLog "Extra FFmpeg audio arguments: !OutputAudioFFmpegArguments!"
set /p OutputAudioFFmpegArguments=Press Enter to keep or input new arguments:
goto :FromTheTop
)
cls
::Proceed to conversion
goto BeginProcess
) ELSE (
::Begin process
:BeginProcess
::Check input-output compatibility
IF "!InputFileExtension!"==".wav" (
IF "!OutputVideoFileExtension!"==".mp4" (
title INCOMPATIBLE FORMAT DETECTED
call :PrintAndLog "WAV input not supported by MP4."
call :PrintAndLog "If you continue, the script will change output format to MKV."
pause
set "OutputVideoFileExtension=.mkv"
cls
)
)
IF "!OutputAudioFileExtension!"==".wav" (
IF "!OutputVideoFileExtension!"==".mp4" (
title INCOMPATIBLE FORMAT DETECTED
call :PrintAndLog "WAV input not supported by MP4."
call :PrintAndLog "If you continue, the script will change output format to MKV."
pause
set "OutputVideoFileExtension=.mkv"
cls
)
)
::Intro
title !ScriptNameVersion!
echo.
::Extract WAV from input
call :PrintAndLog "Extracting main audio track from input..."
echo.
!FFmpegExe! -y -loglevel error -i "!InputPath!" "!InputFilename!-source.wav" 2> %LogFilePath%
::Detect samplerate and change HRIR folder if needed
call :PrintAndLog "Detecting sample rate..."
echo.
for /f "delims=" %%A in ('!SoXExe! --i -r "!InputFilename!-source.wav"') do set "InputSampleRate=%%A"
if "!InputSampleRate!" == "44100" (
SET "HeSuViHRIRfolder=!HeSuViFolder!\hrir\44"
) else if "!InputSampleRate!" == "48000" (
SET "HeSuViHRIRfolder=!HeSuViFolder!\hrir"
) else (
call :PrintAndLog "Input contains unsupported audio sample rate."
call :PrintAndLog "Please, make sure the file is either 44100hz or 48000hz so it's compatible with HeSuVi HRIRs."
pause
exit
)
::Convert extra WAV files, normalize and encode to AAC
call :PrintAndLog "Converting external WAV files..."
echo.
for %%A in ("*.wav") do (
if not "%%~nxA"=="!InputFile!" (
if not "%%~nxA"=="!InputFilename!-source.wav" (
if not !OutputAudioFileExtension!==.wav (
!FFmpegExe! -y -loglevel error -i "%%~nxA" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! "%%~nA!OutputAudioFileExtension!" 2> %LogFilePath%
)
)
)
)
::Iterate through all HeSuVi HRIRs
if !HeSuViHRIR!==All (
for %%A in ("!HeSuViHRIRfolder!\*.wav") do (
::Enable HeSuVi and cycle through HRIRs
"!HeSuViExecutable!" -deactivateeverything 0 -virtualization "%%~nA.wav"
::Apply HRIR to extracted WAV
call :PrintAndLog "Applying %%~nA.wav..."
"C:\Program Files\EqualizerAPO\Benchmark.exe" --nopause -i "!InputFilename!-source.wav" -o "%%~nA.wav" >>%LogFilePath%
::Downmix to discard extra channels, normalize and encode to AAC
IF "!OutputAudioFileExtension!"==".ogg" (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -c:a libopus -vbr on -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
) else if "!OutputAudioFileExtension!"==".wav" (
call :PrintAndLog "Discarding empty channels..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR" !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
del "%%~nA.wav"
) else (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
)
echo.
)
for %%A in ("!HeSuViHRIRfolder!\more\*.wav") do (
::Enable HeSuVi and cycle through HRIRs
"!HeSuViExecutable!" -deactivateeverything 0 -virtualization "more\%%~nA.wav"
::Apply HRIR to extracted WAV
call :PrintAndLog "Applying %%~nA.wav..."
"C:\Program Files\EqualizerAPO\Benchmark.exe" --nopause -i "!InputFilename!-source.wav" -o "%%~nA.wav" >>%LogFilePath%
::Downmix to discard extra channels, normalize and encode to AAC
IF "!OutputAudioFileExtension!"==".ogg" (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -c:a libopus -vbr on -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
) else if "!OutputAudioFileExtension!"==".wav" (
call :PrintAndLog "Discarding empty channels..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR" !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
del "%%~nA.wav"
) else (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
)
echo.
)
) else if !HeSuViHRIR!==Common (
for %%A in ("!HeSuViHRIRfolder!\*.wav") do (
::Enable HeSuVi and cycle through HRIRs
"!HeSuViExecutable!" -deactivateeverything 0 -virtualization "%%~nA.wav"
::Apply HRIR to extracted WAV
call :PrintAndLog "Applying %%~nA.wav..."
"C:\Program Files\EqualizerAPO\Benchmark.exe" --nopause -i "!InputFilename!-source.wav" -o "%%~nA.wav" >>%LogFilePath%
::Downmix to discard extra channels, normalize and encode to AAC
IF "!OutputAudioFileExtension!"==".ogg" (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -c:a libopus -vbr on -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
) else if "!OutputAudioFileExtension!"==".wav" (
call :PrintAndLog "Discarding empty channels..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR" !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
del "%%~nA.wav"
) else (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
)
echo.
)
) else if !HeSuViHRIR!==More (
for %%A in ("!HeSuViHRIRfolder!\more\*.wav") do (
::Enable HeSuVi and cycle through HRIRs
"!HeSuViExecutable!" -deactivateeverything 0 -virtualization "more\%%~nA.wav"
::Apply HRIR to extracted WAV
call :PrintAndLog "Applying %%~nA.wav..."
"C:\Program Files\EqualizerAPO\Benchmark.exe" --nopause -i "!InputFilename!-source.wav" -o "%%~nA.wav" >>%LogFilePath%
::Downmix to discard extra channels, normalize and encode to AAC
IF "!OutputAudioFileExtension!"==".ogg" (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -c:a libopus -vbr on -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
) else if "!OutputAudioFileExtension!"==".wav" (
call :PrintAndLog "Discarding empty channels..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR" !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
del "%%~nA.wav"
) else (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "%%~nA.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - %%~nA.!OutputAudioFileFormat!"
)
echo.
)
) else (
::Enable HeSuVi and select HRIR
"!HeSuViExecutable!" -deactivateeverything 0 -virtualization "!HeSuViHRIR!.wav"
::Apply HRIR to extracted WAV
call :PrintAndLog "Applying !HeSuViHRIR!..."
"C:\Program Files\EqualizerAPO\Benchmark.exe" --nopause -i "!InputFilename!-source.wav" -o "!HeSuViHRIR:more\=!.wav" >>%LogFilePath%
::Downmix to discard extra channels, normalize and encode to AAC
IF "!OutputAudioFileExtension!"==".ogg" (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "!HeSuViHRIR:more\=!.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -c:a libopus -vbr on -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - !HeSuViHRIR:more\=!.!OutputAudioFileFormat!"
) else if "!OutputAudioFileExtension!"==".wav" (
call :PrintAndLog "Discarding empty channels..."
!FFmpegExe! -loglevel error -y -i "!HeSuViHRIR:more\=!.wav" -af "pan=stereo|c0=FL|c1=FR" !OutputAudioFFmpegArguments! "HeSuVi - !HeSuViHRIR:more\=!.!OutputAudioFileFormat!"
del "!HeSuViHRIR:more\=!.wav"
) else (
call :PrintAndLog "Downmixing, normalizing and encoding..."
!FFmpegExe! -loglevel error -y -i "!HeSuViHRIR:more\=!.wav" -af "pan=stereo|c0=FL|c1=FR, loudnorm" -ar !InputSampleRate! -b:a !OutputAudioBitrate! !OutputAudioFFmpegArguments! "HeSuVi - !HeSuViHRIR:more\=!.!OutputAudioFileFormat!"
)
echo.
)
::Cleanup
call :PrintAndLog "Deleting temporary files..."
del "!InputFilename!-source.wav"
echo.
::Disable HeSuVi to test output
call :PrintAndLog "Resetting HeSuVi..."
echo.
"!HeSuViExecutable!" -deactivateeverything 1
::Virtualization complete
call :PrintAndLog "Virtualization complete."
call :PrintAndLog "Press any key to add virtualized tracks to the input video and delete them,"
call :PrintAndLog "or close this window if you just want the virtualized WAV (lossless) or !OutputAudioFileFormat! files."
call :PrintAndLog "Note: due to how batch processing of HRIR works, HeSuVi has been set to the last HRIR and turned off."
echo.
pause
cls
::Combine all tracks
set count=0
for %%A in ("*!OutputAudioFileExtension!") do (
set /a count=!count!+1
set "map=!map! -map !count!:a"
set "i=!i! -i "%%~nxA""
)
if "!InputFileExtension!"==".wav" (
set count=0
) else (
set count=1
)
for %%A in ("*!OutputAudioFileExtension!") do (
set /a count=!count!+1
set "metadata=!metadata! -metadata:s:!count! handler_name="%%~nA""
)
call :PrintAndLog "Merging all tracks..."
echo.
if "!InputFileExtension!"==".wav" (
!FFmpegExe! -loglevel error -y -i "!InputPath!" !i! -map 0:v?:0 -map 0:a:0 !map! -metadata:s:0 handler_name="Source" !metadata! !OutputVideoFFmpegArguments! -codec copy "Output\!InputFilename!-Virtualized!OutputVideoFileExtension!"
) else (
!FFmpegExe! -loglevel error -y -i "!InputPath!" !i! -map 0:v?:0 -map 0:a:0 !map! -metadata:s:1 handler_name="Source" !metadata! !OutputVideoFFmpegArguments! -codec copy "Output\!InputFilename!-Virtualized!OutputVideoFileExtension!"
)
::Cleanup
call :PrintAndLog "Performing cleanup..."
echo.
for %%A in ("*!OutputAudioFileExtension!") do (
del "%%~nA!OutputAudioFileExtension!"
)
for %%A in ("!HeSuViHRIRfolder!\*.wav") do (
if exist "%%~nA.wav" (
del "%%~nA.wav"
)
)
for %%A in ("!HeSuViHRIRfolder!\more\*.wav") do (
if exist "%%~nA.wav" (
del "%%~nA.wav"
)
)
::Complete
call :PrintAndLog "Virtualized audio tracks have been combined with the input."
call :PrintAndLog "Continue to the Output folder?"
pause
start Output
exit
)
::Print and log
:PrintAndLog
echo %~1
echo %~1 >>%LogFilePath%
EXIT /B 0