Schlagwort-Archive: batch

Batch: media-autobuild_suite v2.0

Von dem Compiler Script media-autobuild_suite gibt es jetzt die Version 2.0.

Die Compiler- Umgebung basiert nun auf MSYS2. Vorteil davon ist, dass sich die Umgebung immer aktuell hält, Updates werden automatisch installiert.

Da nun auch viele Libraries aus MSYS2 genommen werden, bleiben auch diese auf dem neusten Stand. Das System bleibt kleiner und läuft im gesamten schneller.

 

Viel Spaß damit!

https://github.com/jb-alvarado/media-autobuild_suite

Batch: rename

Kommt doch immer wieder mal vor, dass man viele Dateien umbenenne muss.

Auf stackoverflow.com beschreibt jemand eine gute Methode wie man das mit einem Powershell Befehl bewerkstelligen kann:

 

powershell -C "gci | % {rni $_.Name ($_.Name -replace 'oldpart', 'newpart')}"

Bei dem Beispiel wird davon ausgegangen, dass ein Teil des Dateinamens bestehen bleibt und der Rest umbenannt wird.

Quelle:

http://stackoverflow.com/questions/9383032/batch-file-rename

Batch: Handling von .msi Installationspaketen

Es gibt verschiedene Möglichkeiten per Batch mit *.msi Paketen umzugehen.

Eine Möglichkeit wäre die Installation ohne Eingabeaufforderung zu starten, kann den Prozess auch um einiges Beschleunigen:

1
msiexec /program.msi /quiet /l* install.log

Eine Andere Möglichkeit wäre, dass Pakt in einen Ordner entpacken zu lasen:

1
msiexec /a program.msi /qb TARGETDIR=C:\target\folder

media-autobuild_suite

Unter Linux gibt es ein tolles Script mit welchem sich das Kompilieren von ffmpeg und andere Tools für Windows automatisieren lässt.

https://github.com/rdp/ffmpeg-windows-build-helpers )

Etwas ähnliches habe ich jetzt auch für Windows geschrieben. Das Script läuft auch weitestgehend automatisch ab. Es muss lediglich ausgewählt werden ob man für Windows 32 bit, 64 bit, oder Beides kompiliert werden soll. Ob „non free“ Encoder, wie fdk aac, eingebunden werden soll und wie viele CPU Cores verwendet werden soll.

Für das Ausführen und verwenden ist es wichtig, dass das Script in einem Ordner kopiert und ausgeführt wird, welcher keine Leerzeichen im Pfad hat. Z.B.: C:\mingw

Da keine Registry Keys, oder Systemvariablen gesetzt werden, kann der Ordner, wenn er nicht mehr benötigt wird, problemlos gelöscht werden. Es bleiben keine Rückstände übrig.

Momentan werden kompiliert:

  • a52dec
  • bzip2
  • exiv2
  • fdkaac (standalone and lib for ffmpeg)
  • ffmpeg
  • faac (standalone and lib for ffmpeg)
  • fftw
  • flac (standalone)
  • fltk
  • fontconfig
  • freetype
  • frei0r
  • gettext
  • gsm
  • gnutls (standalone and lib for ffmpeg)
  • lame (standalone and lib for ffmpeg)
  • ImageMagick (standalone (32 bit))
  • jpeg
  • jpeg2000
  • jpegturbo
  • libass
  • libbluray
  • libcaca
  • libdvdcss
  • libdvdnav
  • libdvdread
  • libilbc
  • libmad
  • libmodplug
  • libmpeg2
  • libpng
  • libsoxr
  • libtiff
  • libtwolame
  • libutvideo
  • libxml2
  • libzvbi
  • lua
  • mediainfo cli (only 32 bit)
  • mp3lame (standalone and lib for ffmpeg)
  • mp4box (standalone)
  • mplayer (standalone)
  • orc
  • opencore-amr
  • openEXR (standalone and lib for ImageMagick)
  • openjpeg
  • ogg
  • opus
  • opus-tools (standalone)
  • qt4
  • rtmp (standalone and lib for ffmpeg)
  • schroedinger
  • sdl (for ffplay)
  • sdl_image
  • sox
  • speex (standalone and lib for ffmpeg)
  • theora
  • vlc player
  • vidstab
  • vpx (standalone and lib for ffmpeg)
  • vo-aacenc
  • vo-amrwbenc
  • vorbis
  • x264 (standalone and lib for ffmpeg)
  • x264 10 bit (standalone)
  • x265 (standalone and lib)
  • x265 16 bit (standalone)
  • xavs (standalone and lib for ffmpeg)
  • xvid
  • zlib

Finden tut ihr die neuste Version immer unter:

https://github.com/jb-alvarado/media-autobuild_suite

Viel Spaß damit!

 

( Da das Tool open source ist, ist die Nutzung natürlich auf eigene Gefahr… 🙂 )

Durch Ordner und Unterordner „schleifen“ und nach Dateiendungen suchen

Manchmal kann es vorkommen, dass man in vielen Unterordnern nach Dateien suchen muss um sie zu löschen, bearbeiten, oder sonstiges mit anzustellen. In meinem Beispiel lasse ich einen Ordner durchsuchen, in dem VLC compiliert wurde. Es sollen alle Dateien mit der Endung „.a“ und „.la“ gelöscht werden und mit dem Tool ubx lasse ich anschließend alle „.exe“ und „.dll“ files packen, damit sie weniger Platz auf der Festplatte einnehmen (vor dem packen nahm vlc ~230 mb in Anspruch, nach dem Packen nur noch 32,3 mb).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@echo off
 
FOR /R "vlc-2.2.0-git" %%A IN (*.a) DO del %%A
FOR /R "vlc-2.2.0-git" %%B IN (*.la) DO del %%B
 
FOR /R "vlc-2.2.0-git" %%C IN (*.exe) DO (
	D:\Dateien\DEV\mingw\bin\strip.exe %%C 
	D:\Dateien\DEV\mingw\bin\upx.exe --best --strip-relocs=0 %%C
	echo.%%C done...
	)
FOR /R "vlc-2.2.0-git" %%D IN (*.dll) DO (
	D:\Dateien\DEV\mingw\bin\strip.exe %%D 
	D:\Dateien\DEV\mingw\bin\upx.exe --best --strip-relocs=0 %%D
	echo.%%D done...
	)
 
pause

Falls benötigt, das Tool ubx lässt sich hier herunterladen:
http://upx.sourceforge.net/#downloadupx

Batch Update Timer

Hier mal eine Idee für einen Batch updater. Gedacht ist, dass das Batchprogramm alle 4 Monate Updates installiert. Das ganze ist sehr einfach gehalten, wie man sieht werde Schaltjahre und Monatslängen nicht berücksichtigt. Im Grunde wird einfach überprüft ob zum letzten mal Ausführen schon 120 Tage vergangen sind, wenn ja kann man wählen ob das Batch vorsetzen soll.

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
@echo off
Setlocal EnableDelayedExpansion 

:: path to update ini
set "ini=D:\Dateien\DEV\BatchScripts\update.ini"
 
set year=%date:~-4%
set month=%date:~-7,2%
set day=%date:~-10,2%
 
set splitMonth=%month:~0,1%
set splitDay=%day:~0,1%
 
if %splitMonth%==0 (
	set month=%month:~-1%
	)
if %splitDay%==0 (
	set day=%day:~-1%
	)	
 
if not exist %ini% (
	echo.year=%year%>>%ini%
	echo.month=!month!>>%ini%
	echo.day=!day!>>%ini%
	)
 
for /F "tokens=2 delims==" %%a in ('findstr /i year %ini%') do (
	set oldYear=%%a
	)
for /F "tokens=2 delims==" %%b in ('findstr /i month %ini%') do (
	set oldMonth=%%b
	)
for /F "tokens=2 delims==" %%c in ('findstr /i day %ini%') do (
	set oldDay=%%c
	)	
 
set /a calcDays = %year% * 365 + %month% * 30 + %day%
set /a calcOldDays = %oldYear% * 365 + %oldMonth% * 30 + %oldDay%
set /a diffDays = %calcDays% - %calcOldDays%

:: update cycle 120 days = 4 month
if %diffDays% LSS 120 GOTO run
echo.
echo....................................................................
echo.
echo.....Update Progress................................................
echo.
echo....................................................................
echo.
echo.
echo.Do you want to update media_compressor? Type: yes or no
echo.
set /P keyInput="Update Process:"
echo.
if %keyInput% == no exit
 
if %keyInput% == yes (
	del %ini%
	echo.year=%year%>>%ini%
	echo.month=!month!>>%ini%
	echo.day=!day!>>%ini%
	)
 
:run
pause

SendTo mp4 Compression Batch Script

Ein erweitertes Kompression-Script das recht gut in den „SendTo“ Kontext im Explorer passt. Mit dem Script können Ordner mit Framesequenzen und Videofiles gleichermaßen komprimiert werden. Am Anfang findet eine Überprüfung statt, ob alle Tools vorhanden sind.

Die neueste Version ist zu finden unter:

https://github.com/jb-alvarado/media_compressor

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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
::-------------------------------------------------------------------------------------
:: LICENSE -------------------------------------------------------------------------
::-------------------------------------------------------------------------------------
::	  This Windows Batchscript is for the SendTo Menu. It compress audio, videos and folders with image sequences to mp4.
::    Copyright (C) 2012  jb_alvarado
::
::    This program is free software: you can redistribute it and/or modify
::    it under the terms of the GNU General Public License as published by
::    the Free Software Foundation, either version 3 of the License, or
::    (at your option) any later version.
::
::    This program is distributed in the hope that it will be useful,
::    but WITHOUT ANY WARRANTY; without even the implied warranty of
::    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
::    GNU General Public License for more details.
::
::    You should have received a copy of the GNU General Public License
::    along with this program.  If not, see <http://www.gnu.org/licenses/>.
::-------------------------------------------------------------------------------------
::-------------------------------------------------------------------------------------
 
::-------------------------------------------------------------------------------------
:: History ---------------------------------------------------------------------------
::-------------------------------------------------------------------------------------
::
:: This is version 0.95 from 2012-09-16. Last bigger modification was on 2013-04-09
:: 2012-10-28 - add HQ Avisynth Deinterlacer, Auto Level for the Codec, maxrate, bufsize and small changes
:: 2012-10-29 - build a new installer, most things a now automatic
:: 2012-11-21 - fixing avisynth input, change code layout
:: 2013-04-09 - changing video input, now it use avisynth only for deinterlacing, download sources fixed
:: 2013-05-24 - fixing small things, also a error in the input by frame sequences
::
::-------------------------------------------------------------------------------------
 
@echo off
Setlocal EnableDelayedExpansion 
 
color 87
title media_Compressor
 
:: EncoderSettings -------------------------------
 
set preset=slow
:: ( preset defined how exactly the x264 codec work, slower better and smaller but slower: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo )
 
set quality=22
:: ( quality: 20-26 useful, smaller better quality )
 
set GOPSize=50
:: ( GOPSize: short clips needs smaller value )
 
set fps=
:: ( fps: frames per second, only need this for other frame rate then 25 (for  frame sequences) )
 
set aacEnc=aac -strict experimental
:: ( use "aac -strict experimental" when you have the free distributed Version from ffmpeg, or libfaac/libfdk_aac when you compile by your self )
 
set audioBit=160k
:: ( Audo Bitrate )  
 
set audioCodec=libmp3lame
:: ( libmp3lame, pcm_s24le, pcm_s16le, mp2, ac3, flac, etc. ) 
 
set audioExt=.mp3
:: ( .wav, .mp3, .ac3, mp2, flac, ogg, etc. ) 
 
::------------------------------------------------------------------------------
:: Install Process
::------------------------------------------------------------------------------
if exist "C:\Program Files (x86)" (
	set "InstallPath=C:\Program Files (x86)\BatchMediaCompressor"
	set "AVSPluginFolder=C:\Program Files (x86)\AviSynth 2.5\plugins"
	if exist "!InstallPath!" GOTO checkwget
	MD "!InstallPath!"
) else (
	set "InstallPath=C:\Program Files\BatchMediaCompressor"
	set "AVSPluginFolder=C:\Program Files\AviSynth 2.5\plugins"
	if exist "!InstallPath!" GOTO checkwget
	MD "!InstallPath!"
	)
 
:checkwget
if not exist "%InstallPath%\license" MD "%InstallPath%\license"
if not exist "%InstallPath%\help" MD "%InstallPath%\help"
if not exist "%InstallPath%\readme" MD "%InstallPath%\readme"	
 
if exist "%InstallPath%\wget.exe" GOTO check7z
	echo -------------------------------------------------------------
	echo.
	echo - please download and copy wget.exe to:
	echo - %InstallPath% 
	echo.
	echo - hit key for download
	echo.
	echo -------------------------------------------------------------
	pause
	start "" "http://users.ugent.be/~bpuype/cgi-bin/fetch.pl?dl=wget/wget.exe"
	pause
if not exist "%InstallPath%\wget.exe" GOTO checkwget
 
:check7z
if exist "%InstallPath%\7za.exe" GOTO checkavisynth
	echo -------------------------------------------------------------
	echo.
	echo - 7z download and install start...
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" "http://blog.pixelcrusher.de/downloads/7za920.exe"
	pushd %InstallPath%
	"%InstallPath%\7za920.exe"
	popd
	move "%InstallPath%\7zip-license.txt" "%InstallPath%\license"
	move "%InstallPath%\7-zip.chm" "%InstallPath%\help"
	move "%InstallPath%\7zip-readme.txt" "%InstallPath%\readme"
	del "%InstallPath%\7za920.exe"
 
:checkavisynth
if exist "%windir%\SysWOW64\avisynth.dll" GOTO checkdevIL
if exist "%windir%\System32\avisynth.dll" GOTO checkdevIL
	echo -------------------------------------------------------------
	echo.
	echo - Avisynth will be download and install
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" http://sourceforge.net/projects/avisynth2/files/latest/download?source=files
	"%InstallPath%\AviSynth_110525.exe" /S
	del "%InstallPath%\AviSynth_110525.exe"
if exist "%windir%\SysWOW64\DevIL.dll" del "%windir%\SysWOW64\devil.dll"
if exist "%windir%\System32\DevIL.dll" del "%windir%\System32\devil.dll"
 
:checkdevIL
if exist "%windir%\SysWOW64\DevIL.dll" GOTO checkQTGMC
if exist "%windir%\System32\DevIL.dll" GOTO checkQTGMC
	echo -------------------------------------------------------------
	echo.
	echo - Avisynth will be patched and adjusted
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" "http://downloads.sourceforge.net/project/openil/DevIL Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip"
if exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\DevIL-EndUser-x86-1.7.8.zip" -o%windir%\SysWOW64 *.dll -r -y
if not exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\DevIL-EndUser-x86-1.7.8.zip" -o%windir%\System32 *.dll -r -y
 
"%InstallPath%\wget" -P "%InstallPath%" "http://blog.pixelcrusher.de/downloads/avisynth.7z"
if exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\avisynth.7z" -o"%windir%\SysWOW64" *.dll -r -y
if not exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\avisynth.7z" -o"%windir%\System32" *.dll -r -y
 
del "%InstallPath%\DevIL-EndUser-x86-1.7.8.zip"
del "%InstallPath%\avisynth.7z"
 
:checkQTGMC
if exist "%AVSPluginFolder%\QTGMC-3.32.avsi" GOTO checkffms
	echo -------------------------------------------------------------
	echo.
	echo - The deinterlacer QTGMC will be download and install
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" "http://www.spirton.com/uploads/QTGMC/QTGMC 32-bit Plugins [Vit-Mod].zip"
	"%InstallPath%\wget" -P "%InstallPath%" "http://www.spirton.com/uploads/QTGMC/QTGMC-3.32.zip"
if exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%windir%\SysWOW64" fftw3.dll -r -y
if exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%windir%\SysWOW64" libfftw3f-3.dll -r -y
if not exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%windir%\System32" fftw3.dll -r -y
if not exist "%windir%\SysWOW64" "%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%windir%\System32" libfftw3f-3.dll -r -y
 
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" mt_masktools-26.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" AddGrainC.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" dfttest.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" EEDI2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" eedi3.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" FFT3DFilter.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" mvtools2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" nnedi.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" nnedi2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" nnedi3.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" RemoveGrainSSE2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" RepairSSE2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" SSE2Tools.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" TDeint.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" VerticalCleanerSSE2.dll -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip" -o"%AVSPluginFolder%" yadif.dll -r -y
 
	"%InstallPath%\7za.exe" e "%InstallPath%\QTGMC-3.32.zip" -o"%AVSPluginFolder%" -r -y
 
	del "%InstallPath%\QTGMC 32-bit Plugins [Vit-Mod].zip"
	del "%InstallPath%\QTGMC-3.32.zip"
 
:checkffms
if exist "%AVSPluginFolder%\ffms2.dll" GOTO checkffmpeg
	echo -------------------------------------------------------------
	echo.
	echo - The AVSLoader will be download and install
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" --no-check-certificate -P "%InstallPath%" "https://ffmpegsource.googlecode.com/files/ffms-2.17.7z"
	"%InstallPath%\7za.exe" e "%InstallPath%\ffms-2.17.7z" -o"%AVSPluginFolder%" ffms-2.17\FFMS2.avsi -y
	"%InstallPath%\7za.exe" e "%InstallPath%\ffms-2.17.7z" -o"%AVSPluginFolder%" ffms-2.17\ffms2.dll -y
	"%InstallPath%\7za.exe" e "%InstallPath%\ffms-2.17.7z" -o"%AVSPluginFolder%" ffms-2.17\ffmsindex.exe -y
	del "%InstallPath%\ffms-2.17.7z"
 
:checkffmpeg
if exist "%InstallPath%\ffmpeg.exe" GOTO checkmp4box
	echo -------------------------------------------------------------
	echo.
	echo - ffmpeg the compressor will be install
	echo.
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.7z
	"%InstallPath%\7za.exe" e "%InstallPath%\ffmpeg-latest-win32-static.7z" -o"%InstallPath%" *.exe -r -y
	del "%InstallPath%\ffmpeg-latest-win32-static.7z"
 
:checkmp4box
if exist "%InstallPath%\mp4box.exe" GOTO checkMediaInfo 
	echo -------------------------------------------------------------
	echo.
	echo - mp4box the multiplexer will be install
	echo.
	echo -------------------------------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" http://kurtnoise.free.fr/mp4tools/MP4Box-0.4.6-rev2735.zip
	"%InstallPath%\7za.exe" e "%InstallPath%\mp4box-0.4.6-rev2735.zip" -o"%InstallPath%" *.exe -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\mp4box-0.4.6-rev2735.zip" -o"%InstallPath%" *.dll -r -y
	del "%InstallPath%\mp4box"-0.4.6-rev2735.zip"
 
:checkMediaInfo
if exist "%InstallPath%\MediaInfo.exe" GOTO checklink
	echo --------------------------------------
	echo.
	echo - MediaInfo will be install
	echo.
	echo --------------------------------------
	"%InstallPath%\wget" -P "%InstallPath%" "http://downloads.sourceforge.net/project/mediainfo/binary/mediainfo/0.7.61/MediaInfo_CLI_0.7.61_Windows_i386.zip"
	"%InstallPath%\7za.exe" e "%InstallPath%\MediaInfo_CLI_0.7.61_Windows_i386.zip" -o"%InstallPath%" *.exe -r -y
	"%InstallPath%\7za.exe" e "%InstallPath%\MediaInfo_CLI_0.7.61_Windows_i386.zip" -o"%InstallPath%" *.dll -r -y
	del "%InstallPath%\MediaInfo_CLI_0.7.61_Windows_i386.zip"
 
:checklink
if exist "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\SendTo\media_Compressor.lnk" GOTO checkself
	echo -------------------------------------------------------------
	echo.
	echo - bulding Link to the SendTo Menu
	echo.
	echo -------------------------------------------------------------
 
	if exist "%InstallPath%\FFmpeg.ico" GOTO buildlink
	"%InstallPath%\wget" -P "%InstallPath%" "http://blog.pixelcrusher.de/downloads/FFmpeg.ico"
 
:buildlink
	echo.Set Shell = CreateObject^("WScript.Shell"^) >> "%InstallPath%\setlink.vbs"
	echo.Set link = Shell.CreateShortcut^("C:\Users\%username%\AppData\Roaming\Microsoft\Windows\SendTo\media_Compressor.lnk"^) >> "%InstallPath%\setlink.vbs"
	echo.link.Arguments = "" >> "%InstallPath%\setlink.vbs"
	echo.link.Description = "Compress Video or Audio Files, Framesequences or multiplex Video and Audio Files to MP4" >> "%InstallPath%\setlink.vbs"
	echo.link.IconLocation = "%InstallPath%\FFmpeg.ico" >> "%InstallPath%\setlink.vbs"
	echo.link.TargetPath = "%InstallPath%\media_Compressor.bat" >> "%InstallPath%\setlink.vbs"
	echo.link.WindowStyle = 1 >> "%InstallPath%\setlink.vbs"
	echo.link.WorkingDirectory = "%InstallPath%" >> "%InstallPath%\setlink.vbs"
	echo.link.Save>> "%InstallPath%\setlink.vbs" 
 
	cscript /nologo "%InstallPath%\setlink.vbs" 
	del "%InstallPath%\setlink.vbs" 
 
:checkself
if exist "%InstallPath%\media_Compressor.bat" GOTO runscript
	copy /Y "%~f0" "%InstallPath%"
 
if exist "%InstallPath%\Uninstall.bat" GOTO runscript
	echo.@echo off >> "%InstallPath%\Uninstall.bat"
	echo.echo ------------------------------------------------------------- >> "%InstallPath%\Uninstall.bat"
	echo.echo. >> "%InstallPath%\Uninstall.bat"
	echo.echo - Avisynth will not be Uninstall >> "%InstallPath%\Uninstall.bat"
	echo.echo - pleas Uninstall it over your Systemsettings >> "%InstallPath%\Uninstall.bat"
	echo.echo. >> "%InstallPath%\Uninstall.bat"
	echo.echo - hit key to process the Uninstaller >> "%InstallPath%\Uninstall.bat"
	echo.echo ------------------------------------------------------------- >> "%InstallPath%\Uninstall.bat"
	echo pause >> "%InstallPath%\Uninstall.bat"
 
	echo. >> "%InstallPath%\Uninstall.bat"
	echo.del "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\SendTo\media_Compressor.lnk" >> "%InstallPath%\Uninstall.bat"
	echo.pushd ..\ >> "%InstallPath%\Uninstall.bat"
	echo.rmdir /s /q "%InstallPath%" >> "%InstallPath%\Uninstall.bat"
	echo. >> "%InstallPath%\Uninstall.bat"
 
	echo -------------------------------------------------------------
	echo.
	echo - media_Compressor is now installed
	echo - pleas close the Window and use it over
	echo - the Explorer Context Menu: SendTo
	echo.
	echo -------------------------------------------------------------
	pause
	exit
 
:runscript
 
set "input=%~1"
if "%input%"=="" (
	echo.
	echo....................................................................
	echo.
	echo.   Pleas drag and drop Files or Folder on the
	echo.   Script or use it in the SendTo Folder
	echo.
	echo....................................................................
	echo.
	pause
	exit
	)
 
cd /d "%~dp1" 2>nul
cd /d %1 2>nul
 
set x1="%input%"
set x2="%cd%"
 
if "%input%"=="%CD%" GOTO folder
	set /a count=0
	for /f "tokens=* delims= " %%a in ('dir/s/b/a-d %*') do (
		set /a count+=1
		)
 
if not %count%==2 GOTO :audiocomp
 
:: Multiplex and Compression -------------------------------
 
set muxingInput=%~x1-%~x2
 
if "%muxingInput%"==".m2v-.ac3" set or_=true
if "%muxingInput%"==".ac3-.m2v" set or_=true
if "%muxingInput%"==".m2v-.mp2" set or_=true
if "%muxingInput%"==".mp2-.m2v" set or_=true
if "%muxingInput%"==".m2v-.wav" set or_=true
if "%muxingInput%"==".wav-.m2v" set or_=true
if "%muxingInput%"==".avi-.wav" set or_=true
if "%muxingInput%"==".wav-.avi" set or_=true
if "%muxingInput%"==".mov-.wav" set or_=true
if "%muxingInput%"==".wav-.mov" set or_=true
if "%muxingInput%"==".avi-.mp3" set or_=true
if "%muxingInput%"==".mp3-.avi" set or_=true
if "%muxingInput%"==".mov-.mp3" set or_=true
if "%muxingInput%"==".mp3-.mov" set or_=true
if "%muxingInput%"==".mp4-.aac" set or_=true
if "%muxingInput%"==".aac-.mp4" set or_=true
if "%muxingInput%"==".mpeg-.ac3" set or_=true
if "%muxingInput%"==".ac3-.mpeg" set or_=true
if "%muxingInput%"==".mpg-.ac3" set or_=true
if "%muxingInput%"==".ac3-.mpg" set or_=true
if "%muxingInput%"==".mpeg-.mp2" set or_=true
if "%muxingInput%"==".mp2-.mpeg" set or_=true
if "%muxingInput%"==".mpg-.mp2" set or_=true
if "%muxingInput%"==".mp2-.mpg" set or_=true
 
if not %or_%==true GOTO audiocomp
 
if "%~x1"==".avi" GOTO audfirst
if "%~x1"==".m2v" GOTO audfirst
if "%~x1"==".mov" GOTO audfirst
if "%~x1"==".mp4" GOTO audfirst
if "%~x1"==".mpg" GOTO audfirst
if "%~x1"==".mpeg" GOTO audfirst
 
set "vidInput=%~s2"
set "audInput=%~s1"
 
GOTO multiplex
 
:audfirst
set "vidInput=%~s1"
set "audInput=%~s2"
 
:multiplex
pushd "%installpath%"
	FOR /F %%i in ( 'mediainfo --Inform^=^"Video^;%%ScanType/String%%^" %vidInput%' ) do set ScanType=%%i
	FOR /F %%j in ( 'mediainfo --Inform^=^"Video^;%%DisplayAspectRatio%%^" %vidInput%' ) do set aspect=%%j
	FOR /F %%k in ( 'mediainfo --Inform^=^"Video^;%%Width/String%%^" %vidInput%' ) do set Width=%%k
	FOR /F %%l in ( 'mediainfo --Inform^=^"Video^;%%Height/String%%^" %vidInput%' ) do set Height=%%l
	FOR /F %%m in ( 'mediainfo --Inform^=^"Video^;%%Duration/String1%%^" %vidInput%' ) do set Duration=%%m
popd
 
if %Width% LEQ 1024 (
	set level=3.2
	set maxrate=4M 
	set bufsize=4M
	)
 
if %Width% GEQ 1280 (
	set level=4.1
	set maxrate=10M 
	set bufsize=10M
	)
 
if %Width% GEQ 1920 (
	set level=5.1
	set maxrate=20M 
	set bufsize=20M
	)
 
echo.
echo....................................................................
echo.....multiplex and convert Video and Audio-File.....................
echo....................................................................
echo.
echo.Duration:  %Duration%
echo.Scan Type: %ScanType%
echo.Width:     %Width%
echo.Height:    %Height%
echo.Aspect:    %Aspect%
echo.
echo....................................................................
echo....................................................................
echo.
 
if exist "%~n1.avs" del "%~n1.avs" 
if exist "%~n1.h264" del "%~n1.h264" 
if exist "%~n1.aac" del "%~n1.aac" 
if exist "%~s1.ffindex" del "%~s1.ffindex" 
if exist "%~s2.ffindex" del "%~s2.ffindex" 
 
if %ScanType%==Interlaced (
	echo.SetMTMode^(5, 4^) >> "%~n1.avs"
	echo.LoadPlugin("%AVSPluginFolder%\ffms2.dll"^) >> "%~n1.avs"
	echo.Import^("%AVSPluginFolder%\QTGMC-3.32.avsi"^) >> "%~n1.avs"
	echo.A = FFAudioSource^("%audInput%"^) >> "%~n1.avs"
	echo.V = FFVideoSource^("%vidInput%"^) >> "%~n1.avs"
	echo.audiodub^(V,A^) >> "%~n1.avs"
	echo.SetMTMode^(2^) >> "%~n1.avs"
	echo.ConvertToYV12^(interlaced=true^) >> "%~n1.avs"
	echo.QTGMC^( Preset="Slow", EdiThreads=2 ^) >> "%~n1.avs"
	echo.SelectEven^(^) >> "%~n1.avs"
 
	"%InstallPath%\ffmpeg.exe" -y -i "%~n1.avs" -aspect %Aspect% -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level %level% -maxrate %maxrate% -bufsize %bufsize% "%~n1.h264" -c:a %aacEnc% -ab %audioBit% "%~n1.aac"
 
	if exist "%~n1_x264.mp4" del "%~n1_x264.mp4" 
	"%InstallPath%\mp4box" -add "%~n1.h264" -add "%~n1.aac" -hint -brand mp42 "%~n1_x264.mp4"
	if exist "%~n1.avs" del "%~n1.avs" 
	if exist "%~n1.h264" del "%~n1.h264" 
	if exist "%~n1.aac" del "%~n1.aac" 
	if exist "%~s1.ffindex" del "%~s1.ffindex" 
	if exist "%~s2.ffindex" del "%~s2.ffindex" 
 
	GOTO end
	) 
 
"%InstallPath%\ffmpeg.exe" -i %vidInput% -i %audInput% -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level %level% -maxrate %maxrate% -bufsize %bufsize% "%~n1.h264" -c:a %aacEnc% -ab %audioBit% "%~n1.aac"
 
if exist "%~n1_x264.mp4" del "%~n1_x264.mp4"
"%InstallPath%\mp4box" -add "%~n1.h264" -add "%~n1.aac" -hint -brand mp42 "%~n1_x264.mp4"
if exist "%~n1.h264" del "%~n1.h264" 
if exist "%~n1.aac" del "%~n1.aac" 
 
GOTO end
 
:: Audio Compression -------------------------------
 
:audiocomp
 
for %%f in (%*) do (
	if "%%~xf"==".avi" GOTO :videocomp
	if "%%~xf"==".AVI" GOTO :videocomp
	if "%%~xf"==".mp4" GOTO :videocomp
	if "%%~xf"==".MP4" GOTO :videocomp
	if "%%~xf"==".m4v" GOTO :videocomp
	if "%%~xf"==".avs" GOTO :avscomp
	if "%%~xf"==".flv" GOTO :videocomp
	if "%%~xf"==".f4v" GOTO :videocomp
	if "%%~xf"==".mov" GOTO :videocomp
	if "%%~xf"==".MOV" GOTO :videocomp
	if "%%~xf"==".mkv" GOTO :videocomp
	if "%%~xf"==".MKV" GOTO :videocomp
	if "%%~xf"==".wmv" GOTO :videocomp
	if "%%~xf"==".divx" GOTO :videocomp
	if "%%~xf"==".mpg" GOTO :videocomp
	if "%%~xf"==".MPG" GOTO :videocomp
	if "%%~xf"==".mpeg" GOTO :videocomp
	if "%%~xf"==".m2v" GOTO :videocomp
	if "%%~xf"==".ogv" GOTO :videocomp
	if "%%~xf"==".dv" GOTO :videocomp
	if "%%~xf"==".vob" GOTO :videocomp
	if "%%~xf"==".3gp" GOTO :videocomp
	if "%%~xf"==".m2v" GOTO :videocomp
 
	echo.
	echo....................................................................
	echo.
	echo..........converting Audio-File.....................................
	echo.
	echo....................................................................
	echo.
 
	"%InstallPath%\ffmpeg.exe" -i %%f -vn -acodec %audioCodec% -ab %audioBit% "%%~nf_%audioExt%"
	)
 
GOTO end
 
:: Video Compression -------------------------------
 
:avscomp
if not "%~x1"==".avs" GOTO :videocomp
for %%f in (%*) do (
	"%InstallPath%\ffmpeg.exe" -i %%f -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -maxrate 6M -bufsize 6M -c:a %aacEnc% -ab %audioBit% "%%~nf.m4v"
 
	if exist "%%~nf_x264.mp4" del "%%~nf_x264.mp4" 
	"%InstallPath%\mp4box" -add "%%~nf.m4v" -hint -brand mp42 "%%~nf_x264.mp4"
	del "%%~nf.m4v" 
	)
 
GOTO end
 
:videocomp
 
for %%f in (%*) do (
	pushd "%installpath%"
		FOR /F %%i in ( 'mediainfo --Inform^=^"Video^;%%ScanType/String%%^" %%f' ) do set ScanType=%%i
		FOR /F %%j in ( 'mediainfo --Inform^=^"Video^;%%DisplayAspectRatio%%^" %%f' ) do set aspect=%%j
		FOR /F %%k in ( 'mediainfo --Inform^=^"Video^;%%Width/String%%^" %%f' ) do set Width=%%k
		FOR /F %%l in ( 'mediainfo --Inform^=^"Video^;%%Height/String%%^" %%f' ) do set Height=%%l
		FOR /F %%m in ( 'mediainfo --Inform^=^"Video^;%%Duration/String1%%^" %%f' ) do set Duration=%%m
		FOR /F %%n in ( 'mediainfo --Inform^=^"Audio^;%%StreamCount%%^" %%f' ) do set AudioStream=%%n
		popd
 
	set "infile=%%~sf"
 
	if !Width! LEQ 1024 (
		set level=3.2
		set maxrate=4M 
		set bufsize=4M
		)
 
	if !Width! GEQ 1280 (
		set level=4.1
		set maxrate=10M 
		set bufsize=10M
		)
 
	if !Width! GEQ 1920 (
		set level=5.1
		set maxrate=20M 
		set bufsize=20M
		)
 
	echo.
	echo....................................................................
	echo..........converting Video-File.....................................
	echo....................................................................
	echo.
	echo.Duration:  !Duration!
	echo.Scan Type: !ScanType!
	echo.Width:     !Width!
	echo.Height:    !Height!
	echo.Aspect:    !Aspect!
	echo.
	echo....................................................................
	echo....................................................................
	echo.
 
	if exist "%%~nf.h264" del "%%~nf.h264" 
	if exist "%%~nf.aac" del "%%~nf.aac" 
	if exist "%%~nf.avs" del "%%~nf.avs"  
	if exist "%%f.ffindex"  del "%%f.ffindex"  
 
	if "!AudioStream!"=="" (
		if !ScanType!==Interlaced (
			echo.SetMTMode^(5, 4^) >> "%%~nf.avs"
			echo.LoadPlugin("%AVSPluginFolder%\ffms2.dll"^) >> "%%~nf.avs"
			echo.Import^("%AVSPluginFolder%\QTGMC-3.32.avsi"^) >> "%%~nf.avs"
			echo.FFVideoSource^("!infile!"^) >> "%%~nf.avs"
			echo.SetMTMode^(2^) >> "%%~nf.avs"
			echo.ConvertToYV12^(interlaced=true^) >> "%%~nf.avs"
			echo.QTGMC^( Preset="Slow", EdiThreads=2 ^) >> "%%~nf.avs"
			echo.SelectEven^(^) >> "%%~nf.avs"
 
			"%InstallPath%\ffmpeg.exe" -y -i "%%~nf.avs" -aspect !Aspect! -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level !level! -maxrate !maxrate! -bufsize !bufsize! "%%~nf.h264"
 
			if exist "%%~nf_x264.mp4" del "%%~nf_x264.mp4" 
			"%InstallPath%\mp4box" -add "%%~nf.h264" -hint -brand mp42 "%%~nf_x264.mp4"
			del "%%~nf.h264" 
			del "%%~sf.ffindex" 
			del "%%~nf.avs" 	
		) else (
			"%InstallPath%\ffmpeg.exe" -i %%f -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level !level! -maxrate !maxrate! -bufsize !bufsize! "%%~nf.h264"
 
			if exist "%%~nf_x264.mp4" del "%%~nf_x264.mp4" 
			"%InstallPath%\mp4box" -add "%%~nf.h264" -hint -brand mp42 "%%~nf_x264.mp4"
			del "%%~nf.h264" 		
			)
	) else (
		if !ScanType!==Interlaced (
			echo.SetMTMode^(5, 4^) >> "%%~nf.avs"
			echo.LoadPlugin("%AVSPluginFolder%\ffms2.dll"^) >> "%%~nf.avs"
			echo.Import^("%AVSPluginFolder%\QTGMC-3.32.avsi"^) >> "%%~nf.avs"
			echo.A = FFAudioSource^("!infile!"^) >> "%%~nf.avs"
			echo.V = FFVideoSource^("!infile!"^) >> "%%~nf.avs"
			echo.audiodub^(V,A^) >> "%%~nf.avs"
			echo.SetMTMode^(2^) >> "%%~nf.avs"
			echo.ConvertToYV12^(interlaced=true^) >> "%%~nf.avs"
			echo.QTGMC^( Preset="Slow", EdiThreads=2 ^) >> "%%~nf.avs"
			echo.SelectEven^(^) >> "%%~nf.avs"
 
			"%InstallPath%\ffmpeg.exe" -y -i "%%~nf.avs" -aspect !Aspect! -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level !level! -maxrate !maxrate! -bufsize !bufsize! "%%~nf.h264" -c:a %aacEnc% -ab %audioBit% "%%~nf.aac"
 
			if exist "%%~nf_x264.mp4" del "%%~nf_x264.mp4" 
			"%InstallPath%\mp4box" -add "%%~nf.h264" -add "%%~nf.aac" -hint -brand mp42 "%%~nf_x264.mp4"
			del "%%~nf.h264" 
			del "%%~nf.aac" 
			del "%%~sf.ffindex" 
			del "%%~nf.avs" 
		) else (
			"%InstallPath%\ffmpeg.exe" -i %%f -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level !level! -maxrate !maxrate! -bufsize !bufsize! "%%~nf.h264" -c:a %aacEnc% -ab %audioBit% "%%~nf.aac"
 
			if exist "%%~nf_x264.mp4" del "%%~nf_x264.mp4" 
			"%InstallPath%\mp4box" -add "%%~nf.h264" -add "%%~nf.aac" -hint -brand mp42 "%%~nf_x264.mp4"
			del "%%~nf.h264" 
			del "%%~nf.aac" 
			)
		)
	)
 
GOTO end
 
:: ---------------------------------------------------
 
:: Folder Compression -------------------------------
 
:folder
 
set "shortpath=%~s1"
 
if not "%fps%" == "" GOTO comp
set fps=25
 
:comp
 
pushd %input%
	set number=0
 
	for %%i in (*) do (
		set /a number=number+1
		set "file=%%i"
		)
 
	set /a Duration=%number%/25
 
	if %number% LSS 251 set GOPSize=50
 
	set ext=%file:~-4%
	call set name=%%file:%ext%=%%
	set newname=%name:~0,-4%
 
	if %ext% == .exr GOTO compEXR
		set endframe=%name:~-4%
		set frame=%endframe:~0,-3%
 
	if not %frame% == 0 GOTO 4digits
		set frame0=%endframe:~-3%
		set frame1=%endframe:~0,-2%
 
	if not %frame1% == 00 GOTO 3digits
		set frame2=%endframe:~-2%
		set /a startframe=%frame2%-%number%+1
 
	GOTO next
 
	:3digits
	set /a startframe=%frame0%-%number%+1
 
	GOTO next
 
	:4digits
	set /a startframe=%endframe%-%number%+1
 
	:next
	popd
 
set "NewFileName=%newname%%%04d%ext%"
 
pushd "%installpath%" 
	FOR /F %%k in ( 'mediainfo --Inform^=^"Image^;%%Width%%^" "%shortpath%\%file%"' ) do set Width=%%k
	FOR /F %%l in ( 'mediainfo --Inform^=^"Image^;%%Height%%^" "%shortpath%\%file%"' ) do set Height=%%l
	popd
 
if %Width% LEQ 1024 (
	set level=3.2
	set maxrate=4M 
	set bufsize=4M
	)
 
if %Width% GEQ 1280 (
	set level=4.1
	set maxrate=10M 
	set bufsize=10M
	)
 
if %Width% GEQ 1920 (
	set level=5.1
	set maxrate=20M 
	set bufsize=20M
	)
 
echo.
echo....................................................................
echo.....converting Frame Sequence......................................
echo....................................................................
echo.
echo.Duration:  %Duration% Seconds
echo.Width:     %Width%
echo.Height:    %Height%
echo.
echo....................................................................
echo....................................................................
echo.
 
"%InstallPath%\ffmpeg.exe" -start_number %startframe% -i "%input%\%NewFileName%" -r %fps% -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level %level% -maxrate %maxrate% -bufsize %bufsize% "%input%\..\%newname%.h264"
 
if exist "%input%\..\%newname%_x264.mp4" del "%input%\..\%newname%_x264.mp4"
"%InstallPath%\mp4box" -add "%input%\..\%newname%.h264" -hint -brand mp42 "%input%\..\%newname%_x264.mp4"
del "%input%\..\%newname%.h264"
 
GOTO end
 
:compEXR
set /P gamma="Set Gamma Value:"
:: ( gamma: gamma correction )
 
set endframe=%name:~-4%
set frame=%endframe:~0,-3%
 
if not %frame% == 0 GOTO 4digits
	set frame0=%endframe:~-3%
	set frame1=%endframe:~0,-2%
 
if not %frame1% == 00 GOTO 3digits
	set frame2=%endframe:~-2%
	set /a startframe=%frame2%-%number%+1
 
GOTO next
 
:3digits
set /a startframe=%frame0%-%number%+1
 
GOTO next
 
:4digits
set /a startframe=%endframe%-%number%+1
 
:next
 
popd
 
set "var=%newname%%%04d%ext%"
 
pushd "%installpath%"
	FOR /F %%k in ( 'mediainfo --Inform^=^"Image^;%%Width%%^" "%shortpath%\%file%"' ) do set Width=%%k
	FOR /F %%l in ( 'mediainfo --Inform^=^"Image^;%%Height%%^" "%shortpath%\%file%"' ) do set Height=%%l
	popd
 
if %Width% LEQ 1024 (
	set level=3.2
	set maxrate=4M 
	set bufsize=4M
	)
 
if %Width% GEQ 1280 (
	set level=4.1
	set maxrate=10M 
	set bufsize=10M
	)
 
if %Width% GEQ 1920 (
	set level=5.1
	set maxrate=20M 
	set bufsize=20M
	)
 
echo.
echo....................................................................
echo.....converting OpenEXR Sequence....................................
echo....................................................................
echo.
echo.Duration:  %Duration% Seconds
echo.Width:     %Width%
echo.Height:    %Height%
echo.
echo....................................................................
echo....................................................................
echo.
 
if exist "%input%\..\%~n1_tmp.avs" del "%input%\..\%~n1_tmp.avs"
 
echo ImageReader^( "%input%\%var%", start=%startframe%, end=%endframe%, fps=%fps% ^, use_DevIL = true) >> "%input%\..\%~n1_tmp.avs"
echo Levels^(0,%gamma%,255,0,255^) >> "%input%\..\%~n1_tmp.avs"
 
"%InstallPath%\ffmpeg.exe" -i "%input%\..\%~n1_tmp.avs" -pix_fmt yuv420p -c:v libx264 -preset %preset% -crf %quality% -g %GOPSize% -profile:v Main -level %level% -maxrate %maxrate% -bufsize %bufsize% "%input%\..\%newname%.h264"
 
if exist "%input%\..\%newname%_x264.mp4" del "%input%\..\%newname%_x264.mp4"
"%InstallPath%\mp4box" -add "%input%\..\%newname%.h264" -hint -brand mp42 "%input%\..\%newname%_x264.mp4"
del "%input%\..\%newname%.h264"
 
if exist "%input%\..\%~n1_tmp.avs" del "%input%\..\%~n1_tmp.avs"
 
:end
echo.
echo....................................................................
echo.
echo.....................converting done................................
echo.
echo....................................................................
echo.
 
ping 127.0.0.0 -n 3 >nul
echo.
echo Window close in 15
echo.
ping 127.0.0.0 -n 5 >nul
echo.
echo Window close in 10
echo.
ping 127.0.0.0 -n 5 >nul
echo.
echo Window close in 5
echo.
ping 127.0.0.0 -n 5 >nul
echo.