max5moritz
Goto Top

Film-Montage mit ffmpeg mit NeuCodieren oder Umlabeln, Videogröße ändern und Streams umgruppieren (mappen)

Für "ffmpeg" gibt es bereits viele Gui (Benutzer-Oberflächen), warum also dann diesen Skript.Zuerst weil es mir Spaß gemacht hat.
Zum anderen: Oft erschlagen mich die Einstell-Möglichkeiten. Dieser Skript fragt nur das, was für die Aufgabe notwendig ist.
Und das hübsch der Reihe nach. Selbst Anfänger können damit ihr Video-Material ihren Bedürfnissen anpassen.

back-to-topFür die Eiligen

Das Wichtigste steht auch im Kopf des Skriptes "Film-Montage". Dass die DateiNamen eine -EndZiffer brauchen, muss ich das erwähnen? face-big-smile
Nicht vergessen: Die "MediaDat" wird auch noch benötigt.


back-to-topWarum Film-Montage?

Ganz einfach, weil der Zusammenhang zwischen Eingangs- und Ausgangs-Bildgröße mit der Orignal-Filmgröße recht komplex ist, wie ein Blick
auf die folgende Tabelle zeigen mag:

f44b1208ecb5da70f0619d9e82cb9146

Damit kann der Schnitt für verschiedene Ausgaben errechnet werden, dort gibt es mehr Hintergrundwissen dazu.
"Film-Montage" erledigt das nebenbei. Wer Interesse an der Tabelle hat, kann sich gern melden.

Ursprünglich sollte es nur ein paar Zeilen-Code werden. Eben, um halt Filmteile zusammenzufügen. Doch dann dachte ich mir, es kann ja
nicht schaden, wenn der gesamte Prozess skriptgesteuert abläuft. Erstens macht man es ja vielleicht nicht so oft und zweitens, kann zwar "ffmpeg" viel,
und dass auch allein, aber den Rest, den will es dann immer ganz genau wissen. Sonst geht es schief.
So sind es dann gut 600, gefühlte 1000 Zeilen geworden. Ich hoffe: Ihr habt Spaß damit.

back-to-topUpdate

Ja, es gibt bereits ein Update. Eine Kleinigkeit - Ich habe einen Zeitstempel eingefügt. Dieser ist Teil der start-set.bat.
Version-Stand: 1.3 - Der Zeitstempel hatte fehlende "AnführungsZeichen" angezeigt. Das ist nun behoben.
Er soll verhindern, dass die Skripte - auf Mehrkern-Rechnern kann ffmpeg auch mehrfach laufen - sich gegenseitig die Infos überschreiben. face-devilish
Die Version-Nr. erscheint kurz nach dem Start als Fenster-Titel. Er sollte mit der von "MediaDat" übereinstimmen. Den Zeit-Stempel findet Ihr unten.
Fehlt die start-set wird sie jetzt mit erstellt. Allein das Anpassen müßt Ihr schon noch selbst. 0face-smile

back-to-topIm Überblick

Und für die, die es genauer wissen wollen, folgt jetzt eine kurze Anleitung:

Ich habe den Skript modular aufgebaut. Der grobe Ablauf ergibt sich somit aus den Zeilen 24-37.

Welche Medien werden unterstützt?
Ich weiss es nicht, was "ffmpeg" alles kann. Da "Film-Montage" auch ein Einzelstück verarbeitet, kann das jeder einfach ausprobieren.

Einzige Bedingung:
Der Dateiname hat am Ende ein Zeichen und eine 1 (z.B.: Media-1.mp4), sonst gibt es eine Fehlermeldung, dass die Anzahl nicht stimmt.
Ansonsten haben Medien-Teilstücke wie die auf einer DVD ja bereits die enstprechende Namensgebung.

Das Zusammenfügen per copy /b habe ich für mp3, mpg, mpe und vob ausprobiert und hinterlegt. Dies kann in Zeile 19 modifiziert werden.
Das Seitenverhältnis, auch Aspect Ratio genannt ist in der Zeile 21 mit 16:9 festgelegt.
Die TestZeit für Probe-Arbeiten habe ich mit 3 min bestimmt. Wer es anders braucht, kann es in Zeile 22 verändern.
Das waren die drei Skript-Vor-Einstell-Möglichkeiten, der Rest wird während der Arbeit abgefragt.

Für die mp4-Montage wird "mp4box" verwendet und für alle anderen, außer den copy-Vorgaben, wird "mencoder" bemüht.
Diese Programme sind wie "ffmpeg" u.a. Teil von "Hybrid", welches ihr dort findet.
Die Namen aller Programme sind in der Zeile 18 als Variable angelegt. Sie dient zum Check, ob auch alle da sind!


back-to-topDer Ablauf

1. MannerInput abklären und wie der Prozess ablaufen soll
2. ContainerWelchen Output-Container (z.B. mp4 / mkv)
3. TitelWelchen Namen soll das "Kind" kriegen?
4. ParameterDas passende Montage-Werkzeug wird vorbereitet
5. MontageAnzeige de gemachten Eingaben und Montage der Teile
- Abzweig zum AnfangFalls die Eingaben falsch waren, return to begin
- Sprung zum EncoderFalls mehrere Teile anstehen, wird erst der Encoder vorbereitet
6. MediaDatInfos einholen und Filmschnitt errechnen.
7. MappingIst mehr als ein Stream der gleichen Art (z.b. Audio) vorhanden, kann nun die Reihenfolge geändert werden
8. EncoderDie gewünschte Umwandlung.
9. Timer-LogNach einem Test-Lauf oder nach Fehlern, wird jetzt ein "reCall" angeboten. Ansonsten Dauer berechnen und ausgeben, fertig.


back-to-topDer Skript

@echo off&setlocal enabledelayedexpansion&mode con cols=91 lines=9&color 3F&title %~n0 - Vers. 1.3
REM Die Variablen wie z.B. %ffmpeg%, die Programme gleichen Namens starten sollen, sind in einer start-set.bat analog nach diesem Muster
REM anzulegen: set "ffmpeg=C:\Pfad zum Progs\ffmpeg.exe", wobei ".exe" auch weggelassen werden kann. Hauptsache der Rest stimmt ;-)  
REM Damit dieser Skript funktioniert, wird noch meine MediaDat.bat benötigt. Alle Skripte sollten sich im selben Ordner befinden.
REM Der Skript läuft auch mit Doppelklick, falls sich alle Dateien (Skripte und z.B. Video_1-4.* in einem Ordner befinden. 
REM Doch der sinnvollste Aufruf geht über eine Verknüpfung im SendTo-Ordner von WinXP etc. pp.
set "info=  Zusammenfgen von Video- oder Audio-Dateien&echo   mit wahlweiser Umwandlung (Encodierung) mittels "ffmpeg""  
set "info=%info%&echo   Container-Wahl nach Belieben (ffmpeg), die Eingaben erfolgen per Skript-Abfrage."  
echo.& echo %info%&ping -n 3 localhost 1>nul 2>nul
if "%~1"=="" echo. & echo                  Entwurf und Layout by max5moritz&ping -n 12 localhost 1>nul 2>nul  
if not "%~1"=="" set "input=%~1" & set "BatWindow=von "%~nx1""  
set "info=echo     Erst noch den Start-set-Skript ^(*.bat oder *.cmd^) anpassen."  
if not exist "%~dp0start-set.*"	cls&echo.&echo.&echo.&%info%&ping -n 4 localhost 1>nul 2>nul &(  
	call :startSet & ping -n 2 localhost 1>nul 2>nul)
set "li29=echo -----------------------------"  
set "mod1=mode con cols=55 lines=8& color FC"  
set "mod2=mode con cols=88 lines=24&color 70"  
:reStart
%mod1% & call start-set "progs" "stamp"  
set "prgs=ffmpeg,mp4box,mencoder,vsrip"  
set "copy=mp3,mpg,mpe,vob"  
set "path=%path%;%~dp0"  
set "aspt=-aspect 16:9"  
set "tcod= -t 0:03:00"  

:Main
call :Manner "%input%"  
call :Container
call :Titel
call :Parameter
call :Montage
if "%newSet%"=="yes" goto :Main  
if "%mapEnc%"=="yes" goto :mapEnc  
call :MediaDat "%input%"  
call :Mapping
:mapEnc
call :Encoder
call :Timer-Log
exit

:Manner
if "%~1"=="" echo.&call :noinPut  
if "%input%"=="" (goto :eof) ELSE call :pprob  
title %~n0 %BatWindow%
%mod1%& set "encoder=no"& set "newSet=no"  
if not "%~1"=="" set "inFile=%~n1" & set "inEXC=%~x1"  
set "inFile=%inFile:~0,-1%" & set "Titel=%inFile:~0,-2%"  
if "%inEXC%"==".mp3" (set "Medium=Musik") ELSE set "Medium=Film"  
echo.&echo  %Medium% nur montieren?& set /P answer= j/n? 
if /i "%answer%"=="j" set "code= -c copy -map 0 "& set "mont1=echo  %Medium% encodieren    : nein"  
if /i "%answer%"=="n" set "encoder=yes" & set "code= "& set "mont1=echo  %Medium% encodieren    : ja"  
if "%answer%"=="" set "code= -c copy -map 0 "& set "mont1=echo  %Medium% encodieren    : ja"  
set answer=&echo.&echo  Montage testen?& set /P answer= j/n? 
if /i "%answer%"=="j" set "tcod=%tcod%"& set "mont2=echo  %Medium%-Montage testen: ja"  
if /i "%answer%"=="n" set "mont2=echo  %Medium%-Montage testen: nein"  
if "%answer%"=="" set "mont2=echo  %Medium%-Montage testen: nein"  
if "%mont2:~-2,2%"=="ja" (set "Test=Test") ELSE set "tcod="  
cls & set "answer=" & if not "%~1"=="" pushd %~dp1  
goto :eof

:Container
set "MiD-Info=%tmp%\%stamp%MiD-Info.txt"& set "exc=%inEXC%"  
if not "%input%"=="" %ffmpeg% -i "%input%" 2> "%MiD-Info%" &(   
	find /n /i "Subtitle" "%MiD-Info%" 1>nul  
	if errorlevel 1 set "oxc=mp4" & set "subti=no" & goto :con1  
	if errorlevel 0 (set "oxc=mkv"& set "subti=yes"  
	) ELSE set "oxc=mp4 & set "subti=no"  
	)
if not "%~1"=="" goto :eof  
:con1
if "%exc:~0,1%"=="." set "exc=%exc:~1,3%"  
cls&echo.&echo  %Medium%-Container selbst festlegen?
set /P answer= j/n? 
if /i "%answer%"=="j" echo.&set /P oxc= Welchen %Medium%-Container?  &cls&echo.  
if "%oxc%"=="" goto :con1  
set answer=&set "mont3=echo  %Medium%-Container     : %oxc%"  
if "%oxc:~0,1%"=="." set "oxc=%oxc:~1,3%"  
if "%~1"=="Testen" goto :eof  
FOR %%i IN (%copy%) DO if /i "%exc%"=="%%i" set "copy=yes"  
:con2
echo.&echo.&set /P anz= Wie viele %Medium%teile? 
if "%anz%"=="" cls&echo.&echo  Bitte eine Zahl eingeben&goto :con2  
set /a anz2=%anz%+0  2>nul
if %anz% NEQ %anz2% cls&echo.&echo  "%anz%" ist keine Zahl&set "anz="&goto :con2  
set "mont4=echo  %Medium%-Teile-Anzahl  : %anz%"  
goto :eof

:Titel
if "%input%"=="" (echo.& set /P Titel= Bitte %Medium%-Titel eingeben.    
	) ELSE cls & echo. & echo  "%Titel%" & echo.  
echo  %Medium%-Titel ok?&echo. & set /P answer= j/n?  
if /i "%answer%"=="j" set "outFile=%Titel%" & goto :tit1  
if /i "%answer%"=="n" cls&echo.&echo  Bitte einen %Medium%-Titel eingeben:&echo.& set /P outFile=   
:tit1
if not "%outFile%"=="" set "mont5=echo  %Medium%-Datei-Name    : %outFile%"&goto :eof  
cls & set answer=& goto :Titel
goto :eof

:Parameter
set "Nr=2"  
if "%anz%"=="1" goto :eof  
if /i "%exc%"=="mp4" (set "parm=-cat "%inFile%2.%exc%""  
	) ELSE if /i "%copy%"=="yes" (set "parm=+"%inFile%2.%exc%""  
	) ELSE set "parm="%inFile%2.%exc%""  
if "%anz%"=="%Nr%" goto :eof  
:prm1
set /A Nr=%Nr%+1
if /i "%exc%"=="mp4" (set "parm=%parm% -cat "%inFile%%Nr%.%exc%""  
	) ELSE if /i "%copy%"=="yes" (set "parm=%parm%+"%inFile%%Nr%.%exc%""  
	) ELSE set "parm=%parm% "%inFile%%Nr%.%exc%""  
if "%anz%" gtr "%Nr%" goto :prm1  
goto :eof

:Montage
if not exist "%inFile%%anz%.%exc%" cls&echo.&(  
echo  %Medium%-Teile-Anzahl stimmt nicht
echo  "%inFile%%anz%.%exc%"&set "anz=no")  
if "%anz%"=="no" call :con2 & goto :Montage  
%mod2%& set "ffpg=no"& call :LenSet "%BatWindow% zu %outFile%.%oxc%"& set "BatWindow=%BatWindow:~0,-7%": %anz%x *.%exc% zu "%outFile%.%oxc%""  
set /A cols=15+%LenSet%
if %cols% lss 48 set "cols=48"  
mode con cols=%cols% lines=24
set "monTitel=title %~n0 %BatWindow%"  
%monTitel%& cls & echo.&echo  Zusammenfassung&%li29%
:mon1
set answer=&%mont1%&%mont2%&%mont5%&%mont3%&%mont4%&%li29%
echo.&echo  Montage starten?& set /P answer= j/n? 
if "%answer%"=="" cls&echo.&echo  Bitte Freigabe, wenn ok.& %li29%& goto :mon1  
if /i "%answer%"=="j" goto :mon2  
if /i "%answer%"=="n" set "newSet=yes" & goto :eof  
:mon2
if "%anz%"=="1" (set "ffpg=go" & goto :eof  
	) ELSE call :MediaDat "%input%" & call :Mapping "mapEnc"  
if "%mapEnc%"=="yes" goto :eof  
:mon3
%monTitel%
if "%Test%"=="Test" set "ffpg=go"& goto :eof  
if exist "%outFile%.%exc%" set "ffpg=go"&set "timLog=%outFile%.%exc%"& goto :eof  
if /i "%exc%"=="mp4" (%mp4box% "%inFile%1.%inEXC%" %parm% -out "%outFile%.%exc%"  
	) ELSE if /i "%copy%"=="yes" (cls&echo.& echo "%outFile%.%oxc%"&echo.&(  
		   echo  %anz% %Medium%-Teile werden montiert&%li29%&echo.
		   copy /b "%inFile%1.%exc%"%parm% "%outFile%.%exc%")  
	) ELSE %mencoder% -idx -ovc copy -oac copy -o "%outFile%.%exc%" "%inFile%1.%exc%" %parm%  
color 1F& ping -n 5 localhost 1>nul 2>nul
if exist "%outFile%.%exc%" set "ffpg=go"  
goto :eof

:MediaDat
%mod2%&setlocal
if not "%input%"=="" call MediaDat "%input%" "%time:~0,8%"  
title Prfen der Media-Daten von: %~nx1
pushd %~dp1 & set /A lines=16+%ziffer%
if %lines% lss 28 set "%lines%=28"  
mode con cols=88 lines=%lines%&color 70
For /f "delims=x tokens=1,2" %%a IN ("%vi5%") DO @set "vi5B=%%a"& set "vi5H=%%b"  
For /f "delims=DR: tokens=1-6" %%a IN ("%vi10%") DO @set "vi10B=%%b"& set "vi10C=%%c"& set "vi10E=%%e"& set "vi10F=%%f"  
set "SB=%vi10B:~1,2%"& set "SH=%vi10C:~,-1%"& set "DB=%vi10E:~1,2%"& set "DH=%vi10F%"  
if "%mont2:~-4,4%"=="nein" echo.& goto :mdd2  
:mdd1
echo.&echo  Der %Medium% hat die folgende Video-Parameter:&%li29%%li29:~5,20%
echo  !vi10!&echo.&echo  Pixel : !vi5!&echo  Breite: %vi5B%&echo  H”he  : %vi5H%&echo.
echo      S1: %SB%&echo      S2: %SH%&echo      D1: %DB%&echo      D2: %DH%&echo.
:mdd2
echo.&echo  %Medium% skalieren oder Abmaáe ver„ndern?& set /P answer2= j/n? 
if /i "%answer2%"=="n" goto :mdd9  
if /i "%answer2%"=="j" goto :mdd3  
cls & echo.& echo  Bitte beantworten.
goto :mdd1
:mdd3
if %DB% neq 4 set "topBot=no"& goto :mdd8  
set /A OAR=(%SB%*100/%SH%)-100+%DH%
if %oar% equ 9 set "oar=1,78"& goto :mdd5  
:mdd4
echo  SAR %SB%:%SH% u. DAR %DB%:%DH%
echo  Welchen OAR hat der %Medium%?
echo  z.B.: %Medium% mit 16:9 hat OAR= 1,78&echo.&set /P OAR= OAR: 
if "%oar%"=="" cls &echo.&echo  Bitte einen Wert eingeben& goto :mdd4  
if "%OAR-Wert%"=="" call :OAR-Wert "orw1"  
FOR %%i IN (%OAR-Wert%) DO if "%oar%"==%%i goto :mdd5  
call :OAR-Wert & goto :mdd4
:mdd5
call :InfoCut
echo.&echo  Werte okay?& set /P answer1= j/n? 
if /i "%answer1%"=="n" goto :mdd4  
if /i "%answer1%"=="j" goto :mdd6  
goto :mdd4
:mdd6
set answer2=& echo.
echo  %Medium% mit den Werten skalieren?& set /P answer2= j/n? 
if /i "%answer2%"=="n" goto :mdd7  
if /i "%answer2%"=="j" if "%padN%"=="yes"  set "topBot= %Crop%"& goto :mdd8  
if /i "%answer2%"=="j" if "%croN%"=="yes"  set "topBot= %Padd%"& goto :mdd8  
if "%answer2%"=="" (if "%croN%"=="yes" set "topBot= %Padd%"&set "answer2=j"&goto :mdd8  
			 ) ELSE if "%padN%"=="yes" set "topBot= %Crop%"&set "answer2=j"&goto :mdd8  
cls & echo.& echo  Da war wohl ein Fehler.& goto :mdd4
:mdd7
goto :mdd9
echo  Eigene Crop- und Pad-Werte eingeben?& set /P answer3= j/n?
if /i "%answer3%"=="n" goto :mdd9  
goto :mddx
:mdd8
if  "%topBot%"=="no" (echo.&echo  Pixel-/ Seitenverh„ltnisse sind ok.& ping -n 3 localhost 1>nul 2>nul  
	) ELSE echo.&(
echo  %Medium% wird wie folgt angepaát:
echo                        topBot: "%topBot%" & ping -n 2 localhost 1>nul 2>nul&echo.)  
if not "%topBot%"=="no" echo  Einen Moment noch, es geht gleich weiter ...&color 1F& ping -n 8 localhost 1>nul 2>nul  
if "%subti%"=="yes" if exist  "%outFile%.%su9%" set "subFile= -i "%outFile%.%su9%""  
:mdd9
endlocal & set "subFile=%subFile%"&(  
if /i "%answer2%"=="j" (set "topBot=%topBot%") ELSE set "topBot=no"  
FOR /f "delims==" %%i IN ('set answer') DO @set "%%i="  
set "vi5=%vi5%"&set "su8=%su8%"&set "lin6=%lin6%"&set "StNr=%StNr%"  
set "subFile=%subFile%")  
goto :eof

:Mapping
title Mapping-Check&color 70& setlocal
cls&echo.&set "map2map= " & set nr2nr=0  
if exist "%tmp%\%stamp%MiD-map.tmp" del "%tmp%\%stamp%MiD-map.tmp"  
FOR %%a IN (Video,Audio,Subtitle,Unknown) DO @(
	set mapChek=%%a
	:map1
	set "map=!map2map!" & set "mapNr=%nr2nr%"  
	FOR /f "delims=-: tokens=1-3" %%i IN ('findstr /i /n "!mapChek!" "%tmp%\%stamp%MiD-Anzg.tmp"') DO @(  
	set /A mapNr+=1
	set /A strNr=%%k
	echo  !mapChek!-!strNr! = !mapNr!
	echo  !mapChek!-!strNr! = !mapNr! >> "%tmp%\%stamp%MiD-map.tmp"  
	ping -n 1 localhost 1>nul 2>nul
	set "map=!map!-map 0:!strNr! "  
	set "map!mapNr!=-map 0:!strNr! "  
	)
	if !mapNr! equ 0 echo  Keine !mapChek! vorhanden.&(
		set "map2map=!map!"& set "mapFrg=exit"&color 1F  
		if not "!mapChek!"=="Unknown" ping -n 3 localhost 1>nul 2>nul  
		)
	call :mapFrg
)
:map2
if "%encoder%"=="yes" if "%subti%"=="yes" (if "%topBot%"=="no" (set "code= -s %vi5% -r 25 -c:a copy -c:s %su8%%map2map%"  
																) ELSE set "code=%topBot% -c:a copy -c:s %su8%%map2map%"  
									) ELSE if "%topBot%"=="no" (set "code= -s %vi5% -r 25 -c:a copy%map2map%"  
																) ELSE set "code=%topBot% -c:a copy%map2map%"  
endlocal & set "code=%code%"&set "map2map=%map2map%"&set "mapNsub=%mapNsub%"&if "%~1"=="mapEnc" set "%~1=yes"  
goto :eof

:Encoder
title Letzter Check vor Encoder-Start:
call :LenSet "%code%"  
set /A cols=48+%LenSet%*2
if %cols% lss 119 (set "cols=119") ELSE if %cols% gtr 150 set "cols=150"  
set /A Lines=24+%StNr%*3
if %Lines% lss 30 (set "Lines=30") ELSE if %Lines% gtr 70 (set "Lines=70")  
mode con cols=%cols% lines=%Lines%&color 1F&echo.
if "%anz%"=="1" (echo  Dieser %Medium%: "%inFile%1%inEXC%") ELSE echo  Dieser %Medium%: "%outFile%.%exc%"  
echo  soll umgewandelt werden. Die Streams haben diesen Inhalt:
echo  %lin6%%lin6:~0,9%&echo.
type "%tmp%\%stamp%MiD-Anzg.tmp"& echo  %lin6%%lin6%&echo.  
echo  Diese sollen durch "ffmpeg" wie folgt verarbeitet werden:  
echo  %lin6%%lin6:~0,9%&echo.
echo  inFile-Code: "%code%"  
if ""=="%outCode%" (echo  outFileCode: ---) ELSE echo  outFileCode: "%outCode%"  
ping -n 6 localhost 1>nul 2>nul&color 70
call :codeFrg
if "%mapEnc%"=="yes" call :mon3  
:enc1
if "%anz%"=="1" (set "inFile=%inFile%1" & set "exc=%inEXC:~1,4%"  
	) ELSE (
	if "%Test%"=="Test" (set "inFile=%inFile%1" & set "exc=%inEXC:~1,4%" &(  
		set "outFile=%outFile%_Test")		  
	) ELSE set "inFile=%outFile%")  
if "%Test%"=="Test" mode con cols=150 lines=70& call :InfoEnc  
:enc2
if "%mont1:~0,-2%"=="ja" (set "BatWindow=Umlabeln %BatWindow%") ELSE set "BatWindow=Encodieren %BatWindow%"  
if "%ffpg%"=="go" cls & title %BatWindow% von ffmpeg um %time:~0,5% gestartet ...&(  
color 0F& %ffmpeg% -i "%inFile%.%exc%"%subFile%%tcod%%code%"%outFile%.%oxc%"%outCode%)  
if "%Test%"=="Test" pause  
goto :eof

:Timer-Log
set "info=%Medium%-Montage "  
title Montage-Zeit berechnen& setlocal
if "%Test%"=="Test" (%mod2%) ELSE %mod1%  
if "%Test%"=="Test" set "dir4=1" & set "dir5=2"& goto :tim1  
if "%timLog%"=="" (set "timLog=%outFile%.%oxc%"&set "txc=%oxc%") ELSE set "timLog=%timLog%"&set "txc=%exc%"  
if exist "%timLog%" @(  
if "%Test%"=="Test" echo  inFile&%li29%&echo.  
For /F "tokens=3,4 Delims= " %%i in ('dir /tc "%timLog%"^|Find /i ".%txc%"') Do @(  
	set "dir1=%%i"&set "dir2=%%j"&set "dir3=!dir1:.=!"&set "dir3=!dir3:~0,-3!"  
	if "%Test%"=="Test" echo dir1: --!dir1!--&echo dir2: --!dir2!--&echo dir3: --!dir3!--  
	)
set /A dir5=!dir3!/10
if "%Test%"=="Test" echo  outFile&%li29%&echo.  
For /F "tokens=3,4 Delims= " %%i in ('dir /tw "%outFile%.%oxc%"^|Find /i ".%oxc%"') Do @(  
	set "dir1=%%i"&set "dir2=%%j"&set "dir4=!dir1:.=!"&set "dir4=!dir4:~0,-3!"  
	if "%Test%"=="Test" echo dir1: --!dir1!--&echo dir2: --!dir2!--&echo dir4: --!dir4!--&(  
	echo.& echo dir5= !dir5! lss !dir4! =dir4& pause)
	if "!dir4!"=="" set "dir4=1" & if "!dir5!"=="" set "dir5=2"  
	))
:tim1
if %dir5% lss %dir4% (set "info=%info%erfolgreich"  
	) ELSE (
	mode con cols=70 lines=20
	if "%Test%"=="Test" (set "info=%info%als Testlauf"  
	) ELSE set "info=%info%fehlerhaft"  
	call :InfoTim "tfo1%Test%" & set /P answer= j/n?   
	if /i "!answer!"=="j" endlocal &start %vlc% "%outFile%.%oxc%"&(  
	call :reCall "%input%" & goto :Timer-Log)  
	if /i "!answer!"=="n" goto :tim4  
	if "!answer!"=="" endlocal & goto :Timer-Log  
	)
set "info=%info% beendet."  
:tim2
FOR /f "tokens=1-5 delims=.: " %%i IN ('dir /tc "%timLog%"^|find /i ".%txc%"') DO @(  
	set /a "ATdd = 100%%i, ATdd %%= 100, ATmm = 100%%j, ATmm %%= 100, AT1h = 100%%l, AT1h %%= 100, AT1m = 100%%m, AT1m %%= 100"  
	set /A ATjj=%%k/4*4
	if not !ATjj! equ %%k set "ATSJ=no"  
	)
set /A ATGm=(%AT1h%*60)+%AT1m%
if "%Test%"=="Test" cls & echo. &@(  
	echo  ATdd: --%ATdd%--&echo ATmm: --%ATmm%--&echo ATSJ: --%ATSJ%--&echo AT1h: --%AT1h%--&echo AT1m: --%AT1m%--
	echo  ------------
	echo  ATGm: %ATGm% min)
FOR /f "tokens=1-5 delims=.: " %%i IN ('dir /tw "%outFile%.%oxc%"^|find /i ".%oxc%"') DO @(  
	set /a "BTdd = 100%%i, BTdd %%= 100, BTmm = 100%%j, BTmm %%= 100, BT1h = 100%%l, BT1h %%= 100, BT1m = 100%%m, BT1m %%= 100"  
	set /A BTjj=%%k/4*4
	if not !BTjj! equ %%k set "BTSJ=no"  
	)	
set /A BTGm=(%BT1h%*60)+%BT1m%
if "%Test%"=="Test" @(  
	echo  ==================
	echo  BTdd: --%BTdd%--&echo BTmm: --%BTmm%--&echo BTSJ: --%BTSJ%--&echo BT1h: --%BT1h%--&echo BT1m: --%BT1m%--
	echo  ------------
	echo  BTGm: %BTGm% min
	echo  ------------------
	)
if %ATmm% lss %BTmm% @(
	FOR %%i IN (4,6,9,11) DO @if %ATmm% equ %%i set A1dd=30
	FOR %%i IN (1,3,5,7,8,10,12) DO @if %ATmm% equ %%i set A1dd=31
	if %ATmm% equ 2 if "%ATSJ%"=="no" (set "A1dd=28") ELSE set "A1dd=29"  
	set /A DTdd=%BTdd%+!A1dd!-%ATdd%
	) ELSE (
	if %ATmm% gtr %BTmm% (set /A DTdd=%BTdd%+31-%ATdd%
	) ELSE set /A DTdd=%BTdd%-%ATdd%
	)
if "%DTdd%" equ "0" (set /A DTGm=%BTGm%-%ATGm%) ELSE set /A DTGm=(DTdd*24*60)+%BTGm%-%ATGm%  
cls &echo.&color 1F& echo  Gesamt-Dauer in min: %DTGm%
if "%Test%"=="Test" (echo  ==================& pause) ELSE ping -n 2 localhost 1>nul 2>nul  
if %DTGm% lss 60 goto :tim3
set /A STD=%DTGm%/60
set /A MIN=%DTGm%-(%STD%*60)
:tim3
if not "%std%"=="0" if "%min%" lss "10" set "MIN=0%min%"  
if %DTGm% lss 60 (if %DTGm% equ 0 (set "Dauer=keine Minute"  
							) ELSE set "Dauer=%DTGm% min"  
							) ELSE set "Dauer=%std%:%min% h"  
set "Dauer=Die Umwandlung hat %Dauer% gedauert."  
if "%Test%"=="Test" echo.&echo  %Dauer%& ping -n 3 localhost 1>nul 2>nul  
:tim4
call :InfoTim "tfo2"  
if exist "%tmp%\%stamp%MiD-*.*" del /q "%tmp%\%stamp%MiD*.*"  
cls &echo.& echo  Habe fertig.& endlocal
ping -n 6 localhost 1>nul 2>nul
goto :eof

::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::------------------------------- Funktionen ----------------------

:codeFrg
setlocal
set "codeNew=%code%"&set "codeOK=yes"  
if not "%StringOld%"=="" echo  old-String : "%StringOld%"  
:cfr1
echo.& echo  Codec-Parameter ok?&set answer=&set /P answer= j/n?  
if /i "%answer%"=="j" goto :cfr2  
if /i "%answer%"=="n" set "codeOK=no"&cls&echo.&echo  inFile-Code: %codeNew%&(  
echo  %lin6%%lin6:~0,-12%&echo.&color 70
echo  Bitte Code neu eingeben (kopieren / einfgen ist per Rechtsklick m”glich^)&set /P codeNew= 
) & cls & echo.&echo  Ist nach und vor den Anfhrungszeichen ein leeres Zeichen vorhanden?
echo.&if not "%StringOld%"=="" echo  old-String : "%StringOld%"&(  
echo  inFile-Code: " %codeNew% "&echo  %lin6%%lin6:~0,-12%&goto :cfr1)  
:cfr2
if "%codeOK%"=="yes" endlocal & if not "%StringOld%"=="" (set "code=%StringOld%"& goto :eof  
	) ELSE goto :eof 
endlocal &  set "code= %codeNew% "  
goto :eof

:InfoCut
set "oar1=%oar:~0,1%"& set "oar2=%oar:~2,2%"  
set /A OAR=(%oar1%*100)+%oar2%
set /A CroH=(((%vi5H%*10000)/(%OAR%*((%DH%*100)/%DB%)))/16+1)*16
set /A Crop=(%vi5H%-%CroH%)/2
set /A PadB=(((%vi5B%*10000)/(%OAR%*((%DH%*100)/%DB%)))/9+1)*16
set /A Padd=(%vi5B%-%PadB%)/2
if %Crop% lss 0 set "Crop=%Crop:~1,4%"& set "croN=yes"  
if %Padd% lss 0 set "Padd=%Padd:~1,4%"& set "padN=yes"  
if "%Test%"=="Test" ping -n 6 localhost 1>nul 2>nul  
cls&echo.&echo    %Medium%-Input: !vi5! Pixel&%li29%%li29:~5,6%
if "%croN%"=="yes" (echo   %Medium%-Output: %PadB%x%vi5H% Pixel&(  
					echo   %Medium%-Balken:   2x %Padd% (links u. rechts^))
			 ) ELSE echo   %Medium%-Output: %vi5B%x%CroH% Pixel&(
					echo  %Medium%-Schnitt:   2x %Crop% (oben u. unten^))
set "Crop=-s %vi5B%x%CroH% -vf crop=%vi5B%:%CroH%:0:%Crop% %aspt%"  
set "Padd=-s %PadB%x%vi5H% -vf pad=%PadB%:%vi5H%:%Padd%:0 %aspt%"  
::set "outCode= -s %vi5% -aspect 16:9"  
goto :eof

:InfoEnc
cls & echo.& color F0
echo  Der Encoder startet jetzt mit diesen Einstellungen:
%li29%%li29:~5,15%%li29:~5,15%&echo.
echo  "ffmpeg" -i "%inFile%.%exc%"%subFile%%tcod%%code%"%outFile%.%oxc%"%outCode%  
echo. 
if "%~1"=="rec" (goto :eof) ELSE pause  
goto :eof

:InfoTim
echo.& set answer=& color F0
echo  %info%&%li29%%li29:~5,20%& echo.
if "%~1"=="" (goto :eof) ELSE goto :%~1  
:tfo1
echo  Vielleicht konnte "ffmpeg" die Untertitel nicht verarbeiten.  
echo  Vorschlag: Am besten die Untertitel vorher extrahieren.& echo.
echo  Erst Untertitel demuxen und dann %Medium% encodieren?& echo.
goto :eof
:tfo1Test
echo  %outFile% mit %Medium%-Player
echo   abspielen und "ffmpeg" neu starten?& echo.  
goto :eof
:tfo2
set "li58=%li29%%li29:~5,29%"  
set "li116=%li58%%li58:~5,58%"  
echo %monTitel:~23,-1%">"%outFile%_%oxc%.txt"  
echo %info%>>"%outFile%_%oxc%.txt"  
if not "%Hinweis%"=="" echo %Hinweis% >>"%outFile%_%oxc%.txt"  
%li116%%li29:~5,29%>>"%outFile%_%oxc%.txt"  
echo inFile-Code: "%code%">>"%outFile%_%oxc%.txt"  
if "%DTGm%" equ "0" (set "linX=%li116:~0,-55%") ELSE set "linX=%li58:~0,-5%"  
if "%outCode%"=="" (set "outFileCode=outFileCode: ---") ELSE set "outFileCode=outFileCode: "%outCode%""  
echo %outFileCode%>>"%outFile%_%oxc%.txt"  
%linX%>>"%outFile%_%oxc%.txt"  
echo %Dauer%>>"%outFile%_%oxc%.txt"  
%linX%>>"%outFile%_%oxc%.txt"  
%li116%%li29:~5,29%>>"%outFile%_%oxc%.txt"  
type "%tmp%\%stamp%MiD-Anzg.tmp">>"%outFile%_%oxc%.txt"  
%li116%%li29:~5,6%>>"%outFile%_%oxc%.txt"  
type "%MiD-Info%">>"%outFile%_%oxc%.txt"  
%li116%%li29:~5,6%>>"%outFile%_%oxc%.txt"  
%ffmpeg% -i "%outFile%.%oxc%" 2> "%MiD-Info%"   
%li116%%li29:~5,6%>>"%outFile%_%oxc%.txt"  
type "%MiD-Info%">>"%outFile%_%oxc%.txt"  
goto :eof
	
:LenSet
setlocal EnableDelayedExpansion
set "WorstCaseLen=200"  
set "DerTestString=%~1"  
For /L %%i in (%WorstCaseLen%,-1,1) do (if not defined myStrLen if "!DerTestString:~%%i,1!" NEQ "" Set /a myStrLen=1+%%i)  
endlocal & set LenSet=%myStrLen%
goto :eof

:mapFrg
if "!mapFrg!"=="exit" (goto :eof) ELSE set mpFrg=  
if !mapNr! equ 1 set "map2map=!map!" & set "nr2nr=!mapNr!"& goto :mfr1  
call :LenSet "%mapChek%-Map: %map%"  
set /A cols=10+%LenSet%
if %cols% lss 55 set "cols=55"  
call :LenSet %map%
set /A Lines=20+%mapNr%
mode con cols=%cols% lines=%Lines%&echo.
type "%tmp%\%stamp%MiD-map.tmp"&echo.   
echo.& echo  !mapChek!-Map: "!map!" &echo.&echo  Mapping-Reihenfolge ok?  
set /P mpFrg= j/n? 
if /i "!mpFrg!"=="j" set "map2map=!map!" & set "nr2nr=!mapNr!"& goto :mfr1  
if /i "!mpFrg!"=="n" call :newMap & echo.& goto :mapFrg  
if "!mpFrg!"=="" cls&echo.&echo  Bitte Frage beantworten.& goto :mapfrg  
cls&echo.&echo  Bitte richtig antworten.& goto :mapfrg
:mfr1
cls & echo. & set !mapNr!=0
FOR %%i IN (Audio,Video) DO @if "%mapChek%"=="%%i" set "mapNsub=!map!"  
del "%tmp%\%stamp%MiD-map.tmp"  
goto :eof

:newMap
call :LenSet "%mapChek%-Map: %map%"  
set /A cols=10+%LenSet%
if %cols% lss 55 set "cols=55"  
call :LenSet %map%
set /A Lines=20+%mapNr%
if "%lines%"=="" set "lines=24"  
mode con cols=%cols% lines=%Lines%
set "mapChek=new-total" & echo.  
echo  Komma oder Leerzeichen zwischen den Zahlen setzen
echo  Falls kein Stream ausgew„hlt werden soll:
echo  Ein Leerzeichen eingeben.&echo.
echo  %mapChek%-Map: "%map%"&echo.  
type "%tmp%\%stamp%MiD-map.tmp"&echo.   
set /P Mapping= Žndere die Reihenfolge:  
set "map=%map2map%"  
FOR %%i IN (%Mapping%) DO @(
	call :Zahl "%%i"  
	set "map=!map!!neuMap!"  
	)
goto :eof

:noinPut
echo  Name der 1. Input-Datei?& set /P inFile= &echo.
if "%inFile:~-4,1%"=="." set "inEXC=%inFile:~-4,4%"&(  
set "inFile=%inFile:~0,-4%"& goto :noi1)  
echo  Welche Input-Endung?& set /P inEXC= &echo.
if not "%inEXC:~0,1%"=="." set "inEXC=.%inEXC%"  
:noi1
if exist "%inFile%%inEXC%" (set "input=%~dp0%inFile%%inEXC%"  
	) ELSE cls &echo.&echo  Die Eingabe war nicht korrekt.& goto :noinPut
set "BatWindow=von "%inFile%%inEXC%""  
goto :eof

:OAR-Wert
set "OAR-Wert="1,33","1,67","1,78","1,85","1,97","2,00","2,20","2,33","2,39","2,40","2,78""  
if "%~1"=="orw1" goto :eof  
:orw2
cls & echo.
echo  OAR: %oar% ist ein falscher Wert&echo.
echo  M”gliche Werte sind:
echo  --------------------
echo  OAR: 1,33 - 35-mm-%Medium%, TV-4:3
echo  OAR: 1,67 - europ„ische Widescreen (5:3)
echo  OAR: 1,78 - TV-16:9 (HDTV)
echo  OAR: 1,85 - Kino-Breitbildformat
echo  OAR: 1,97 - VistaVision (Paramont)
echo  OAR: 2,33 - CinemaScope (7:3)
echo  OAR: 2,39 - SMPTE-genormte GrӇe (auch 2,40)
echo  OAR: 2,78 - Ultra-Panavision
echo. & pause &cls&echo.
goto :eof

:pprob
setlocal enabledelayedexpansion
FOR %%a IN (%prgs%) DO @(
	call :ppr1 "%%a"  
	if not exist "!pprob!" cls & echo.&(  
	mode con cols=55 lines=8&color FC
	echo  Das Programm "%%a" ist nicht vorhanden,  
	echo  oder der Pfad ist falsch deklariert.&echo.
	echo  Bitte jetzt die start-set.bat korrigieren
	echo  und abspeichern. Der Skript startet dann neu.
	For /F "tokens=1,2 Delims=." %%i in ('dir /b "%~dp0start-set.*"^|Find /i "start-set"') Do @Set "pprst=%%i.%%j"  
	ping -n 5 localhost 1>nul 2>nul
	notepad "%~dp0!pprst!"& cls &echo.& echo  Suche "%%a"  
	ping -n 2 localhost 1>nul 2>nul& goto :reStart
	))
endlocal
goto :eof
:ppr1
set "pprob=!%~1!.exe"  
:ppr2
if  "%pprob:~-4,1%"=="." if  "%pprob:~-4,1%"=="%pprob:~-8,1%" set "pprob=%pprob:~0,-4%" & goto :ppr2  
goto :eof

:reCall
mode con cols=%cols% lines=%Lines%&color 70& echo.
set "Media=%~n1"& title reCall gestartet ...& setlocal  
echo  Neustart mit: "%Media%"& echo.& ping -n 3 localhost 1>nul 2>nul  
set "Media-org=%Media:~0,-1%1%~x1"&set "inFile=%Media:~0,-1%"&set "StringOld=%code%"  
if "%~1"=="Test" call :con1 "%Test%en"  
:rec1
set answer=& echo.
echo  Untertitel separat extrahieren?& set /P answer= j/n? 
if /i "%answer%"=="j" goto :rec2  
if /i "%answer%"=="n" goto :rec3  
if "%answer%"=="" cls &echo.& echo  Frage bitte beantworten& goto :rec1  
set answer=& goto :reCall
:rec2
cls & echo.&echo  Gleich startet der "VobSub Ripper Wizard".&echo.  
echo  Dort die Datei "%inFile%0.ifo" ”ffnen und als "%outFile%.idx" speichern.&echo.  
ping -n 4 localhost 1>nul 2>nul
echo  Danach auf next klicken: Die gewnschte(n^) Sprache(n^) ausw„hlen.
echo  Aufpassen: Die tauchen manchmal ”fter auf - alle Teile markieren.&echo. 
ping -n 4 localhost 1>nul 2>nul
echo  Erneut auf next klicken: Die K„sten 'beep' und 'close Dialog' anklicken.  
echo  Und dann das Ergebnis abwarten ...&color 1F& ping -n 4 localhost 1>nul 2>nul
%vsrip% & cls & echo.&color 70&echo  Fertig, es geht gleich weiter ...
ping -n 3 localhost 1>nul 2>nul& cls
:rec3
set answer=& echo.
echo  Vorbereitung von "ffmpeg" zum Neustart.&echo.  
echo  nochmal ein Testlauf?& set /P answer= j/n? 
if /i "%answer%"=="j" goto :rec4  
if /i "%answer%"=="n" set "tcod="& set "Test="&(  
	set "outFile=%outFile:~0,-5%"& goto :rec4  )  
if "%answer%"=="" cls &echo.&echo  Frage bitte beantworten  
goto :rec3
:rec4
set "answer="& echo.  
call :LenSet "-c:s %su8%%map2map%"  
set /A LenSet=%LenSet%+1
set "code=!code:~0,-%LenSet%!%mapNsub%"  
call :codeFrg
call :InfoEnc rec & set answer=& echo.
echo  Encoding starten? & set /P answer= j/n?  
if /i "%answer%"=="j" goto :rec5  
if /i "%answer%"=="n" goto :rec4  
if "%answer%"=="" cls &echo.&echo  Frage bitte beantworten  
goto :rec4
:rec5
call :mon3
call :enc2
cls & set "answer="& echo.  
set "Hinweis=Hinweis: mkv-Merge durchführen."  
endlocal
goto :eof

:startSet
> "%~dp0start-set.bat" echo.if "%%~1"=="progs" goto :%%~1  
>>"%~dp0start-set.bat" echo.:start  
>>"%~dp0start-set.bat" echo.  
>>"%~dp0start-set.bat" echo.:progs  
>>"%~dp0start-set.bat" echo.REM Diesen Bereich anpassen und abspeichern.  
>>"%~dp0start-set.bat" echo.set "ffmpeg=C:\Programme\ffmpeg\bin\ffmpeg"  
>>"%~dp0start-set.bat" echo.  
>>"%~dp0start-set.bat" echo.if "%%~2"=="" (goto :eof) ELSE (goto :%%~2)  
>>"%~dp0start-set.bat" echo.  
>>"%~dp0start-set.bat" echo.:stamp  
>>"%~dp0start-set.bat" echo.set "stamp=%%date:~-4%%%%date:~3,2%%%%date:~0,2%%_%%time::=%%"  
>>"%~dp0start-set.bat" echo.set "stamp=%%stamp:~0,-3%%"  
>>"%~dp0start-set.bat" echo.goto :eof  
>>"%~dp0start-set.bat" echo.  
>>"%~dp0start-set.bat" echo.:ende  
ping -n 2 localhost 1>NUL 2>NUL
notepad "%~dp0start-set.bat"  
goto :eof

:Zahl
echo "map%~1">"%tmp%\%stamp%MiDnewSET.tmp"  
set /p neuMap=<"%tmp%\%stamp%MiDnewSET.tmp"  
set "neuMap=!%neuMap:~1,-1%!"&del "%tmp%\%stamp%MiDnewSET.tmp"  
goto :eof

:----------- Testfeld -------------
:VariTest
::Befehl: call :VariTest "%~1" "%~2"  
cls & echo.
echo      sub: %subti%
echo   topBot: %topBot%
echo     li29: %li29%
echo   Ziffer: %Ziffer%
echo     code: %code%
echo    Pixel: %vi5%
echo   vari-1: "%~1"  
echo   vari-2: "%~2"  
echo  OutFile: %outFile%
echo      M2M: %map2map%
echo     lin6: %lin6%
pause
goto :eof


back-to-topWie verwenden?

Am Einfachsten alle Skripte diesen, "MediaDat" und Eure Start-set.bat (oder *.cmd) in einen Ordner Eurer Wahl, dazu die Media-Dateien.
Keine Angst, diese bleiben völlig ungeschoren. Na, und "Film-Montage per Doppelklick starten.
Besser noch, eine Verküpfung zu "Film-Montage" im "sendTo-Ordner" anlegen, denn dann steht das Tool
jederzeit zur Verfügung. Die Dateien müssen sich auf der Festplatte befinden.
Ein Start direkt von der DVD z.B. ist noch nicht vorgesehen. Vielleicht kommt das ja ein Mal.


back-to-topStart-set.bat mit Zeitstempel

Die erwähnten Programm-Pfade samt Dateinamen bitte unterhalb von :progs unterbringen.
ein Beispiel: set "ffmpeg=C:\Pfad zum Progs\ffmpeg.exe" (es geht auch ohne .exe face-wink)
Die Start-set.bat ist seit Version 1.1 Bestandteil des Skriptes (Zeilen 606 - 623)

Wer positive copy /b oder sonstige Ergebnisse findet, bitte posten. Ebenso Anregungen und Kritik.

Dank diesem Forum konnte ich die "Film-Montage" kreieren. Jedoch einen besonderen Dank an @Friemler für seine Hilfe bei der startSet-Routine
und an @rubberman für seine Idee zur führenden Null-Beseitigung. Die könnt Ihr auch dazu nutzen.

Danke für Euer Interesse.

max5moritz

Content-Key: 197715

Url: https://administrator.de/contentid/197715

Printed on: April 19, 2024 at 10:04 o'clock