VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy a VSO converter software :)
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 33
Thread
  1. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Not been around for a while.

    Still doing the batch file thing.
    Check your paths, people....

    Code:
    @echo off
    :: 2 pass for most videos to AVI with MP3 audio @ 128kbps.
    
    if not exist AVI\*.* md AVI
    set /p rate=Enter bitrate(k)?
    Title Bitrate=%rate%
    set /p sample=Sample clip only?(y/n)
    if /i %sample%==y goto sample
    
    for %%a in ("*.mp4")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mp4")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mts")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mts")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.avi")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.avi")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mkv")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mkv")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mpg")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mpg")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.vob")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.vob")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.webm") do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.webm") do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    goto end
    
    :sample
    for %%a in ("*.mp4")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:07:00 -to 00:07:30 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mp4")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:07:00 -to 00:07:30 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mts")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mts")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.avi")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.avi")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mkv")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mkv")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mpg")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mpg")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.vob")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.vob")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.webm") do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.webm") do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -ss 00:06:00 -to 00:06:20 -f avi -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    
    :end

    Code:
    :: To unpack bframes. The slightly annoying, but truthful message, spat out by ffmpeg.
    :: Only .AVI as input.
    
    @echo off
    if not exist avi\*.* md avi
    for %%a in ("*.avi") do "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -codec copy -bsf:v mpeg4_unpack_bframes -y "avi\%%~na.avi"
    goto end
    
    :end


    Code:
    :: MediaInfo - batch file mode. Works on .AVI videos.
    :: 3 examples.
    :: Uncomment the wanted ..... (means remove the double colons....)
    :: Change the output path to your fancied destination. Mine's e:\a\
    
    echo off
    if exist ~largemovies.txt del /q ~largemovies.txt
    for %%a in (*.avi) do set avi=%%a&& call :MI
    goto end
    
    :MI
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=General;%%OverallBitRate%%" "%avi%" >> ~tmpfile.txt
    ::set /p OverallBitRate= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %OverallBitRate% gtr 1600000 echo "%avi%" >> ~largemovies.txt && echo %OverallBitRate% >> ~largemovies.txt
    ::if %OverallBitRate% gtr 1600000 copy "%avi%" e:\a\
    
    
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=Video;%%BitRate%%" "%avi%" >> ~tmpfile.txt
    ::set /p BitRate= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %BitRate% gtr 1600000 echo "%avi%" >> ~largemovies.txt && echo %BitRate% >> ~largemovies.txt
    ::if %bitrate% gtr 1600000 copy "%avi%" e:\a\
    
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=Audio;%%Channel(s)%%" "%avi%" >> ~tmpfile.txt
    ::set /p Channel(s)= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %Channel(s)% neq 2 echo "%avi%" >> ~largemovies.txt && echo %Channel(s)% >> ~largemovies.txt
    ::if %Channel(s)% neq 2 copy "%avi%" e:\a\
    
    goto :eof
    
    :end
    ~largemovies.txt


    Code:
    @echo off
    :: Works on .AVI files.
    :: VirtualDub to add the video clip name, as a subtitle, at the start for 5 seconds. (My mate's line dancing tutorials.)
    :: textsub.vdf (I'm using TextSub 2.23) filter must be in the \virtualdub\plugins folder.
    :: Xvid must be installed.
    
    :: Do we have any AVI clips?
    if not exist *.avi goto ErrMsg01
    
    :: If yes, make the output folder.
    if not exist AVI\*.* md AVI
    
    :: Create the .srt (subtitle) file for each AVI.
    for %%a in ("*.avi") do echo 1 > "%%~na.srt"
    for %%a in ("*.avi") do echo 00:00:00,000 --^> 00:00:05,000 >> "%%~na.srt"
    for %%a in ("*.avi") do echo %%~na >> "%%~na.srt"
    for %%a in ("*.avi") do echo. >> "%%~na.srt"
    
    ::Create the .style (font & colour) file for each AVI.
    for %%a in ("*.avi") do echo [V4 Styles] > "%%~na.srt.style"
    for %%a in ("*.avi") do echo Format:	Name,	Fontname,	Fontsize,	PrimaryColour,	SecondaryColour,	TertiaryColour,	BackColour,	Bold,	Italic,	BorderStyle,	Outline,	Shadow,	Alignment,	MarginL,	MarginR,	MarginV,	AlphaLevel	Encoding >> "%%~na.srt.style"
    for %%a in ("*.avi") do echo Style: Default,	Arial,		36,		^&H00FFFFFF,	^&H000000FF,		^&H00000000,	^&H00000000,	0,	0,	1,		2,		2,	2,		10,		10,		10,		0,		1 >> "%%~na.srt.style"
    
    :: Create .jobs script for each AVI video
    for %%a in ("*.avi") do echo // $signature 0 1   > "%%~na.jobs"
    for %%a in ("*.avi") do echo // $numjobs 1  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $job "Job 1"  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $input "%%a"  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $output "AVI\%%~na.avi"  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $state 0  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $id e38e29ba033ff831  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $start_time 00000000 00000000  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $end_time 00000000 00000000  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $script  >> "%%~na.jobs"
    
    for %%a in ("*.avi") do echo declare Frames;  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.Open("%%a","",0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo Frames = VirtualDub.video.length;  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetSource(1);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetMode(0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetInterleave(1,500,1,0,0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetClipMode(1,1);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetEditMode(1);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetConversion(0,0,0,0,0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetVolume();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetCompression();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.EnableFilterGraph(0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetInputFormat(0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetOutputFormat(7);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetMode(3);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetSmartRendering(0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetPreserveEmptyFrames(0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetFrameRate2(0,0,1);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetIVTC(0, 0, 0, 0);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetCompression(0x64697678,0,10000,0);  >> "%%~na.jobs"
    
    :: 1 pass XviD compression @ 2500 kbps
    for %%a in ("*.avi") do echo VirtualDub.video.SetCompData(3540,"AAAAAMQJAACQsggALlx2aWRlby5wYXNzAAAuAHAAYQBzAHMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAkAEAAE1QRUc0IEFkdmFuY2VkIFNpbXBsZSBAIEw1AAAgAFMAaQBtAHAAbABlACAAQAAgAEwANQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAChVc2VyIGRlZmluZWQpAABmAGkAbgBlAGQAKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAIERITFRcZGxESExUXGRscFBUWFxgaHB4VFhcYGhweIBYXGBocHiAjFxgaHB4gIyYZGhweICMmKRscHiAjJiktEBESExQVFhcREhMUFRYXGBITFBUWFxgZExQVFhcYGhsUFRYXGRobHBUWFxgaGxweFhcYGhscHh8XGBkbHB4fIQEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAIAAACWAAAAZAAAAAEAAAAAAAAABAAAAAMAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAZAAAAPQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAABkAAAAZAAAAAEAAAAKAAAAAQAAABQAAAAAAAAAAAAAAAUAAAAFAAAABQAAAAAoCgAAAAAAAQAAAAEAAAAeAAAAAAAAAAIAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAYAAAAEAAAAAAAAAAEAAAABAAAAAQAAAJYAAAAAAAAAAQAAABQAAAABAAAAFAAAAAEAAAAUAAAAAQAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM8DAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA");  >> "%%~na.jobs"
    
    for %%a in ("*.avi") do echo VirtualDub.video.filters.Clear();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.filters.Add("TextSub 2.23");  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.filters.instance[0].Config("%%~na.srt", 1, "25.00000");  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.filters.Clear();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.subset.Clear();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.subset.AddRange(0,Frames);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.video.SetRange();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.project.ClearTextInfo();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo   // -- $reloadstop --  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.SaveAVI("AVI\\%%~na.avi");  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.audio.SetSource(1);  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo VirtualDub.Close();  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $endjob  >> "%%~na.jobs"
    for %%a in ("*.avi") do echo // $done  >> "%%~na.jobs"
    
    :: Virtualdub to create the AVI with the video clip name as a 5 second subtitle
    for %%a in ("*.jobs") do "c:\vidaud\virtualdub32\virtualdub.exe" /s "%%a" /r /x
    
    :: Clean up
    for %%a in ("*.avi") do del "%%~na.srt" "%%~na.jobs" "%%~na.srt.style"
    
    echo. && echo All done! New clips, with titles, are in the AVI folder
    echo Press any key to exit. &pause > nul
    goto end
    
    :ErrMsg01
    cls
    echo  &echo. &echo  &echo. &echo 
    echo COULD NOT FIND ANY AVI CLIPS!!!
    echo Press any key to exit. &pause > nul
    goto end
    
    :end




    Hope these are of use, to someone.
    I'll be back in a week.

    :p
    Last edited by pcspeak; 11th Dec 2016 at 01:01. Reason: Tidied up the batch files. (Mostly the commented lines.)
    Quote Quote  
  2. Thanks for this and very brilliant indeed.
    Quote Quote  
  3. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    I've changed the MI batch file to allow for more videos.
    Not just AVI. Also added another example.

    Code:
    echo off
    if exist ~largemovies.txt del /q ~largemovies.txt
    for %%a in (*.avi)  do set video=%%a&& call :MI
    for %%a in (*.mp4)  do set video=%%a&& call :MI
    for %%a in (*.flv)  do set video=%%a&& call :MI
    for %%a in (*.mkv)  do set video=%%a&& call :MI
    for %%a in (*.webm) do set video=%%a&& call :MI
    for %%a in (*.mpg)  do set video=%%a&& call :MI
    for %%a in (*.vob)  do set video=%%a&& call :MI
    for %%a in (*.m2v)  do set video=%%a&& call :MI
    goto end
    
    :MI
    :: Get the overall bitrate (Video & Audio) of the clip.
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=General;%%OverallBitRate%%" "%video%" >> ~tmpfile.txt
    ::set /p OverallBitRate= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %OverallBitRate% gtr 1600000 echo "%video%" >> ~largemovies.txt && echo %OverallBitRate% >> ~largemovies.txt
    ::if %OverallBitRate% gtr 1600000 copy "%video%" e:\a\
    
    :: Get the bitrate of just the video.
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=Video;%%BitRate%%" "%video%" >> ~tmpfile.txt
    ::set /p BitRate= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %BitRate% gtr 1600000 echo "%video%" >> ~largemovies.txt && echo %BitRate% >> ~largemovies.txt
    ::if %bitrate% gtr 1600000 copy "%video%" e:\a\
    
    :: Find the number of audio channels.
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=Audio;%%Channel(s)%%" "%video%" >> ~tmpfile.txt
    ::set /p Channel(s)= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if %Channel(s)% neq 2 echo "%video%" >> ~largemovies.txt && echo %Channel(s)% >> ~largemovies.txt
    ::if %Channel(s)% neq 2 copy "%video%" e:\a\
    
    :: Find the audio format. "MPEG Audio" = MP3. (and may be others??)
    ::"C:\VidAud\MediaInfoCLI\mediainfo.exe" "--Inform=Audio;%%Format%%" "%video%" >> ~tmpfile.txt
    ::set /p Format= < ~tmpfile.txt
    ::del ~tmpfile.txt
    ::if "%Format%" neq "MPEG Audio" echo "%video%" >> ~largemovies.txt && echo %Format% >> ~largemovies.txt
    ::if "%Format%" neq "MPEG Audio" copy "%video%" e:\a\
    
    goto :eof
    
    :end
    ~largemovies.txt
    By now members have probably realized that I want my final video clips to be:
    XviD encoded AVI/MP3
    I'm sort of stuck in a Rock 'n' Roll/Line Dancing fix.
    The above format plays on, pretty much, all dvd players.
    That's how my mate's students want it.

    Cheers.
    Last edited by pcspeak; 4th May 2016 at 00:44.
    Quote Quote  
  4. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Now getting videos taken with mobile phones, video cameras,
    tablets and whatever else is out there.
    The definition is pretty good, if somewhat shaky on occassion.
    Usualy taken with no idea of which way is up.

    Code:
    @echo off
    :: 1 pass most videos to AVI and MP3 in separate folders.
    :: Rotate the video and demux to sub folders.
    if not exist AVI\*.* md AVI
    if not exist MP3\*.* md MP3
    
    echo To rotate - select a number on your keyboard and then press Enter.
    echo 	0 - No Rotation
    echo 	1 - Clockwise 90 degrees
    echo 	2 - Anticlockwise 90 degrees
    echo 	3 - 180 Degrees
    set /p r1=0, 1, 2, 3. ?
    if /i %r1%==1 set r2=-vf transpose=1
    if /i %r1%==2 set r2=-vf transpose=2
    if /i %r1%==3 set r2=-vf transpose=1,transpose=1
    
    for %%a in (*.mp4) do if not exist "avi\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vtag XVID %r2% -c:v mpeg4 -b:v 1500k -an -threads 0 -y "avi\%%~na.avi"
    for %%a in (*.avi) do if not exist "avi\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vtag XVID %r2% -c:v mpeg4 -b:v 1500k -an -threads 0 -y "avi\%%~na.avi"
    for %%a in (*.mov) do if not exist "avi\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi -vtag XVID %r2% -c:v mpeg4 -b:v 1500k -an -threads 0 -y "avi\%%~na.avi"
    
    for %%a in (*.avi) do if not exist "mp3\%%~na.mp3" "c:\vidaud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -vn -c:a libmp3lame -ac 2 -b:a 192k -ar 44100 "MP3\%%~na.mp3"
    for %%a in (*.mov) do if not exist "mp3\%%~na.mp3" "c:\vidaud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -vn -c:a libmp3lame -ac 2 -b:a 192k -ar 44100 "MP3\%%~na.mp3"
    for %%a in (*.mp4) do if not exist "mp3\%%~na.mp3" "c:\vidaud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -vn -c:a libmp3lame -ac 2 -b:a 192k -ar 44100 "MP3\%%~na.mp3"
    First step is to clean up the audio as best as possible. Audacity.
    Second step is to resize and clean up the video to make DVD compliant.


    Code:
    @echo off
    :: Mux a new MP3 created by Audacity.
    :: Look for AVI & MP3 files with matching names.
    :: If found, mux the video with the new MP3, discarding the old audio.
    
    if not exist avi\*.* md avi
    
    for %%a in ("*.mp3") do if exist "%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%~na.avi" -i "%%a" -map 0:v -map 1:a -c:v copy -c:a copy -y "avi\%%~na.avi"
    goto end
    
    :end
    Last edited by pcspeak; 17th Apr 2016 at 14:18.
    Quote Quote  
  5. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Had a look at the first batch file I posted.
    There's a lot of repetition.
    I've now set the filters and sample length as 'Environment Variables'.
    I only need to change filters and/or samplelength in one place.

    Code:
    @echo off
    :: 2 pass most videos to AVI with MP3 audio.
    
    if not exist AVI\*.* md AVI
    set /p rate=Enter bitrate(k)?
    
    :: Change filters and sample length here!
    set filters=-vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2
    set samplelength=-ss 00:06:00 -to 00:06:30
    set /p sample=Sample clip only?(y/n)
    if /i %sample%==y goto sample
    
    for %%a in ("*.mp4")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mp4")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mts")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mts")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.avi")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.avi")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mkv")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mkv")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.mpg")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mpg")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.vob")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.vob")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.webm") do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.webm") do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    for %%a in ("*.m2v")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"    "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.m2v")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi"  "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -i "%%~na.ac3" -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na.avi"
    goto end
    
    :sample
    for %%a in ("*.mp4")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mp4")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mts")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mts")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.avi")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.avi")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mkv")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mkv")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.mpg")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.mpg")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.vob")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.vob")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.webm") do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.webm") do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    for %%a in ("*.m2v")  do Title P1-%rate%k-%%a && if not exist "%%~na-0.log"   "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~na" -vtag XVID -an -threads 0 -y NUL
    for %%a in ("*.m2v")  do Title P2-%rate%k-%%a && if not exist "AVI\%%~na.avi" "C:\VidAud\ffmpeg32\bin\ffmpeg.exe" -i "%%a" -i "%%~na.ac3" %samplelength% -f avi yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2 -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~na" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~na-%rate%.avi"
    
    :end
    Note:
    I have 3 internal drives. Drive C: is a SSD.
    I've modified my batch file to output to two destinations.
    c:\vid1\ --> d:\vid1\ (vid1-D.cmd)
    c:\vid2\ --> e:\vid2\ (vid2-E.cmd)

    I split the videos between the input folders and run both batch files at the same time.
    This gives approx. 33% reduction in total processing time.
    Still allows me to do other things.

    This is not really the way to go with no SSD.
    There will be a lot of drive thrashing and drive life will be reduced.

    Cheers.
    Last edited by pcspeak; 19th Apr 2016 at 22:13.
    Quote Quote  
  6. how about
    Code:
    @echo off
    setlocal
    :: 2 pass most videos to AVI with MP3 audio.
    
    set "ffmpeg=C:\VidAud\ffmpeg32\bin\ffmpeg.exe"
    if not exist AVI\*.* md AVI
    set /p rate=Enter bitrate(k)?
    
    :: Change filters and sample length here!
    set filters=-vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2
    set samplelength=-ss 00:06:00 -to 00:06:30
    set /p sample=Sample clip only?(y/n)
    if /i not [%sample%]==[y] set "samplelength="
    
    for %%a in ("*.mp4","*.mts","*.avi","*.mkv","*.mpg","*.vob","*.webm","*.m2v")  do call :process "%%a"
    endlocal
    echo DONE & pause
    goto :eof
    
    :process
    Title P1-%rate%k-%~1
    if not exist "%%~n1-0.log"    "%ffmpeg%" -i "%~1" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%%~n1" -vtag XVID -an -threads 0 -y NUL
    Title P2-%rate%k-%~1
    if not exist "AVI\%%~n1.avi"  "%ffmpeg%" -i "%~1" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%%~n1" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%%~n1.avi"
    goto :eof
    Quote Quote  
  7. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    @ pcspeak & _Al_

    The long format helps me grasp the short format.
    Keep going.
    Quote Quote  
  8. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Nice one _Al_.

    I started this batch file well over 2 years ago.
    It was only to handle one type of video out of my JVC camera.
    It just grew.

    I'm not too worried about the size of the batch file.
    I realized that others may want to change the batch file to suit.
    Hence the variables to make MY most often changes, simple.

    I, sort of, agree with sambat. When I revisit I like to have as much detail as convenient.

    Thanks for your input. I WILL borrow 1 or 2 techniques.
    Thanks to you too, sambat.

    Cheers
    Quote Quote  
  9. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    @ _Al_
    I made a couple of changes to your batch file to suit my DOS environment.

    After running the batch file exactly per your post the output video on my pc
    didn't had the correct name, just the input parameter description.
    \AVI\%~n1.avi
    I changed the format of some parameters.
    Now works here.

    I never use SETLOCAL & ENDLOCAL
    Added a few cosmetic spaces for readability.
    (If a file has to take up a 4k sector then I'm going to use up to the full 4k.)

    Code:
    @echo off
    :: 2 pass most videos to AVI with MP3 audio.
    
    :: Path to ffmpeg.exe goes here.
    set ffmpeg=C:\VidAud\ffmpeg32\bin\ffmpeg.exe
    if not exist AVI\*.* md AVI
    set /p rate=Enter bitrate(k)?
    
    :: Change filters and sample length here!
    set filters=-vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2
    set samplelength=-ss 00:06:00 -to 00:06:30
    set /p sample=Sample clip only?(y/n)
    if /i not [%sample%]==[y] set "samplelength="
    
    for %%a in ("*.mp4", "*.flv", "*.mts", "*.avi", "*.mkv", "*.mpg", "*.vob", "*.webm") do call :process "%%a"
    goto end
    
    :process
    Title P1-%rate%k-%~1
    if not exist "%%~n1-0.log"    "%ffmpeg%" -i "%~1" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 1 -passlogfile "%~n1" -vtag XVID -an -threads 0 -y NUL
    Title P2-%rate%k-%~1
    if not exist "AVI\%%~n1.avi"  "%ffmpeg%" -i "%~1" %samplelength% -f avi %filters% -c:v mpeg4 -b:v %rate%k -pass 2 -passlogfile "%~n1" -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 -threads 0 -y "AVI\%~n1.avi"
    goto :eof
    
    :end
    Thanks again & cheers all.
    Quote Quote  
  10. Yes, I left double %% there

    -double "%%" characters is in that for ... in ...
    -one "%" character, if it suppose to be passed variable from a function (our function/subroutine is "process")

    also change:
    if not exist "%%~n1-0.log"
    to:
    if not exist "%~n1-0.log"

    and
    if not exist "AVI\%%~n1.avi"
    to:
    if not exist "AVI\%~n1.avi"
    Quote Quote  
  11. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    if not exist "%%~n1-0.log"
    to:
    if not exist "%~n1-0.log"
    oops.
    Last edited by pcspeak; 18th May 2016 at 00:34.
    Quote Quote  
  12. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    This is a slight rehash of a batch file I posted earlier in this thread.
    It uses a couple of recommendations suggested by _Al_.
    The output is AVI.

    The video filters have not changed, much.

    Please note the following methods are not my innovation.
    Greater minds have been at work.

    The input audio is expected to be 6channel (5.1).
    Output will be 2channel (stereo).

    An attempt is made to reduce the volume of all audio except
    the actor's dialogue, which I suspect is the centre channel(s).
    Then the audio is normalized.
    The output audio will have the volume enhanced to increase
    the level of very soft sounds, and the peak volumes reduced
    to remove "most" clipping.

    If the input audio is 2channel?
    The filter is set to do only the normalization.

    I've tested it on 2 DVDs (5.1) and 1 web download (stereo).
    The download was a reality show. Which show? Don't ask. I'm not proud of myself.
    Code:
    @echo off
    :: Most videos to AVI.
    if not exist NEW\*.* md NEW
    
    :: Path to ffmpeg.exe.
    set ffmpeg=C:\VidAud\ffmpeg32\bin\ffmpeg.exe
    :: Path to MediaInfo Command Line.
    set MI_CLI=C:\VidAud\MediaInfoCLI\mediainfo.exe
    
    set /p bitrate=Bitrate?
    
    for %%a in ("*.mp4", "*.flv", "*.wmv", "*.mts", "*.avi", "*.mkv", "*.mpg", "*.mov", "*.vob", "*.webm", "*.ts") do call :process "%%a"
    goto end
    
    :process
    :: Set filters here.
    set vfilters=-vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2
    set afilters=-af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR",dynaudnorm
    
    :: Set sample length here.
    set samplelength=-ss 00:05:00 -to 00:05:30
    set /p sample=Sample clip only?(y/n)
    if /i not [%sample%]==[y] set "samplelength="
    
    :: If audio channels=2 change the audio filters.
    set video=%~1
    %MI_CLI% "--Inform=Audio;%%Channel(s)%%" "%video%" >> tmpfile.txt
    set /p Channel(s)= < tmpfile.txt
    del tmpfile.txt
    set video=
    if %Channel(s)% equ 2 set afilters=-af dynaudnorm
    
    Title "%bitrate%k-%~n1"
    if exist "NEW\%~n1.avi" (
    	echo %~n1.avi already exists...
    	set /p ok=Overwrite the video? [Y,N]
    	)
    if /i [%ok%]==[n] goto :eof
    "%ffmpeg%" -i "%~1" %samplelength% -f AVI %vfilters% -c:v mpeg4 -b:v %bitrate%k -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 %afilters% -threads 0 -y "NEW\%~n1.AVI"
    goto :eof
    
    :end
    echo All done.
    echo Press any key to exit... &pause>nul
    I've been happy with the results. It's removed, mostly, the need to tweak the audio with Audacity.

    Cheers
    Last edited by pcspeak; 30th Nov 2016 at 23:37.
    Quote Quote  
  13. Beer for 2 pass, any file and target size (4GiB-1) - another beer for ability to select particular language tracks (both audio and sub).
    Quote Quote  
  14. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Tried the 32 and 64 bit versions of ffmpeg.
    After I insert the bitrate and tell it that I want a sample, I echo the variables and the command line just before it calls ffmpeg: the variables seem seem ok, then It gives the error.



    Bitrate?1200
    Sample clip only?(y/n)y

    "2.mpg"
    -ss 00:05:00 -to 00:05:30
    -vf yadif=0:-1:0,unsharp,scale=640:trunc(ow/a/2)*2
    1200
    -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0. 30*BR",dynaudnorm

    echo "%ffmpeg%" -i "%~1" %samplelength% -f AVI %vfilters% -c:v mpeg4 -b:v %bitrate%k -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 %afilters% -threads 0 -y "NEW\%~n1.AVI"

    '""' is not recognized as an internal or external command,
    operable program or batch file.
    Press any key to exit...
    Quote Quote  
  15. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    I changed the settings of the paths to ffmpeg and MI to reflect your settings and it worked.

    This was where I had it set to reflect my path and it failed - must be a problem.



    set ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe
    Quote Quote  
  16. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Hi.
    Just tested on my machine. Worked for me. ????
    set ffmpeg=C:\Program Files (x86)\ffmpeg32\bin\ffmpeg.exe

    "%ffmpeg%" -i "%~1" %samplelength% -f AVI %vfilters% -c:v mpeg4 -b:v %bitrate%k -vtag XVID -c:a libmp3lame -b:a 128k -ar 44100 -ac 2 %afilters% -threads 0 -y "NEW\%~n1.AVI"
    '""' is not recognized as an internal or external command,
    operable program or batch file.
    Press any key to exit... "
    Single quotes outside double quotes. Not sure how this comes about.

    Cheers.
    Last edited by pcspeak; 1st Dec 2016 at 17:31. Reason: misread sambat's post.
    Quote Quote  
  17. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Simply placing quotes just around the path failed, thus:

    set ffmpeg="C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe"

    I placed the quotes immediately in front of ffmpeg and it worked, thus:

    set "ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe"
    Seems to be no consensus when it comes to spaces and quotes.
    The last line in the fifth post was how I fixed it.

    http://superuser.com/questions/119610/spaces-and-parenthesis-in-windows-path-variable-...up-batch-files
    Quote Quote  
  18. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Allowing spaces in file names, whilst handy, has been a real pain for batch coders. And full on programmers.
    Thousands upon thousands of errors have occurred because of.

    I can live with:
    Programs
    ProgramFiles
    ProgramFiles-x86
    MyDocs
    Documents
    MyDocuments
    etc. etc. etc.

    One of those Microsoft decisions that, in hindsight, was a bad one.
    Mind you, long file names are a good thing.
    Microsoft seems to think so too.
    Code:
    'C:\Windows\SoftwareDistribution\DeliveryOptimization\f9b50ea393d519f560d8fd6bc7947e7cfdaf8095\'
    And not a space in sight.
    8.3 file names were starting to get seriously vague.

    Anyhoo, it keeps us on our toes.
    Last edited by pcspeak; 1st Dec 2016 at 23:06.
    Quote Quote  
  19. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    @pandy
    Sorry. You're on your own.

    p.s. Op shops. Weekend markets. garage sales. Average price $2.00 for a scratch free DVD. Release dates are from 5-10 years ago.
    I start with DVDShrink. Preferences: Target=DVD-9, 1 VOB(no splitting). Default language - Eng. Audio 5.1. Forced subs. Then Re-author.

    DVDDecrypter with similar preferences as above.
    vobmerge still works for me.

    Basically I end up with a single VOB containing the subs and audio I want. I feed it to my batch files.
    I have an almost identical batch file to the one above that outputs an MP4.

    Forced subs only? We'd best start a new thread.
    Last edited by pcspeak; 1st Dec 2016 at 23:35.
    Quote Quote  
  20. I use:
    set ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe
    ...
    "%ffmpeg%" etc...
    SET can accept values with spaces. It's the command line that can't.

    I don't know how this:
    Originally Posted by sambat View Post
    set "ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe"
    works for you. It does not work for me:
    'C:\Program' is not recognized as an internal or external command, operable program or batch file.
    Quote Quote  
  21. Originally Posted by pcspeak View Post
    @pandy
    Sorry. You're on your own.
    I know... i had idea but it will be not elegant for sure (in command line - with some language like python it should be quite easy).
    Quote Quote  
  22. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    We could just leave the space out.

    Windows x32
    set ffmpeg=C:\Progra~1\ffmpeg\bin\ffmpeg.exe
    Windows x64
    set ffmpeg=C:\Progra~2\ffmpeg\bin\ffmpeg.exe


    Spaces and the length of the path string are the reason I just download the latest ffmpeg and 7unzip it to where I want it.

    Eeeek!!! Edit. Edit. Edit.
    Last edited by pcspeak; 11th Dec 2016 at 01:00. Reason: I was dumb enough to leave the double quotes in. :o(
    Quote Quote  
  23. Guys I have plenty of subroutines that one can simply call with "CALL variable1 variable2 ..." function. They rather be within script otherwise firewalls complain and it is not that nice if they are all in some BAT file (like "DVavi helper.zip" was done years back). Those subroutines can be just stocked at the bottom of the same script out of sight, making that script more clean. Those subroutines can be submerged into themselves, I myself have 5-6 levels submerged and it simply works ...

    These subroutines can get mediainfo into variables, check avisynth output (before actually you render a video), autocrop etc.
    I can post them here one by one slowly to not overwhelm anyone or let some time for questions
    First thing you do though is to get Notepad++ , copy/paste script in there, set language to batch and it is much more easier to read in script

    First basic one is getting mediainfo from video into variables, you need to download mediainfo CLI from here not mediainfo from mediainfo website first

    Code:
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    echo video mediainfo into variables
    
    set "video=C:\video\my_video.avi"
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    
    if not exist "%temp_folder%" echo creating temp folder: "%temp_folder%"& MD "%temp_folder%"
    
    call :run_mediainfo "%video%"
    
    echo.
    echo MediaInfo reports:
    if defined serving echo video: frame serving %format%,%w% x %h%, %fps% fps, ar^=%ar%, %duration%
    if not defined serving echo video: %format%, %w% x %h%, %fps% fps, %scan_type%, %scan_order%, ar^=%ar%, %cs%, %ch_sub%, %duration%
    echo audio: sampling rate %sampling%
    echo.
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    
    
    
    
    
    :run_mediainfo <video file>
    set field_order=unknown
    set format=unknown
    set scan_order=unknown
    set scan_type=unknown
    set fps=unknown
    set ar=unknown
    set w=unknown
    set h=unknown
    set duration=unknown
    set fps=unknown
    set ar=unknown
    set cs=unknown
    set ch_sub=unknown
    set sampling=unknown or no audio
    if not exist "%mediainfo%" echo ERROR, Mediainfo path is not defined or file is missing & goto :eof
    if not exist "%~1"         echo ERROR, Filename path is not defined or file is missing& goto :eof
    "%mediainfo%" "%~1" > "%temp_folder%\mediainfo.txt"
    set info="%temp_folder%\mediainfo.txt"
    findstr /c:"Scan order    "  %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (set /p scan_order= < "%temp_folder%\temp.txt" &  set scan_order=!scan_order:*: =!) else (set "scan_order=")
    findstr /c:"Scan type    "  %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 set /p scan_type= < "%temp_folder%\temp.txt" & set scan_type=!scan_type:*: =!
    findstr /b /i /c:"Duration   " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 set /p duration= < "%temp_folder%\temp.txt" & set duration=!duration:*: =!
    findstr /b /i /c:"Format    " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 set /p format= < "%temp_folder%\temp.txt" & set format=!format:*: =!
    findstr /b /i /c:"Width    " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 set /p w= < "%temp_folder%\temp.txt" & set w=!w:*:=! & set w=!w: pixels=! & set w=!w: =!
    findstr /b /i /c:"Height   " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p h= < "%temp_folder%\temp.txt"
       set h=!h:*:=!
       set h=!h: pixels=!
       set h=!h: =!
       )
    findstr /b /i /c:"Display aspect ratio   " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p ar= < "%temp_folder%\temp.txt"
       set ar=!ar:*: =!
       )
    findstr /b /i /c:"Frame rate    " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p fps= < "%temp_folder%\temp.txt"
       set fps=!fps:*: =!
       for /f "tokens=1 delims= " %%x in ("!fps!") do set "fps=%%x" 
       )
    findstr /b /i /c:"Color space      " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p cs= < "%temp_folder%\temp.txt"
       set cs=!cs:*: =!
       )
    findstr /b /i /c:"Chroma subsampling  " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p ch_sub= < "%temp_folder%\temp.txt"
       set ch_sub=!ch_sub:*: =!
       )
    findstr /b /i /c:"Sampling rate  " %info% > "%temp_folder%\temp.txt"
    if %errorlevel%==0 (
       set /p sampling= < "%temp_folder%\temp.txt"
       set sampling=!sampling:*: =!
       )
    set "serving="
    findstr /b /i /c:"Format                                   : VFW" %info%>nul
    if %errorlevel%==0 set serving=yes
    goto :eof
    Last edited by _Al_; 2nd Dec 2016 at 15:54.
    Quote Quote  
  24. Jagabo years back introduced here that wonderful idea of dropping files on batch file, which has exactly the the same effect as writing command line manually.
    So taking above example, you grab any video file and you drop it on batch file getting mediaifo on screen and in variables that you can sort out later for any purpose:
    Code:
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    echo video mediainfo into variables
    
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    
    if not exist "%temp_folder%" echo creating temp folder: "%temp_folder%"& MD "%temp_folder%"
    
    call :run_mediainfo "%~1"
    
    echo.
    echo MediaInfo reports:
    if defined serving echo video: frame serving %format%,%w% x %h%, %fps% fps, ar^=%ar%, %duration%
    if not defined serving echo video: %format%, %w% x %h%, %fps% fps, %scan_type%, %scan_order%, ar^=%ar%, %cs%, %ch_sub%, %duration%
    echo audio: sampling rate %sampling%
    echo.
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    rem here youpaste that :run_mediainfo subroutine
    the only change from above script is deleting that line where you defined video and writing %~1 instead of %video% while calling :run_mediainfo

    You might create batch script where dropping videofile on batch script would bring same text view as installed mediainfo does. So you dot need to install media info at all. You just use portable version, CLI version. You do not need to call :run_mediainfo for this:
    Code:
    @echo off
    SETLOCAL
    echo video mediainfo into text output
    
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    "%mediainfo%" "%~1" > "%temp_folder%\mediainfo.txt"
    START  "notepad.exe" "%temp_folder%\mediainfo.txt"
    ENDLOCAL&exit
    About allowed character in batch scripts. Batch is not tolerant much at all with these characters: | & < > ^ . But those are not allowed in paths and filenames so this illegal check does not bother with these for now. But you have to be careful about characters in filenames and their paths as well, because when scripts get more elaborate other characters might be a problem especially some foreign language characters while using those paths within Avisynth and you are in trouble, so I have one subroutine that allows only alphabetic characters , numbers, spaces or . _-:\ . These are usually no trouble at all. So this script checks paths first, if one of those found:& ^ + ( ) @ # $ { } [ ] ' ; , ` % " and foreign characters then it gives error.Maybe it is overkill, some scripts would work with many of those not allowed characters but just to be sure, it is batch script.

    So here is a batch, you can drop a video file on it and it tests paths used in script, just subroutine is called for particular path (in that script dropped videofile and mediainfo path):
    Code:
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    echo video mediainfo into variables
    
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    
    set "fail="
    call :illegal_character_check "%temp_folder%"
    call :illegal_character_check "%~1"
    call :illegal_character_check "%mediainfo%"
    if defined fail ENDLOCAL&echo press any key to exit&pause>nul&exit
    
    if not exist "%temp_folder%" MD "%temp_folder%"
    call :run_mediainfo "%~1%"
    
    echo.
    echo MediaInfo reports:
    if defined serving echo video: frame serving %format%,%w% x %h%, %fps% fps, ar^=%ar%, %duration%
    if not defined serving echo video: %format%, %w% x %h%, %fps% fps, %scan_type%, %scan_order%, ar^=%ar%, %cs%, %ch_sub%, %duration%
    echo audio: sampling rate %sampling%
    echo.
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    
    :illegal_character_check <file>
    rem definitively allowed characters:  space and  . _-:\0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
    set "var=%~1"
    for %%i in (^& ^^ + ^( ^) @ # $ { } [ ] ' ; , ` ^%% ^") do set var=!var:%%i=!
    :search
    for /f "tokens=1* delims=~=" %%j in ('echo !var!') do (
    set var=%%j%%k
    set flag=%%k
    )
    if not "%flag%"=="" goto :search
    if exist "%var%" goto :eof
    set fail=yes
    echo Did not pass illegal character check:
    echo "%~1"
    echo remove illegal characters to avoid problems with this batch script or Avisynth
    echo.
    goto :eof
    
    
    rem here you paste that :run_mediainfo subroutine
    Note: you have to add that :run_mediainfo to that script, also removing that:
    Code:
    if defined fail ENDLOCAL&echo press any key to exit&pause>nul&exit
    script might finish even with one of those illegal characters in paths, because in this case it would not matter
    Last edited by _Al_; 23rd Jan 2017 at 14:50.
    Quote Quote  
  25. MediaInfoCLI can find out only one concrete thing using other method but unfortunately this method cannot find scan order or chroma and some other things:
    Code:
    @echo off
    SETLOCAL
    echo video mediainfoCLI
    
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    "%Mediainfo%" --Inform=Video;%%FrameRate%% "%~1" > "%temp_folder%\temp.tmp"
    set /p fps=<"%temp_folder%\temp.tmp"
    echo Mediainfo reports: fps=%fps%
    
    ENDLOCAL&echo press any key to exit&pause>nul&exit
    --Inform=Video
    means that it is looked only in video section not audio section
    more in manual that is included when you download MediainfoCLI.zip
    So advantage: you do not need to parse anything to get the value, you get it right away
    disadvantage: not all video properties can be found using this (above method parsing mediainfo.txt file yes)

    EDIT: downloading latest mediainfo CLI it detects even scan order, chroma subsumpling, I think everything it suppose to. maybe I messed up something before, .., so this method might be used to get any video parameters. All parameters that can be found could be printed running this BAT, the list is long so it is better to print it in txt file, in this case parameters.txt rather that print it in command prompt:

    Code:
    @echo off
    SETLOCAL
    echo video mediainfoCLI
    
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    "%Mediainfo%" --Info-Parameters > "%temp_folder%\parameters.txt"
    START  "notepad.exe" "%temp_folder%\parameters.txt"
    ENDLOCAL&exit
    Last edited by _Al_; 26th Dec 2016 at 22:04.
    Quote Quote  
  26. Creating Avisynth script dropping avi videofile onto this batch file:
    Code:
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    REM checking for illegal character input
    call :illegal_character_check "%~1"
    if defined fail ENDLOCAL&echo press any key to exit&pause>nul&goto :eof
    
    rem checking if extension is avi
    for %%i in ("%~1") do set "extension=%%~xi"& set "name=%%~ni"
    if /i not [%extension%] == [.avi] echo file is not avi& pause& goto :eof
    
    echo Avisource("%~1")          > "%temp_folder%\%name%.avs"
    echo LanczosResize(1920,1080) >> "%temp_folder%\%name%.avs"
    
    echo created avisynth script:
    type "%temp_folder%\%name%.avs"
    pause& goto :eof
    
    rem here you include :illegal_character_check subroutine
    Quote Quote  
  27. Now that script above could be modified to add a subroutine that checks if there is a syntax error in the script. Just syntax error, not if script is functioning well or proper filters were used etc.

    This is done by creating a wrapper for original avisynth script and loading that into avsmeter (make sure it is latest), it could be virtualdub or something else, point is just to load it somewhere and it would create error log if there is syntax error, then if that happens error info is printed in command prompt:
    Code:
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    set "AVSMeter=C:\tools\AVSMeter\AVSMeter.exe"
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    REM checking for illegal character input
    call :illegal_character_check "%~1"
    call :illegal_character_check "%AVSMeter%"
    if defined fail ENDLOCAL&echo press any key to exit&pause>nul&goto :eof
    
    rem checking if extension is avi
    for %%i in ("%~1") do set "extension=%%~xi"& set "name=%%~ni"
    if /i not [%extension%] == [.avi] echo file is not avi& pause& goto :eof
    
    echo Avisource("%~1")          > "%temp_folder%\%name%.avs"
    echo LLanczosResize(1920,1080) >> "%temp_folder%\%name%.avs"
    
    REM checking script for errors
    call :check_avs_for_errors "%temp_folder%\%name%.avs"
    if exist "%temp_folder%\error.log" endlocal & echo press any key to exit ... & pause>nul & goto :eof
    
    echo generated avisynth script is printed between lines:
    echo -------------------------------------------------------------
    type "%temp_folder%\%name%.avs"
    echo -------------------------------------------------------------
    echo.
    pause& ENDLOCAL& goto :eof
    
    
    rem here you include :illegal_character_check subroutine
    
    
    :check_avs_for_errors <avs script>
    rem goal is to run avisynth script wrapper with avsmeter.exe just to run avisynth script, where wrapper would generate error.log if there is a syntax error in script
    echo avisynth script syntax error check, wait ...
    if exist "%temp_folder%\error.log" del "%temp_folder%\error.log"
    REM creating wrapper for catching avisynth error
    
    echo script = "%~1"         > "%temp_folder%\avswrapper.avs"
    echo log = "%temp_folder%\error.log"  >> "%temp_folder%\avswrapper.avs"
    echo try { Import(script) } >> "%temp_folder%\avswrapper.avs"
    echo catch (err) {          >> "%temp_folder%\avswrapper.avs"
    echo   WriteFileStart(BlankClip(), log, "script", """ ": " """, "err", append=true)  >> "%temp_folder%\avswrapper.avs"
    echo } >> "%temp_folder%\avswrapper.avs"
    
    for %%i in ("%avsmeter%") do set "avsmeter_path=%%~dpi"
    if exist "%avsmeter_path%AVSMeter.ini" del "%avsmeter_path%AVSMeter.ini" temp.ini
    "%AVSMeter%" "%temp_folder%\avswrapper.avs" -range=0,1 2>nul
    if exist "%avsmeter_path%temp.ini" del "%avsmeter_path%AVSMeter.ini"
    if exist "%avsmeter_path%temp.ini" ren "%avsmeter_path%temp.ini" AVSMeter.ini
    if exist "%avsmeter_path%temp.ini" del  "%avsmeter_path%temp.ini"
    
    if not exist "%temp_folder%\error.log" goto :eof
    echo.
    echo    ERROR, syntax error detected in this avisynth script:
    type "%~1"
    echo    ERROR Line:
    type "%temp_folder%\error.log" | findstr /v avswrapper.avs
    goto :eof
    there is a syntax error mistake on purpose written in that avisynth script, if you correct it it, save that BAT again, it would not find any error then ...
    not sure why it prints error line two times ... but it works
    Last edited by _Al_; 26th Dec 2016 at 22:23.
    Quote Quote  
  28. AvsMeter is a great utility, not only to analyze speed, but also it can get video properties coming out of Avisynth script, that could be really handy sometimes. Like check frame rate, width, height before video is even actually encoded, before video really exists and more importantly it could be handy to get those values into batch script variables, so time is not wasted to actually encode it first if script processes things automatically.
    avsmeter command line could be:
    "avsmeter.exe" "my_script.avs" -log
    where log is specified in avsmeter.ini, that is in the same folder as avsmeter.exe

    so for example to get frame rate, height and width coming out of avisynth script, drop avisynth file onto this batch script,
    correct the path for avsmeter first depending where it is in your PC:
    Code:
    @echo off
    echo Getting some avisynth script output properties into variable with avsmeter utility
    
    set "avsmeter=C:\tools\AVSMeter\AVSMeter.exe"
    
    if "%~1" =="" echo you need to drop avisynth script file onto this batch script & pause& goto :eof
    if /i not  "%~x1" == ".avs" echo dropped file does not have avs extension& pause& goto :eof
    if exist "%temp%" set "temp_folder=%temp%"
    if not exist "%temp_folder%" set "temp_folder=C:\temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    rem getting avsmeter.exe path
    for %%i in ("%avsmeter%") do set "avsmeter_path=%%~dpni"
    
    rem avsmeter.INI must be in the same directory as avsmeter.exe
    rem I did not figured out how to specify path for log in avsmeter command line, it only worked to write it in INI file:
    echo LogDirectory=%temp_folder% > "%avsmeter_path%.ini"
    
    echo.
    rem avsmeter command line analysing only couple of first frames, no need for higher range for what we need
    rem also not printing anything into cmd prompt window, only to create log file
    rem remember it might index a file if not avisource is used, but that index file is needed later anyway ...
    
    "%avsmeter%" "%~1" -log -range=0,1 
    
    for %%i in ("%~1") do set "avisynth_name=%%~ni"
    findstr /b /i /c:"Frame height:" "%temp_folder%\%avisynth_name%.log" > "%temp_folder%\temp.txt"
    set /p line= < "%temp_folder%\temp.txt"
    set line=%line:Frame height:=% 
    set height=%line: =%
    
    findstr /b /i /c:"Frame width:" "%temp_folder%\%avisynth_name%.log" > "%temp_folder%\temp.txt"
    set /p line= < "%temp_folder%\temp.txt"
    set line=%line:Frame width:=% 
    set width=%line: =%
    
    findstr /b /i /c:"Framerate:" "%temp_folder%\%avisynth_name%.log" > "%temp_folder%\temp.txt"
    set /p line= < "%temp_folder%\temp.txt"
    set line=%line:Framerate:=% 
    for /f "tokens=1,2 delims= " %%x in ("%line%") do set fps=%%x
    
    echo.
    echo Avisynth script output is %width%x%height%, %fps%fps
    echo.
    pause
    Last edited by _Al_; 7th Jan 2017 at 13:56.
    Quote Quote  
  29. Or you can find out avisynth version installed in PC and compare it if version is at least 2.6.0, just run this batch, no file dropping needed:
    again , fix your avsmeter path in that script first
    Code:
    @echo off
    echo Getting Avisynth version into variable with avsmeter
    
    set "avsmeter=C:\tools\AVSMeter\AVSMeter.exe"
    
    if exist %SYSTEMROOT%\SysWOW64\avisynth.dll set "avs=yes"
    if exist %SYSTEMROOT%\System32\avisynth.dll set "avs=yes"
    if not defined avs (
      echo    WARNING, avisynth.dll was not detected in SysWOW64 or System32 directory, Avisynth is perhaps not installed 
      echo.
    )
    if exist "%temp%" set "temp_folder=%temp%"
    if not exist "%temp_folder%" set "temp_folder=C:\temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    for %%i in ("%avsmeter%") do set "avsmeter_path=%%~dpni"
    echo LogDirectory=%temp_folder% > "%avsmeter_path%.ini"
    
    echo blankclip() > "%temp_folder%\blank.avs"
    echo wait ...
    "%avsmeter%" "%temp_folder%\blank.avs" -log  2>nul
    findstr /b /i /c:"File version" "%temp_folder%\blank.log" > "%temp_folder%\temp.txt"
    rem storing that line into a variable
    set /p line= < "%temp_folder%\temp.txt"
    rem deleting "File version:" string from that line
    set line=%line:File version:=%
    rem deleting spaces from that line, to keep avisynth number version only
    set line=%line: =%
    echo Avisynth version is %line%
    echo.
    echo parsing result to find out if version is at least 2.6.0
    rem parsing that line to get first and second number between dots
    for /f "tokens=1,2 delims=." %%x in ("%line%") do set first=%%x& set second=%%y
    set "ok="
    if %first% EQU 2 if %second% GEQ 6 set ok=yes
    if %first% GTR 2  set ok=yes
    echo.
    if defined ok echo Avisynth version %line% works for us, HCEncoder 028 should have Avisynth version higher than 2.6
    if not defined ok echo    WARNING, HcEncoder 028 recommends at least Avisynth 2.6.0.0 yours is %line%
    pause
    Quote Quote  



Similar Threads