-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Timelapse Creator 1.0.1.bat
667 lines (471 loc) · 13.7 KB
/
_Timelapse Creator 1.0.1.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
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
setlocal enabledelayedexpansion
@echo off
]2;Timelapse Creator by Jan Weigang
Rem |---- Set Basic Variables ----|
mode con: cols=120 lines=30
set dirfull=_Full Video
set dirproxy=_Proxy Video
set dirgifs=GIFs
set profile=2
set crf=18
set keyframes=1
set hcontainer=mov
set pcontainer=mov
set maxsize=15
set deflickersize=15
set deflickermode=am
set deflicker=size=%deflickersize%:mode=%deflickermode%
set deflickertoggle=on
set proxytoggle=off
set motiontoggle=off
echo %cd%\%dirfull%\NUL
if not exist "%dirfull%\" mkdir "%dirfull%"
if not exist "%dirproxy%\" mkdir "%dirproxy%"
if not exist "%dirgifs%\" mkdir "%dirgifs%"
Rem |---- Detect Images ----|
:images
set imagetype=png
set name=UNDEFINED
set fps=25
for %%A in (*.png) do (
set "name=%%~nA.png"
set imagetype=png
goto continue
)
for %%A in (*.jpg) do (
set "name=%%~nA.jpg"
set imagetype=jpg
goto continue
)
if name EQU UNDEFINED (
echo [91mNo images found! Exiting...[0m
goto end
)
:continue
set name=%name:~0,-8%
Rem |---- Menu and Codec ----|
:menu
echo.&cls
echo - - - - - [36mTimelapse Creator[0m by [36mJan Weigang[0m - - - - -
echo.
echo Found the following %imagetype%s: [96m%name%[0m
echo.
set codec=prores
set height=2160
set custom=n
set bitrate=100
echo.
echo [97mPick Preset (press number to continue)[0m:
echo.
echo 1. [96mProres 4k[0m
echo 2. [96mh264 1080[0m
echo 3. [96mh265 1080[0m
echo.
echo 5. Custom Video
echo.
echo.
echo [90m- - advanced settings: - -[0m
echo [90mp. Toggle Proxy ([36m%proxytoggle%[90m)[0m
echo [90md. Toggle Deflicker ([36m%deflickertoggle%[90m)[0m
echo [90mm. Toggle Motion Interpolation ([36m%motiontoggle%[90m)[0m
echo.
echo 0. GIFs
echo.
echo [30m
choice /C 1235pdm0 /N
if %ERRORLEVEL% EQU 8 (
set codec=gif
set height=360
goto presetcontinue
)
if %ERRORLEVEL% EQU 7 (
if %motiontoggle% EQU on (
set motiontoggle=off
) else (
set motiontoggle=on
)
[0m
goto menu
)
if %ERRORLEVEL% EQU 6 (
if %deflickertoggle% EQU on (
set deflickertoggle=off
set deflicker=bypass=1
) else (
set deflickertoggle=on
set deflicker=size=%deflickersize%:mode=%deflickermode%
)
[0m
goto menu
)
if %ERRORLEVEL% EQU 5 (
if %proxytoggle% EQU on (
set proxytoggle=off
) else (
set proxytoggle=on
)
[0m
goto menu
)
if %ERRORLEVEL% EQU 4 (
set custom=y
set width=3840
goto presetcontinue
)
if %ERRORLEVEL% EQU 3 (
set codec=h265
set height=1080
goto presetcontinue
)
if %ERRORLEVEL% EQU 2 (
set codec=h264
set height=1080
goto presetcontinue
)
if %ERRORLEVEL% EQU 1 (
set codec=prores
set height=2160
goto presetcontinue
)
:presetcontinue
echo [0m
if %custom% EQU y goto custommenu
Rem |---- Preset Framerate ----|
:framerate
set /P fps=[97mPlease enter the framerate:[0m
set "var="&for /f "delims=0123456789" %%i in ("%fps%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto framerate
)
goto process
Rem Going to Process unless GIFs are selected as preset
Rem TODO: Custom Menu
Rem |---- Custom Menu ----|
:custommenu
set /A ratio = %width% / %height%
echo.&cls
echo - - - - - [36mTimelapse Creator[0m by [36mJan Weigang[0m - - - - -
echo.
echo.
echo [97mPick setting to change (press number to continue)[0m:
echo.
echo 1. Codec: [96m%codec%[0m
echo 2. Resolution: [96m%height%p[0m
echo 3. Framerate: [96m%fps% fps[0m
echo.
echo 4. Width/Aspect [36m%width% px[0m
echo.
echo [90m- - %codec% settings: - -[0m
Rem |--- Prores Settings ---|
if %codec% EQU prores echo 5. Container: [36m%pcontainer%[0m
if %codec% EQU prores echo 6. Profile (0-5): [36m%profile%[0m
Rem |--- h264 Settings ---|
if %codec% EQU h264 echo 5. Container: [36m%hcontainer%[0m
if %codec% EQU h264 echo 6. CRF (0-51): [36m%crf%[0m
if %codec% EQU h264 echo 7. Bitrate: [36m%bitrate% Mbit[0m
if %codec% EQU h264 echo 8. Keyframe: [36mevery %keyframes% second(s)[0m
Rem |--- h265 Settings ---|
if %codec% EQU h265 echo 5. Container: [36m%hcontainer%[0m
if %codec% EQU h265 echo 6. CRF (0-51): [36m%crf%[0m
if %codec% EQU h265 echo 7. Bitrate: [36m%bitrate% Mbit[0m
if %codec% EQU h265 echo 8. Keyframe: [36mevery %keyframes% second(s)[0m
Rem |--- Prores Settings ---|
if %codec% EQU gif echo 9. Max-Size: [36m%maxsize% MB[0m
echo.
echo.
echo.
echo.
echo [90m- - advanced settings: - -[0m
echo [90mp. Toggle Proxy ([36m%proxytoggle%[90m)[0m
echo [90md. Toggle Deflicker ([36m%deflickertoggle%[90m)[0m
echo [90mm. Toggle Motion Interpolation ([36m%motiontoggle%[90m)[0m
echo.
echo 0. Start rendering
echo [30m
choice /C 123456789pdm0 /N
if %ERRORLEVEL% EQU 13 goto process
if %ERRORLEVEL% EQU 12 (
if %motiontoggle% EQU on (
set motiontoggle=off
) else (
set motiontoggle=on
)
[0m
goto custommenu
)
if %ERRORLEVEL% EQU 11 (
if %deflickertoggle% EQU on (
set deflickertoggle=off
set deflicker=bypass=1
) else (
set deflickertoggle=on
set deflicker=size=%deflickersize%:mode=%deflickermode%
)
[0m
goto custommenu
)
if %ERRORLEVEL% EQU 10 (
if %proxytoggle% EQU on (
set proxytoggle=off
) else (
set proxytoggle=on
)
[0m
goto custommenu
)
if %ERRORLEVEL% EQU 9 goto pickfilesize
if %ERRORLEVEL% EQU 8 goto pickkeyframes
if %ERRORLEVEL% EQU 7 goto pickbitrate
if %ERRORLEVEL% EQU 6 goto pickquality
if %ERRORLEVEL% EQU 5 goto pickcontainer
if %ERRORLEVEL% EQU 4 goto pickwidth
if %ERRORLEVEL% EQU 3 goto pickfps
if %ERRORLEVEL% EQU 2 goto pickheight
if %ERRORLEVEL% EQU 1 goto pickcodec
Rem |---- Custom Menu - prompts ----|
Rem 1 Codec, 2 Height, 3 FPS, 4 Width, 5 Container, 6 Profile / CRF, 7 Bitrate, 8 Keyframes (sekunden), 9 Filesize (GIF), 0 Start
:pickcodec
echo [0m
echo.&cls
echo - - - - - [36mTimelapse Creator[0m by [36mJan Weigang[0m - - - - -
echo.
echo.
echo [97mPick codec (press number to continue)[0m:
echo.
echo 1. [96mprores[0m
echo 2. [96mh264[0m
echo 3. [96mh265%[0m
echo 4. [96mGIF[0m
echo.
echo [30m
choice /C 1234 /N
if %ERRORLEVEL% EQU 4 set codec=gif
if %ERRORLEVEL% EQU 3 set codec=h265
if %ERRORLEVEL% EQU 2 set codec=h264
if %ERRORLEVEL% EQU 1 set codec=prores
echo [0m
goto custommenu
Rem - - - - - - - - - - - - Custom height:
:pickheight
echo [0m
set /P height=[97mPlease enter y-resolution:[0m
set "var="&for /f "delims=0123456789" %%i in ("%height%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickheight
)
set /A width=%height% * 16 / 9
goto custommenu
Rem - - - - - - - - - - - - Custom FPS:
:pickfps
echo [0m
set /P fps=[97mPlease enter the framerate:[0m
set "var="&for /f "delims=0123456789" %%i in ("%fps%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickfps
)
goto custommenu
Rem - - - - - - - - - - - - Custom Bitrate:
:pickbitrate
echo [0m
set /P bitrate=[97mPlease enter the bitrate:[0m
set "var="&for /f "delims=0123456789" %%i in ("%bitrate%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickbitrate
)
goto custommenu
Rem - - - - - - - - - - - - Custom Width:
:pickwidth
echo [0m
echo [93mWarning: [33mPicking Width (instead of height) changes the aspect ratio. Set height first.[0m
echo Current Value: [36m%width% px[0m
echo.
echo.
set /P width=[97mPlease enter x-dimension:[0m
set "var="&for /f "delims=0123456789" %%i in ("%width%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickwidth
)
goto custommenu
Rem - - - - - - - - - - - - Custom Container:
:pickcontainer
echo [0m
echo.&cls
echo - - - - - [36mTimelapse Creator[0m by [36mJan Weigang[0m - - - - -
echo.
echo.
echo [97mPick codec (press number to continue)[0m:
echo.
echo 1. [96mmov[0m
if %codec% EQU prores (
echo 2. [96mmkv[0m
) else (
echo 2. [96mmp4[0m
)
echo.
echo [30m
choice /C 12 /N
if %ERRORLEVEL% EQU 2 (
if %codec% EQU prores (
set pcontainer=mkv
) else (
set hcontainer=mp4
)
)
if %ERRORLEVEL% EQU 1 (
if %codec% EQU prores (
set pcontainer=mov
) else (
set hcontainer=mov
)
)
echo [0m
goto custommenu
Rem - - - - - - - - - - - - Custom Quality:
:pickquality
echo [0m
if %codec% EQU prores echo Current Value: [36m%profile%[0m
if %codec% NEQ prores echo Current Value: [36m%crf%[0m
echo.
if %codec% EQU prores set /P profile=[97mPlease enter profile:[0m
if %codec% NEQ prores set /P crf=[97mPlease enter crf value:[0m
set "var="&for /f "delims=0123456789" %%i in ("%profile%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickquality
)
set "var="&for /f "delims=0123456789" %%i in ("%crf%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickquality
)
goto custommenu
Rem - - - - - - - - - - - - Custom keyframes:
:pickkeyframes
echo [0m
echo Current Value: Keyframe every [36m%keyframes% second(s)[0m
echo.
echo.
set /P keyframes=[97mPlease enter seconds:[0m
set "var="&for /f "delims=0123456789" %%i in ("%keyframes%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickkeyframes
)
goto custommenu
Rem - - - - - - - - - - - - Custom filesize (gif):
:pickfilesize
echo [0m
echo Current Value: [36m%maxsize% MB[0m
echo.
echo.
set /P maxsize=[97mPlease enter maximum filesize for short gif:[0m
set "var="&for /f "delims=0123456789" %%i in ("%maxsize%") do set var=%%i
if defined var (
echo [91mEntered Value is not numeric[0m
goto pickfilesize
)
goto custommenu
Rem |------------------------------ Start of Process ------------------------------------|
:process
set deflickername=
if %deflickertoggle% EQU on set deflickername=_deflicker
set motionname=
if %motiontoggle% EQU on set motionname=x2
set /A doublefps=%fps% * 2
set motion=
if %motiontoggle% EQU on set motion=,minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=%doublefps%:me=ds'
if %custom% EQU n set /A width = %height% * 16 / 9
if %codec% EQU gif goto processgifs
if %custom% EQU n set /A bitrate = (%bitrate% + (%fps% * 2)) * %height% / 2160
set /A keyfps=%fps%*%keyframes%
echo.&cls
echo - - - - - [36mTimelapse Creator[0m by [36mJan Weigang[0m - - - - -
echo.
echo Settings:
echo.
echo Codec: [96m%codec%[0m
echo Dimensions: [96m%width% x %height% p %fps%[0m
echo Bitrate: [96m%bitrate% Mbit[0m
Rem |---- Video Creation ----|
:full
echo.
echo.
echo Creating [96m%codec% %height%p video with %fps% fps...[93m
echo.
if %codec% EQU prores (
ffmpeg.exe ^
-framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv422p10le ^
-c:v %codec% -profile:v 2 -alpha_bits 0 -loglevel error -stats ^
-filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^
"%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov"
)
if %codec% EQU h264 (
ffmpeg.exe ^
-framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv420p ^
-c:v libx264 -quality good -g %keyfps% -b:v %bitrate%M -loglevel error -stats ^
-filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^
"%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov"
)
if %codec% EQU h265 (
ffmpeg.exe ^
-framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt yuv420p ^
-c:v libx265 -quality good -g %keyfps% -b:v %bitrate%M -loglevel error -stats ^
-x265-params log-level=error ^
-filter:v "crop=%width%:%height%:exact=1,setsar=1,deflicker=%deflicker%%motion%"^
"%dirfull%\%name%%codec%_%fps%%motionname%%deflickername%.mov"
)
echo [93mDone.[0m
:proxy
if %proxytoggle% EQU off goto end
echo.
echo.
if %codec% EQU prores (
echo Creating [96m%codec% 720p proxy with %fps% fps...[93m
echo.
ffmpeg.exe ^
-i %name%%%04d.%imagetype% -s 1280x720 -pix_fmt yuv422p10le -framerate %fps% ^
-c:v %codec% -profile:v 2 -alpha_bits 0 -loglevel error -stats ^
-filter:v "crop=1280:720:exact=1,setsar=1,deflicker=%deflicker%"^
"%dirproxy%\%name%%codec%_%fps%%deflickername%.mov"
)
if %codec% EQU prores echo [93mDone.[0m
goto end
Rem ------------------------------
Rem |---- GIF Creation ----|
:processgifs
echo.
echo.
echo Creating [96mFull Length GIF...[93m
echo.
ffmpeg.exe -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt rgb8 -c:v gif ^
-loglevel error -stats ^
"%dirgifs%\%name%%height%p%fps%_full.gif"
echo [93mDone.[0m
echo.
echo.
echo Creating [96mShort GIF (15MB)...[93m
echo.
ffmpeg.exe -framerate %fps% -i %name%%%04d.%imagetype% -s %width%x%height% -pix_fmt rgb8 -c:v gif -fs %maxsize%M ^
-loglevel error -stats ^
"%dirgifs%\%name%%height%p%fps%_short.gif"
echo [93mDone.[0m
echo.
echo.
goto end
Rem ------------------------------
:end
echo.
echo.
if %ERRORLEVEL% NEQ 0 (
echo [93mFound an [91merror[93m and paused.[0m
pause
)
echo.
echo Finished.
timeout /t 5
endlocal