Jetzt wollte ich es auch ... einen Ordner überwachen. Und sobald sich ein Video-File darin verirrt: Gehirnwäsche .. komplett umwandeln das Ding. Und, damit ich auch den englischsprachigen Ordnerüberwachern einen Dienst tue:

ffmpeg (handbrake) watch-folder video-transcoding (Windows) ...


First, this adventure is in need of a watched folder. A quick and dirty search brought up "Directory Monitor" which is offered free, but (hopefully) safe by some guy who calls his website "DevEnterprise.NET" (guess which framework it uses ..).

Next, this author, not this, but the one here (hello!) made use of HandBrakeCLI - a software that, in my impression, cuts off everything of ffmpeg but x264-encoding - and at least it works on windows ..

The interested reader would find out by himself, but i put the two needed HandBrakeCLI files into a folder c:\handbrake\*

Now you do have to - yes you can - create a folder c:\videos\

From now on it gets obvious i was to lazy to translate my script into english ..

Now my poem, wandeln.cmd (which means something like "change" - yes you can), goes into c:\handbrake\* as well. It contains the following lyrics:

------------------------------
@echo off

if /i %1==c:\videos\thumbs.db goto ende

if not exist "c:\videos\gewandelt" (
echo Erstelle Verzeichnis "gewandelt"...
mkdir c:\videos\gewandelt
)

echo Kopiere %~nx1

:nochmal
if not exist %1 goto ende
move %1 "c:\videos\ready-%~nx1" 1>nul 2>nul
if errorlevel 1 goto weiter

goto wandeln

:weiter

ping /n 6 localhost >nul
goto nochmal

:wandeln

echo Wandle Datei ready-%~nx1

"c:\handbrake\HandBrakeCLI.exe" -i "c:\videos\ready-%~nx1" -o "c:\videos\gewandelt\busy-%~n1.mp4" -4 -b 2500 -B 320

if exist "c:\videos\gewandelt\gewandelt-%~n1.mp4" goto vorhanden

move "c:\videos\gewandelt\busy-%~n1.mp4" "c:\videos\gewandelt\gewandelt-%~n1.mp4"

goto nichtvorhanden

:vorhanden

set /a zuz=%random% %%9000+999

move "c:\videos\gewandelt\busy-%~n1.mp4" "c:\videos\gewandelt\gewandelt-%zuz%-%~n1.mp4"

:nichtvorhanden

if errorlevel 1 goto ende

del /F "c:\videos\ready-%~nx1"

:ende

exit

------------------------------


Point the Directory Monitor Software to watch the folder c:\videos (without subfolders and only on new files) and run the wandeln.cmd if something gets trapped.

Now, if I didn't forget anything, you can throw some video into the videofolder and after conversion you'll find a converted video in subfolder "gewandelt". The original video will be deleted afterwards, so consider working with copies ..

Thank you very much - you've been a beautiful audience.

ping /n 6 localhost >nul
if not exist %1 goto ende
if %1="c:\videos\thumbs.db" goto ende
goto nochmal