构建批处理以从txt读取信息并决定如何处理视频文件

时间:2012-10-31 05:23:16

标签: batch-processing batch-file

第三天!

新输出文件txt:

Filename          : %FILENAME%.%EXTENSION%
Sizes             : 1.66 GiB for 1h 58mn 0s 615ms at 2 014 Kbps
Writing_App       : VirtualDubMod 1.5.10.2 (build 2542/release)

Video_#0          : DivX 5 MPEG-4 Visual at 1 812 Kbps, with 1.49 GiB (90%)
Aspect            : 704 x 368 (1.913) at 23.976 fps
Writing_App_V     : DivX 6.8.5 (UTC 2009-08-20)

Audio_#0          : AC3
Mode_#0           : Constant
Sample_#0         : 48000
Channels_#0       : 2
Size_#0           : 162 MiB (10%)
Title_#0          : 

Audio_#1          : MP3
Mode_#1           : Constant
Sample_#1         : 44100
Channels_#1       : 2
Size_#1           : 101 MiB (11%)
Title_#1          : 

rem Required to use Delayed !Variable! Expansion
setlocal EnableDelayedExpansion
rem Create all text files (copied from your example)
rem for %%T in ("*.avi") do "C:\Meus Programas\MEDIA\MediaInfo CLI\MediaInfo.exe" --output=file://"C:\Meus Programas\MEDIA\MediaInfo CLI\luis4.csv" --logfile="%%~nT.cod" "%%T"
rem echo.>TXTCollector.lst
rem for %%Z in ("*.cod") do type "%%~Z">>TXTCollector.lst && echo ===========================================>>TXTCollector.lst && echo.>>TXTCollector.lst
rem ren TXTCollector.lst TXTCollector.txt
rem Process each file
for %%F in (*.cod) do (
   rem Delete variables that may not exist in certain files
   set Audio_#1=
   rem Read variables from this text file (explained above)
   for /F "usebackq tokens=1* delims=:" %%a in ("%%F") do (
      for %%c in (%%a) do set %%c=%%b
      set %%c=!%%c:~1!
   )
   ECHO VirtualDub.Open("r:\\%%~nF.avi","",0);>"%%~nF.vcf"
   ECHO VirtualDub.RemoveInputStreams();>>"%%~nF.vcf"
)

Writed所有bat文件并开始调试。我的前两行开始出现问题。此批处理用于创建脚本文件(.vcf),使用>>创建重定向。不再工作了。
ECHO VirtualDub.Open(“r:\ %% ~nF.avi”,“”,0);>“%% ~nF.vcf”
使用参数%% ~nF.vcf创建名称正确的文件,但在文件内刷新完成的所有工作 for / F“usebackq tokens = 1 * delims =:”%% a in(“%% F”)
ECHO VirtualDub.RemoveInputStreams();>>“%% ~nF.vcf”生成了一个名为%~nF.vcf的文件(这意味着该参数不再起作用。)
试图关闭EnableDelayedExpansion,结果相同。也许是因为括号。
再次被困!


第二天!

好的,@ Aacini,谢谢......会尝试恢复...... 我有很多文件可以使用...我为每个文件生成一个.txt。我正在尝试执行一个读取每个.txt的批处理,并决定如何处理原始文件。

TXT FILES:

General
ORIGINAL_FILENAME.avi
818 MiB for 1h 46mn 25s 14ms
AVI-Mux GUI 1.16.11, Dec 15 2004  14:51:34

Video #0
XviD MPEG-4 Visual, with 624 MiB (76%),  at 23.976 fps
XviD 1.2.1 (UTC 2008-12-04)

Audio #0
MPEG Audio Version 1 Layer 3
Variable
44.1 KHz
2 channels
85.8 MiB (10%)
Portuguese BR - 3LT0N
LAME3.93a

Audio #1
MPEG Audio Version 1 Layer 3
Variable
48.0 KHz
2 channels
97.5 MiB (12%)
English - 3LT0N
LAME3.98r

到目前为止,我一直在考虑批次......

IF DOESNT EXIST "Audio #1" in TXT goto :ONEAUDIO
IF EXIST "AC-3" in TXT goto :AC3

Set Value 0 from txt line 02 = filename

"for audio 1"
Set Value 1 from txt line 12 = Variable OR Constant
Set Value 2 from txt line 13 = 44.1 OR 48.0

"for audio 2"
Set Value 3 from txt line 21 = Variable or Constant
Set Value 4 from txt line 22 = 44.1 or 48.0

if value 1 = variable goto :variable1 ELSE goto :constant1

:variable1
(will execute some commands here)
if value 2 = 44.1 goto :22 ELSE goto :24

:22
(will execute some commands here)
goto :jump24

:24
(will execute some commands here)

:jump24
if value 3 = variable goto :variable2 ELSE goto :constant2

:variable2
(will execute some commands here)
if value 4 = 44.1 goto :44 ELSE goto :48

:44
(will execute some commands here)
goto :end

:48
(will execute some commands here)
goto :end

:constant1
(will execute some commands here)
goto :end

:constant2
(will execute some commands here)
goto :end


:ONEAUDIO
later
goto :end

:AC3
later
goto :end

:end

这会遇到一些麻烦...我只知道一些关于FOR(LOOP)的东西,据我所知它不适用于GOTO:例子。也许使用两个批处理文件...一个循环用于调用第二批解析filename.txt

我想的另一种方法是批处理为每个视频文件生成“批处理模型”,然后读取视频文件的.txt,然后替换“批处理模型”中的字符串。但这对我来说太先进了。


第一天:

我需要帮助才能将我的批处理文件加入到一个批处理文件中,并添加此批处理功能以读取文件.txt并确定同一目录中一堆视频的后续步骤。这一切都是关于从avi转换音频以生成与编辑程序的兼容性......

步骤如下:

1)为每个视频文件生成一个.txt,其中包含有关视频和音频的基本信息。

for %%a in ("*.avi") do "C:\Meus Programas\MEDIA\MediaInfo CLI\MediaInfo.exe" --output=file://"C:\Meus Programas\MEDIA\MediaInfo CLI\luis.csv" --logfile="%%~na.txt" "%%a"

或生成包含所有小文件的大文件:

for %%a in ("*.avi") do "C:\Meus Programas\MEDIA\MediaInfo CLI\MediaInfo.exe" --output=file://"C:\Meus Programas\MEDIA\MediaInfo CLI\luis.csv" --logfile="%%~na.txt" "%%a"
echo.>TXTCollector.lst
for %%i in ("*.txt") do type "%%~i">>TXTCollector.lst && echo ===========================================>>TXTCollector.lst && echo.>>TXTCollector.lst && del "%%~i"
ren TXTCollector.lst TXTCollector.txt

输出文件示例:

General           : ORIGINAL NAME FOR THE VIDEO FILES.avi
Format            : 820 MiB for 1h 26mn 38s 777ms at 1 324 Kbps
Writing App.      : VirtualDubMod 1.5.10.2 (build 2540/release)

Video #0          : XviD MPEG-4 Visual at 925 Kbps, with 574 MiB (70%)
Aspect            : 608 x 336 (16:9) at 23.976 fps
Writing App.      : XviD 1.2.1 (UTC 2008-12-04)

Audio #0          : 119 MiB (15%), AC-3  ,  
Infos             : Constant at 192 Kbps, 48.0 KHz, 1 channel
Writing App.      : , 

Audio #1          : 110 MiB (12%), MPEG Audio Version 1 Layer 3,  
Infos             : Constant at 128 Kbps, 48.0 KHz, 2 channels
Writing App.      : LAME3.97 , -m j -V 4 -q 2 -lowpass 17 -b 128

2)从那里,从文件中读取音频格式,我将文件移动到特定文件夹并执行该文件夹中的批处理以运行转换。

蝙蝠的例子。

REM @echo off
:: create the virtual drives and go to the root of drive r:
set ORIGINALDIR=%~d0
subst r: "%cd%"
md JobDone
subst s: "%cd%\JobDone"
r:
cd\
for %%w in ("*.avi") do ECHO VirtualDub.Open("r:\\%%~w","",0);>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.RemoveInputStreams();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetSource(0x73647561,0,1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].DeleteComments(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].AddComment(0x00000003,"","Portuguese");>>"%%~nw.vcf"
REM for %%w in ("*.avi") do ECHO VirtualDub.stream[0].AddComment(0x00000003,"","English");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].AdjustChapters(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetMode(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetInterleave(1,500,1,0,0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetClipMode(1,1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetConversion(0,0,0,0,0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetVolume();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].SetCompression(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].EnableFilterGraph(0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[0].filters.Clear();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetSource(0x73647561,1,1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].DeleteComments(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].AddComment(0x00000003,"","English");>>"%%~nw.vcf"
REM for %%w in ("*.avi") do ECHO VirtualDub.stream[1].AddComment(0x00000003,"","Portuguese");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].AdjustChapters(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetMode(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetInterleave(1,500,1,0,0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetClipMode(1,1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetConversion(0,0,0,0,0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetVolume();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].SetCompression(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].EnableFilterGraph(0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.stream[1].filters.Clear();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.DeleteComments(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.AddComment(0x00000002,"ISFT","VirtualDubMod 1.5.10.2 (build 2542/release)");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.AdjustChapters(1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.SetDepth(24,24);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.SetMode(0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.SetFrameRate(0,1);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.SetIVTC(0,0,-1,0);>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.SetCompression();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.video.filters.Clear();>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.SaveAVI("s:\\%%~nw.avi");>>"%%~nw.vcf"
for %%w in ("*.avi") do ECHO VirtualDub.Close();>>"%%~nw.vcf"

:: Execute the script file just created
for %%a in ("*.vcf") do "C:\VirtualDubMod\VirtualDubMod.exe" /r /s"%%~fa" /x && del "%%~fa"

:: go back to previous folder and delete the virtual drives.
%ORIGINALDIR%
REM %~d0
subst r: /d
subst s: /d

:end

每个作业都有一个文件夹和一个批处理。基本上它是3个不同的过程: 带有AC3音频的视频文件需要采用不同的方法...... 带MP3的视频文件将所有内容转换为恒定比特率和48000采样率。 已经具有常量比特率的视频文件不需要转换,只需要一个remux。

ONE AUDIO
+AC3 AUDIO
--2 CHANNELS
--6 CHANNELS
+MP3 AUDIO
--44100 SAMPLING RATE
--48000 SAMPLING RATE
+JUST REMUX AUDIO

TWO AUDIOS
+AC3
--2ch-2ch
--2ch-6ch
--6ch-2ch
--6ch-6ch
+1ST AUDIO ONLY
--44100
--48000
+2ND AUDIO ONLY
--44100
--48000
+44100-44100
+44100-48000
+48000-41000
+48000-48000
+INVERT AUDIO (just change the order of the audio tracks, no converting)
+JUST REMUX

这就是乐趣开始的地方:

只有一个音频的视频文件很少...可以不在批处理中。 如果...有一个bat文件来完成所有...那么(* .avi)的LOOP将不再起作用,因为每个视频文件都有它自己的属性...然后再次......批处理将有根据文件名创建脚本(或创建脚本的新bat)。

Audio #0          : 119 MiB (15%), AC-3  ,  
Infos             : Constant at 192 Kbps, 48.0 KHz, 1 channel
Writing App.      : , 

考虑一下......如果它只是一个音频......那么: 有ac3(有2ch做2通道转换;如果不做6通道转换) 如果不是ac3(有常数 - >只是remux - > else(如果48.0做48.0转换;否则做41000转换)

这很“很简单” 但这些文件有两个音频......现在对我来说非常困难。

Audio #0          : 119 MiB (15%), AC-3  ,  
Infos             : Constant at 192 Kbps, 48.0 KHz, 1 channel
Writing App.      : , 

Audio #1          : 110 MiB (12%), MPEG Audio Version 1 Layer 3,  
Infos             : Constant at 128 Kbps, 48.0 KHz, 2 channels
Writing App.      : LAME3.97 , -m j -V 4 -q 2 -lowpass 17 -b 128

让我解释一下: “Just remux”和“MP3s conversions”使用视频文件中的内部音频。 “AC3转换”并不那么简单。必须从文件中取出音频,与其他应用程序进行第一次转换,然后在原始程序中进行第二次转换。

md audio1
for %%x in ("*.avi") do "C:\VirtualDubMod\ffmpeg.exe" -i "%%x" -vn -map 0:1 -acodec copy "%%~dpxaudio1\%%~nx.audio1.ac3"

md audio2
for %%u in ("*.avi") do "C:\VirtualDubMod\ffmpeg.exe" -i "%%u" -vn -map 0:2 -acodec copy "%%~dpuaudio2\%%~nu.audio2.ac3"

cd audio1
for %%y in ("*.ac3") do "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core( -input "%%~fy" -output "%%~dpy%%~ny.wav" -2ch ) -azid( -c light ) -ota( -hybridgain ) && del "%%~y"

cd..
cd audio2
for %%y in ("*.ac3") do "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core( -input "%%~fy" -output "%%~dpy%%~ny.wav" -2ch ) -azid( -c light -L -3db ) -ota( -hybridgain ) && del "%%~y"

为转换生成的脚本可以分成几部分: 1)要处理的视频文件 2)第一个音频和对话选项 obs:mp3(不需要指定文件,它是内部音频的代码)AC3(必须指定.wav文件名) 3)第二音频和转换选项 4)视频和转换选项 5)文件名保存新文件 6)命令在进程结束时关闭应用程序。

批处理可以创建一个脚本(或生成脚本的新批处理)逐个粘贴这些和平。并且批次可以有一个“目录”的片段,并通过有关音频的信息选择正确的....

这可能吗?

2 个答案:

答案 0 :(得分:0)

确定。我将尝试从所有这些混乱中得到清楚的东西......

您向我们展示了两种不同的文本文件格式。第一个(在OUTPUT FILE EXAMPLE下)更容易处理。我想你可以修改这个文件,这样每行的标题都是唯一的,并且没有空格,只需插入下划线或数字(作为有效的批量变量名称)。这是我的程序所需格式的示例文件:

General           : ORIGINAL NAME FOR THE VIDEO FILES.avi
Format            : 820 MiB for 1h 26mn 38s 777ms at 1 324 Kbps
Writing_App       : VirtualDubMod 1.5.10.2 (build 2540/release)

Video_#0          : XviD MPEG-4 Visual at 925 Kbps, with 574 MiB (70%)
Aspect            : 608 x 336 (16:9) at 23.976 fps
Writing_App_V0    : XviD 1.2.1 (UTC 2008-12-04)

Audio_#0          : 119 MiB (15%), AC-3  ,  
Infos_A0          : Constant at 192 Kbps, 48.0 KHz, 1 channel
Writing_App_A0    : , 

Audio_#1          : 110 MiB (12%), MPEG Audio Version 1 Layer 3,  
Infos_A1          : Constant at 128 Kbps, 48.0 KHz, 2 channels
Writing_App_A1    : LAME3.97 , -m j -V 4 -q 2 -lowpass 17 -b 128

以下代码将读取上一个文件,并使用右侧的值定义冒号左侧的变量:

rem Read each line from the text file
for /F "tokens=1* delims=:" %%a in (thefile.txt) do (
   rem Eliminate spaces from variable name
   for %%c in (%%a) do set %%c=%%b
   rem Eliminate first character (space) from variable value
   set %%c=!%%c:~1!
)

在上一个循环结束后,您可以直接获取每个变量的值。例如, ECHO!格式!如果没有定义Audio_#1 ECHO One Audio IF“!Audio_#0:AC-3 =!” EQU“!Audio_#0!” ECHO Audio#0不是AC-3“等等。

这是将所有部分组合在一起的第一次尝试:

@echo off
rem Required to use Delayed !Variable! Expansion
setlocal EnableDelayedExpansion
rem Create all text files (copied from your example)
for %%a in ("*.avi") do "C:\Meus Programas\MEDIA\MediaInfo CLI\MediaInfo.exe" --output=file://"C:\Meus Programas\MEDIA\MediaInfo CLI\luis.csv" --logfile="%%~na.txt" "%%a"
rem Process each file
for %%f in (*.txt) do (
   rem Delete variables that may not exist in certain files
   set Audio_#1=
   rem Read variables from this text file (explained above)
   for /F "usebackq tokens=1* delims=:" %%a in ("%%f") do (
      for %%c in (%%a) do set %%c=%%b
      set %%c=!%%c:~1!
   )
   rem Identify each case
   set AC-3=NO
   if "!Audio_#0:AC-3=!" neq "!Audio_#0!" set AC-3=YES
   if not defined Audio_#1 (
      rem One Audio
      if !AC-3! equ YES (
         rem Process One Audio with AC-3
      ) else (
         rem Process One Audio with no AC-3
      )
   ) else (
      rem Two Audios
      if "!Audio_#1:AC-3=!" neq "!Audio_#1!" set AC-3=YES
      if !AC-3! equ YES (
         rem Process Two Audios with AC-3
      ) else (
         rem Process Two Audios with no AC-3
      )
   )
)

尝试理解此代码并进行多项测试,然后发布新问题。

安东尼奥

ADDENDUM 有关“从变量名中删除空格”的说明

如果这个FOR命令:

for /F "tokens=1* delims=:" %%a in (thefile.txt) do (
   set %%a=%%b
)

请阅读以下内容:

General           : ORIGINAL NAME FOR THE VIDEO FILES.avi

然后执行的SET命令是:

   set General           = ORIGINAL NAME FOR THE VIDEO FILES.avi

这样,变量名称恰好是“General< 11 spaces>”,所以

echo %General%               does NOT work
echo %General           %    OK

为避免这种混乱,必须删除变量名称中的空格。

如果执行此命令,您必须知道:

for %%a in (    one        two         threee      ) do echo "%%a"

结果是:

"one"
"two"
"three"

因此可以使用FOR命令来消除空格。 OK?

答案 1 :(得分:0)

批处理正在运行,并针对所有类型的文件进行了测试。谢谢你的帮助。这批产品正在进行预期,但还有一些工作要做。它可以清洗很多。后来...

@echo off
rem create the virtual drives needed to VirtualDubMod work
set ORIGINALDRIVE=%~d0
subst r: "%cd%"
md JobDone
subst s: "%cd%\JobDone"
r:
cd\
rem Required to use Delayed !Variable! Expansion
setlocal EnableDelayedExpansion
rem Create all text files (copied from your example)
for %%T in ("*.avi") do "C:\Meus Programas\MEDIA\MediaInfo CLI\MediaInfo.exe" --output=file://"C:\Meus Programas\MEDIA\MediaInfo CLI\luis4.csv" --logfile="%%~nT.cod" "%%T"
rem Create "catalogue" from all INFOs created.
echo.>TXTCollector.lst
for %%Z in ("*.cod") do type "%%~Z">>TXTCollector.lst && echo ===========================================>>TXTCollector.lst && echo.>>TXTCollector.lst
ren TXTCollector.lst TXTCollector.txt
rem Process each file
for %%F in (*.cod) do (
   rem Setting the variables needed!
   set NAMEFILE=%%~nF
   rem Delete variables that may not exist in certain files
   set Audio_#1=
   rem Read variables from this text file (explained above)
   for /F "usebackq tokens=1* delims=:" %%a in ("%%F") do (
      rem Eliminate spaces from variable name?????????
      for %%c in (%%a) do (
         set %%c=%%b
         rem Eliminate first character (space) from variable value
         set %%c=!%%c:~1!
      )
   )
   ECHO VirtualDub.Open^("r:\\!NAMEFILE!.avi","",0^);>"!NAMEFILE!.vcf"
   ECHO VirtualDub.RemoveInputStreams^(^);>>"!NAMEFILE!.vcf"
   rem PROCESS FIRST AUDIO
   if !Audio_#0! equ AC3 (
      rem PROCESS AC3
      if !Channels_#0! equ 6 (
         rem Process AC3 6 Channels
         ECHO -=-=-=-=-=-=-=-=-=-=-
         ECHO AC3_1 HAS 6 CHANNELS
         ECHO -=-=-=-=-=-=-=-=-=-=-
         "C:\VirtualDubMod\ffmpeg.exe" -i "!NAMEFILE!.avi" -vn -map 0:1 -acodec copy "r:\!NAMEFILE!.audio1.ac3"
         "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core^( -input "r:\!NAMEFILE!.audio1.ac3" -output "r:\!NAMEFILE!.audio1.wav" -2ch ^) -azid^( -c light -L -3db ^) -ota^( -hybridgain ^)
         del "r:\!NAMEFILE!.audio1.ac3"
      ) else (
         rem Process AC3 2 or 1 Channels
         ECHO -=-=-=-=-=-=-=-=-=-=-
         ECHO AC3_1 HAS 2 CHANNELS
         ECHO -=-=-=-=-=-=-=-=-=-=-
         "C:\VirtualDubMod\ffmpeg.exe" -i "!NAMEFILE!.avi" -vn -map 0:1 -acodec copy "r:\!NAMEFILE!.audio1.ac3"
         "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core^( -input "r:\!NAMEFILE!.audio1.ac3" -output "r:\!NAMEFILE!.audio1.wav" -2ch ^) -azid^( -c light ^) -ota^( -hybridgain ^)
         del "r:\!NAMEFILE!.audio1.ac3"
      )
      ECHO VirtualDub.stream[0].SetSource^("r:\\!NAMEFILE!.audio1.wav",0x00000201^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].AddComment^(0x00000003,"","Portuguese"^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetMode^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetVolume^(^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].SetCompression^(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA"^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[0].filters.Clear^(^);>>"!NAMEFILE!.vcf"
   ) else (
      rem PROCESS MP3
      if !Mode_#0! equ Constant (
         rem JUST REMUX AUDIO
         ECHO VirtualDub.stream[0].SetSource^(0x73647561,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].AddComment^(0x00000003,"","Portuguese"^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetMode^(0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetVolume^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetCompression^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].filters.Clear^(^);>>"!NAMEFILE!.vcf"
      ) else (
         rem REDO AUDIO
         ECHO VirtualDub.stream[0].SetSource^(0x73647561,0,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].AddComment^(0x00000003,"","Portuguese"^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetMode^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetVolume^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[0].SetCompression^(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA"^);>>"!NAMEFILE!.vcf"
         if !Sample_#0! equ 44100 (
            rem REDO 44100 AUDIO
            ECHO VirtualDub.stream[0].EnableFilterGraph^(1^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Clear^(^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Add^("input"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Add^("resample"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Connect^(0, 0, 1, 0^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.instance[1].SetInt^(0, 48000^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.instance[1].SetInt^(1, 64^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Add^("output"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Connect^(1, 0, 2, 0^);>>"!NAMEFILE!.vcf"
         ) else (
            rem REDO 48000 AUDIO
            ECHO VirtualDub.stream[0].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[0].filters.Clear^(^);>>"!NAMEFILE!.vcf"
         )
      )
   )
   rem PROCESS SECOND AUDIO
   if !Audio_#1! equ AC3 (
      rem PROCESS AC3
      if !Channels_#1! equ 6 (
         rem Process AC3 6 Channels
         ECHO -=-=-=-=-=-=-=-=-=-=-
         ECHO AC3_2 HAS 6 CHANNELS
         ECHO -=-=-=-=-=-=-=-=-=-=-
         "C:\VirtualDubMod\ffmpeg.exe" -i "!NAMEFILE!.avi" -vn -map 0:1 -acodec copy "r:\!NAMEFILE!.audio2.ac3"
         "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core^( -input "r:\!NAMEFILE!.audio2.ac3" -output "r:\!NAMEFILE!.audio2.wav" -2ch ^) -azid^( -c light -L -3db ^) -ota^( -hybridgain ^)
         del "r:\!NAMEFILE!.audio2.ac3"
      ) else (
         rem Process AC3 2 or 1 Channels
         ECHO -=-=-=-=-=-=-=-=-=-=-
         ECHO AC3_2 HAS 2 CHANNELS
         ECHO -=-=-=-=-=-=-=-=-=-=-
         "C:\VirtualDubMod\ffmpeg.exe" -i "!NAMEFILE!.avi" -vn -map 0:2 -acodec copy "r:\!NAMEFILE!.audio2.ac3"
         "c:\Meus Programas\AUDIO\BeSweet\BeSweet.exe" -core^( -input "r:\!NAMEFILE!.audio2.ac3" -output "r:\!NAMEFILE!.audio2.wav" -2ch ^) -azid^( -c light ^) -ota^( -hybridgain ^)
         del "r:\!NAMEFILE!.audio2.ac3"
      )
      ECHO VirtualDub.stream[1].SetSource^("r:\\!NAMEFILE!.audio2.wav",0x00000201^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].AddComment^(0x00000003,"","English"^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetMode^(1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetVolume^(^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].SetCompression^(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA"^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
      ECHO VirtualDub.stream[1].filters.Clear^(^);>>"!NAMEFILE!.vcf"
   ) else (
      rem PROCESS MP3
      if !Mode_#0! equ Constant (
         rem JUST REMUX AUDIO
         ECHO VirtualDub.stream[1].SetSource^(0x73647561,1,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].AddComment^(0x00000003,"","English"^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetMode^(0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetVolume^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetCompression^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].filters.Clear^(^);>>"!NAMEFILE!.vcf"
      ) else (
         rem REDO AUDIO
         ECHO VirtualDub.stream[1].SetSource^(0x73647561,1,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].DeleteComments^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].AddComment^(0x00000003,"","English"^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetMode^(1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetInterleave^(1,500,1,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetClipMode^(1,1^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetConversion^(0,0,0,0,0^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetVolume^(^);>>"!NAMEFILE!.vcf"
         ECHO VirtualDub.stream[1].SetCompression^(85,48000,2,0,16000,1,12,"AQAEAAAAgAEBAAAA"^);>>"!NAMEFILE!.vcf"
         if !Sample_#0! equ 44100 (
            rem REDO 44100 AUDIO
            ECHO VirtualDub.stream[1].EnableFilterGraph^(1^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Clear^(^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Add^("input"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Add^("resample"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Connect^(0, 0, 1, 0^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.instance[1].SetInt^(0, 48000^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.instance[1].SetInt^(1, 64^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Add^("output"^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Connect^(1, 0, 2, 0^);>>"!NAMEFILE!.vcf"
         ) else (
            rem REDO 48000 AUDIO
            ECHO VirtualDub.stream[1].EnableFilterGraph^(0^);>>"!NAMEFILE!.vcf"
            ECHO VirtualDub.stream[1].filters.Clear^(^);>>"!NAMEFILE!.vcf"
         )
      )
   )
   ECHO VirtualDub.video.DeleteComments^(1^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.AddComment^(0x00000002,"ISFT","VirtualDubMod 1.5.10.2 (build 2542/release)"^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.AdjustChapters^(1^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.SetDepth^(24,24^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.SetMode^(0^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.SetFrameRate^(0,1^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.SetIVTC^(0,0,-1,0^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.SetCompression^(^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.video.filters.Clear^(^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.SaveAVI^("s:\\!NAMEFILE!.avi"^);>>"!NAMEFILE!.vcf"
   ECHO VirtualDub.Close^(^);>>"!NAMEFILE!.vcf"
   "C:\VirtualDubMod\VirtualDubMod.exe" /r /s"R:\!NAMEFILE!.vcf" /x
   rem del "!NAMEFILE!.vcf"
   del "!NAMEFILE!.cod"
   rem del "!NAMEFILE!.audio1.wav"
   rem del "!NAMEFILE!.audio2.wav"
)
rem go back to original folder and delete the virtual drives.
%ORIGINALDRIVE%
subst r: /d
subst s: /d