VideoHelp Forum




+ Reply to Thread
Results 1 to 10 of 10
  1. Hi,

    I would like build a batch file that do this:

    it have to recognize if my .avi source (attached) is mjpeg (MJPG) or uncompressed (YUY2) with the ffprobe and

    If is mjpeg --> goto procedure1
    if is UNCOMPRESSED --> goto procedure2

    in another bath ndjamed help me using something like this:

    Code:
    SetLocal DisableDelayedExpansion
    	rem Find TimeCode Info
    	Set AUCount=0;
    	for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdubmod\FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~1" 2^>^&1') DO (
    		 if "%%~g"=="TAG:company_name" set "T_Company_Name=%%~h"
    		 if "%%~g"=="TAG:product_name" set "T_Product_Name=%%~h"
    		 if "%%~g"=="TAG:product_version" set "T_Product_Version=%%~h"
    		 if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h"
    		 if "%%~g"=="width" set "V_Width=%%~h"
    		 if "%%~g"=="height" set "V_Height=%%~h"
    		 if "%%~g"=="sample_aspect_ratio" set "V_PAR=%%~h"
    		 if "%%~g"=="codec_type" if "%%~h"=="audio" set /a AUCount+=1
    	)
    	if "%V_Width%"=="" (
    		echo  ERROR: Video Width NOT FOUND!
    		pause
    		goto :eof
    	)
    	if "%V_Height%"=="" (
    		echo  ERROR: Video Height NOT FOUND!
    		pause
    		goto :eof
    	)
    	if "%V_PAR%"=="" (
    		echo  ERROR: Video PAR NOT FOUND!
    		pause
    		goto :eof
    	)
    	rem Set "V_Q=UD"
    	rem if %V_Width% LEQ 1920 if %V_Height% LEQ 1120 \\
    	Set "V_Q=HD"
    	rem if %V_Width% LEQ 1280 if %V_Height% LEQ 752 Set "V_Q=MD"
    	if %V_Width% LEQ 1024 if %V_Height% LEQ 608 Set "V_Q=SD"
    	echo  Using %V_Q% Mode
    	echo  PAR = %V_PAR%
    	if "%TimeCode%"=="" echo Warning! no TimeCode Found!
    	if NOT "%TimeCode%"=="" echo Timecode= %TIMECODE%
    	
    if "%V_Q%"=="SD" (CALL :MAKEVCF_SD "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1")
    if "%V_Q%"=="HD" (CALL :MAKEVCF_HD "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1")
    
    but now, in this batch, I would analize the "vtag"

    How I have to change it to recognize the "vtag" YUY2 or MJPG?

    thanks
    Image Attached Files
    • File Type: avi u.avi (4.02 MB, 51 views)
    • File Type: wav u.wav (37.5 KB, 80 views)
    Last edited by marcorocchini; 16th Jun 2014 at 09:39.
    Quote Quote  
  2. an in this another attachment is the .avi in mjpeg
    Image Attached Files
    • File Type: avi m.AVI (2.01 MB, 64 views)
    • File Type: wav m.wav (37.5 KB, 77 views)
    Quote Quote  
  3. u.avi = uncompressed.avi
    m.avi = mjpeg .avi
    Quote Quote  
  4. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    I'm sure I gave you this before:

    Code:
    FFProbe -hide_banner -loglevel fatal -pretty -show_streams "%~1" 1>"%~dpn1.txt"
    Quote Quote  
  5. thanks ndjamena, your batch does work perfectly. With yours I'm able to transcode from .mxf into .avi files

    Now I have to do a batch that do from .avi into .mxf (but in hd mode ffmbc won't work :=()

    So I have to recognize if my source is a .avi mjpeg or yuy2, but possibly I don't wont to generate a .txt file. Simply the batch have to analize the .avi and if it is yuy2 have to go into procedure1 (..) and if is mjpeg have to go into procedure2

    u.avi is yuy2
    m.avi is mjpg

    have the batch distinguish it in base the fourcc code? ffprobe have to extract the fourcc

    The new batch should: watch if the input .avi file is internally mjpg or yuy2: if the .avi is not yuy2 or mjpg ---> goto EOF : "error unrecognized input format"



    This is my definitive MXF2AVI.bat (from mxf to avi)

    Code:
    @rem unless otherwise specified for debugging reasons turn echo off
    @if "%EMode%"=="" Set EMode=ON
    @ECHO %EMode%
    @ECHO off
    
    xcopy /y V:\automazioneclip\system\morgan\m3jpegHD.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpHD.ini c:\windows
    xcopy /y v:\automazioneclip\system\morgan\MMIJG32.dll c:\windows\system32
    xcopy /y V:\automazioneclip\system\morgan\m3jpegSD.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpSD.INI c:\windows
    xcopy /y v:\automazioneclip\system\morgan\MMIJG30.dll c:\windows\system32
    
    xcopy /y v:\automazioneclip\system\wavdest.ocx c:\windows\system32
    xcopy /y v:\automazioneclip\system\SamplesDropper.ocx c:\windows\system32
    xcopy /y v:\automazioneclip\system\SP_audio.ocx c:\windows\system32
    xcopy /y v:\automazioneclip\system\dv_grabber.ocx c:\windows\system32
    xcopy /y v:\automazioneclip\system\SP_video.ocx c:\windows\system32
    regsvr32 /s c:\windows\system32\wavdest.ocx
    regsvr32 /s c:\windows\system32\SamplesDropper.ocx
    regsvr32 /s c:\windows\system32\SP_audio.ocx
    regsvr32 /s c:\windows\system32\dv_grabber.ocx
    regsvr32 /s c:\windows\system32\SP_video.ocx
    
    regedit /s v:\automazioneclip\system\morgan\morganreg.reg
    del v:\automazioneclip\output\temp.avi
    del v:\automazioneclip\output\temp.wav
    cls
    
    
    SetLocal DisableDelayedExpansion
    
    Set "EXTLIST=*.mxf"
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    Set VDM_LOC="v:\automazioneclip\VirtualDubMOD\virtualdubmod.exe"
    
    if not exist v:\automazioneclip\output\progetto1 mkdir v:\automazioneclip\output\progetto1
    set "DestFolder=v:\automazioneclip\output\progetto1"
    
    
    Set "WorkFolder=%DestFolder%"
    
    if not exist %DestFolder% mkdir %DestFolder%
    
    rem process the arguments one by one
    :ARGS
    	
    	rem if there are no further arguments then exit the batch.
    	if [%1]==[] (
    		if "%ARGLVL%"=="0" (
    			CALL :GetTargetName		
    			EndLocal
    			pause
    		)
    		goto :eof
    	)
    
    	rem wildcard processing
    	Set "FileName=%~1"
    	if "%FileName%"=="" (
    		SHIFT
    		goto :ARGS
    	)
    
    	rem if the argument doesn't exist in the file system in any form skip it.
    	if NOT EXIST %1 (
    		SHIFT
    		goto :ARGS
    	)
    
    	if NOT [%1]==[] if NOT "%FileName:^*=%%FileName:^?=%"=="%FileName%%FileName%" (
    		for %%w in (%1) DO (
    			Set /a ARGLVL+=1
    			CALL :ARGS "%%~fw"
    			Set /a ARGLVL-=1
    		)
    		SHIFT
    		goto :ARGS
    	)
    	Set "FileName="
    		
    	rem Set search/recursion variables
    	Set "Pattern=%EXTLIST%"
    	Set "STARTLVL=0"
    	Set "FOUNDLVL=1024"
    	
    	rem if the argument is the current directory then process everything in it.
    	if "%~f1"=="%CD%" (
    		rem echo Processing Directory "%CD%"
    		CALL :START %1
    		SHIFT
    		goto :ARGS
    	)
    	rem Test if the argument is a directory, if it is move to it then process everything in it, if not then move to the file's parent directory and process the file.  Then return to starting directory.
    	Type NUL
    	pushd "%~f1" 2> nul
    	if NOT "%errorlevel%"=="0" (
    		if NOT "%CD%\"=="%~dp1" (
    			pushd "%~dp1"
    			Set "DoPop=1"
    		)
    		Set Pattern="%~nx1"
    	) else (
    		rem echo Processing Directory "%~f1"
    		Set "DoPop=1"
    	)
    	CALL :START %1
    	if "%DoPop%"=="1" (
    		popd
    		Set "DoPop=0"
    	)
    	SHIFT
    
    goto :ARGS
    
    :START <CURRENT_ARG>
    
    	rem Count is superseded by FOUNDLVL but may still be useful for renaming purposes
    	Set "Count=0"
    	rem Process all files in the current directory fitting the arguments search pattern.
    	for /f "delims=" %%y in ('dir %Pattern% /b /od /a-d') do (
    		if /I NOT "%%~y"=="File Not Found" CALL :Process_File "%%~fy"
    	)
    	rem if it didn't find anything search all directories instead
    goto :eof
    	if "%Count%"=="0" if %STARTLVL% LSS %FOUNDLVL% (
    		for /d %%b in (*) do (
    			pushd "%%~fb"
    			rem echo Processing Directory "%%~fb"
    			Set /a STARTLVL+=1
    			CALL :START "%%~fb"
    			Set /a STARTLVL-=1
    			popd
    		)
    	)
    
    goto :eof
    
    :Process_File <MXF_FILENAME>
    
    	Set /a Count+=1
    	Set "FOUNDLVL=%STARTLVL%"
    
    	echo Processing "%CD%\%~nx1"
    	if /I NOT "%~x1"==".mxf" (
    		echo "%~nx1"
    		echo  Is not an mxf file.
    		pause
    		goto :eof
    	)
    	if EXIST "%DestFolder%\%~n1.avi" (
    		echo  File già esistente nella directory di destinazione %DestFolder%
    
    
    
    
    
    
    		goto :eof
    	)
    	if EXIST "%WorkFolder%\%~n1.avi" (
    		echo  Working File Already Exists...
    		goto :eof
    		pause
    	)
    	
    	SetLocal DisableDelayedExpansion
    	rem Find TimeCode Info
    	Set AUCount=0;
    	for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdubmod\FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~1" 2^>^&1') DO (
    		 if "%%~g"=="TAG:company_name" set "T_Company_Name=%%~h"
    		 if "%%~g"=="TAG:product_name" set "T_Product_Name=%%~h"
    		 if "%%~g"=="TAG:product_version" set "T_Product_Version=%%~h"
    		 if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h"
    		 if "%%~g"=="width" set "V_Width=%%~h"
    		 if "%%~g"=="height" set "V_Height=%%~h"
    		 if "%%~g"=="sample_aspect_ratio" set "V_PAR=%%~h"
    		 if "%%~g"=="codec_type" if "%%~h"=="audio" set /a AUCount+=1
    	)
    	if "%V_Width%"=="" (
    		echo  ERROR: Video Width NOT FOUND!
    		pause
    		goto :eof
    	)
    	if "%V_Height%"=="" (
    		echo  ERROR: Video Height NOT FOUND!
    		pause
    		goto :eof
    	)
    	if "%V_PAR%"=="" (
    		echo  ERROR: Video PAR NOT FOUND!
    		pause
    		goto :eof
    	)
    	rem Set "V_Q=UD"
    	rem if %V_Width% LEQ 1920 if %V_Height% LEQ 1120 \\
    	Set "V_Q=HD"
    	rem if %V_Width% LEQ 1280 if %V_Height% LEQ 752 Set "V_Q=MD"
    	if %V_Width% LEQ 1024 if %V_Height% LEQ 608 Set "V_Q=SD"
    	echo  Using %V_Q% Mode
    	echo  PAR = %V_PAR%
    	if "%TimeCode%"=="" echo Warning! no TimeCode Found!
    	if NOT "%TimeCode%"=="" echo Timecode= %TIMECODE%
    	
    if "%V_Q%"=="SD" (CALL :MAKEVCF_SD "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1")
    if "%V_Q%"=="HD" (CALL :MAKEVCF_HD "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1")
    
    
    
    rem CALL :MAKEVCF "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1"
    
    	echo  FATTO
    	echo.
    	echo ---------------------------------------------
    	echo.
    	EndLocal
    	
    goto :eof
    
    :MAKEVCF_HD <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <MXF_FILENAME>
    
            v:\automazioneclip\virtualdubmod\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -filter_complex "[0:1] [0:2] amerge,volume=3" -c:a pcm_s16le %WorkFolder%\%~n1.wav
            v:\automazioneclip\virtualdubmod\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -filter_complex "[0:3] [0:4] amerge,volume=3" -c:a pcm_s16le %WorkFolder%\%~n1ch3ch4.wav
    
    	rem ***Make The .vcf Script File***
    	echo VirtualDub.RemoveInputStreams^(^)^;>%1
    	echo VirtualDub.video.DeleteComments^(1^)^;>>%1
    	if NOT "%TimeCode%"=="" echo VirtualDub.video.AddComment^(0x0000000C,"","%TIMECODE%"^)^;>>%1
    	echo VirtualDub.video.AdjustChapters^(1^)^;>>%1
    	echo VirtualDub.video.SetDepth^(16,16^)^;>>%1
    	echo VirtualDub.video.SetMode^(1^)^;>>%1
    	echo VirtualDub.video.SetFrameRate^(0,1^)^;>>%1
    	echo VirtualDub.video.SetIVTC^(0,0,-1,0^)^;>>%1
    	echo VirtualDub.video.SetCompression^(0x31626d64,0,10000 ,0^)^;>>%1
    	echo VirtualDub.video.filters.Clear^(^)^;>>%1
    		
    	rem ***Make The .avs AVISynth Script***
    	echo DirectShowSource^(%4^)>%2
    
    	
    	rem ***Call VirtualDub[Mod]
    	if NOT EXIST %VDM_LOC% (
    		echo  Um, where the hell is VirtualDubMod?
    		pause
    	)
    	%VDM_LOC% /s%1 /p%2,%3 /r /x
    	if NOT "%ERRORLEVEL%"=="0" (
    		echo  WARNING!!!  VirtualDubMod Error Detected!!!
    		pause
    	)
    	for %%v in (%3) do (
    		if %%~zv LSS 128 (
    			echo  ERROR!!!  Extra Small File Size Detected!!!
    			pause
    		)
    	)
            v:\automazioneclip\virtualdub\cfourcc.exe -i %3 -u MJPG -d MJPG
    	rem Clean-up
    	DEL %1
    	DEL %2
    	
    goto :eof
    
    
    :MAKEVCF_SD <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <MXF_FILENAME>
    
    
    
    
            v:\automazioneclip\virtualdubmod\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -map_channel 0.1.0 -map_channel 0.1.1 -af "volume=volume=9dB:precision=fixed" %WorkFolder%\%~n1.wav
            v:\automazioneclip\virtualdubmod\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -map_channel 0.1.2 -map_channel 0.1.3 -af "volume=volume=9dB:precision=fixed" %WorkFolder%\%~n1ch3ch4.wav
    
    
    	rem ***Make The .vcf Script File***
    	echo VirtualDub.RemoveInputStreams^(^)^;>%1
    	echo VirtualDub.video.DeleteComments^(1^)^;>>%1
    	if NOT "%TimeCode%"=="" echo VirtualDub.video.AddComment^(0x0000000C,"","%TIMECODE%"^)^;>>%1
    	echo VirtualDub.video.AdjustChapters^(1^)^;>>%1
    	echo VirtualDub.video.SetDepth^(16,16^)^;>>%1
    	echo VirtualDub.video.SetMode^(1^)^;>>%1
    	echo VirtualDub.video.SetFrameRate^(0,1^)^;>>%1
    	echo VirtualDub.video.SetIVTC^(0,0,-1,0^)^;>>%1
    	echo VirtualDub.video.SetCompression^(0x6a6d7674,0,10000 ,0^)^;>>%1
    	echo VirtualDub.video.SetCompData^(28,"TUpQRxgAAAAAAAAAAgAAAAgAAAACAAAAAQAAAA=="^)^;>>%1
    	echo VirtualDub.video.filters.Clear^(^)^;>>%1
    		
    	rem ***Make The .avs AVISynth Script***
    	echo DirectShowSource^(%4^)>%2
    	echo Crop^(0,32,0,0^)>>%2
    	
    	rem ***Call VirtualDub[Mod]
    	if NOT EXIST %VDM_LOC% (
    		echo  Um, where the hell is VirtualDubMod?
    		pause
    	)
    	%VDM_LOC% /s%1 /p%2,%3 /r /x
    	if NOT "%ERRORLEVEL%"=="0" (
    		echo  WARNING!!!  VirtualDubMod Error Detected!!!
    		pause
    	)
    	for %%v in (%3) do (
    		if %%~zv LSS 128 (
    			echo  ERROR!!!  Extra Small File Size Detected!!!
    			pause
    		)
    	)
            v:\automazioneclip\virtualdub\cfourcc.exe -i %3 -u MJPG -d MJPG
    	rem Clean-up
    	DEL %1
    	DEL %2
    	
    
    
    goto :eof
    
    :GetTargetName
    
    	Set "FileName="
    	Set /p FileName=InputFileName.mxf o InputFolder - INVIO per convertire tutto (EXIT esce):
    	
    	rem Add or remove double-quotes if necessary
    
    	if NOT DEFINED FileName (
    		Set "FileName-DQ="
    		goto :DQSkip
    	)
    	
    	Set "FileName-DQ=%FileName:"=%"
    	if NOT DEFINED FileName-DQ (
    		Set "FileName="
    		Set "FileName-DQ="
    		goto :DQSkip
    	)
    	
    	if EXIST "%FileName-DQ%" (
    		if "%FileName-DQ%"=="%FileName-DQ: =%" (
    			Set "FileName=%FileName-DQ%"
    		) else (
    			Set FileName="%FileName-DQ%"
    		)
    	)
    
    :DQSkip
    
    	if /I "%FileName-DQ%"=="" Set FileName="%CD%"
    	if /I "%FileName-DQ%"=="CD" Set FileName="%CD%"
    	if /I "%FileName-DQ%"=="EXIT" goto :eof
    	if /I "%FileName-DQ%"=="NOEXIT" goto :GetTargetName
    	if DEFINED FileName (
    		Set /a ARGLVL+=1
    		CALL :ARGS %FileName%
    		Set /a ARGLVL-=1
    	)
    	
    goto :GetTargetName
    Last edited by marcorocchini; 16th Jun 2014 at 13:40.
    Quote Quote  
  6. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    That command will list all the values FFProbe will put out for a particular file. All you have to do is add whatever value you're interested in to the FFProbe command line in the original script, assign it to a variable then use an if statement on the variable. It's not rocket science.
    Quote Quote  
  7. mmmm now I spoke with my cat, thank you
    Quote Quote  
  8. for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdubmod\FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,codec_tag_string^,width^,height^,sample_aspect_ratiotream_disposition^=:format_tags^=timecode^,company _name^,product_name^,product_version "%~1" 2^>^&1') DO (
    if "%%~g"=="TAG:company_name" set "T_Company_Name=%%~h"
    if "%%~g"=="TAGroduct_name" set "T_Product_Name=%%~h"
    if "%%~g"=="TAGroduct_version" set "T_Product_Version=%%~h"
    if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h"
    if "%%~g"=="width" set "V_Width=%%~h"
    if "%%~g"=="height" set "V_Height=%%~h"
    if "%%~g"=="sample_aspect_ratio" set "V_PAR=%%~h"
    if "%%~g"=="codec_tag_string" set "codec_tag_string=%%~h"
    if "%%~g"=="codec_type" if "%%~h"=="audio" set /a AUCount+=1
    )
    Quote Quote  
  9. mmm my catcClick image for larger version

Name:	CCAT6.JPG
Views:	247
Size:	20.2 KB
ID:	25779
    Quote Quote  
  10. grr if "%codec_tag_string%"=="YUY2" (CALL : BLACK CATS)
    if "%codec_tag_string%"=="MJPG" (CALL : WHITE BACK CATS)
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!