VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Hi ****
    because ffprobe interlaced_frame and mediainfo is too slow to determine if the video source is progressive or interlaced.

    I wonder if is there a faster way , thanks
    Quote Quote  
  2. Is a second or so too slow?
    Quote Quote  
  3. a second .. but it's too also 1 second
    Quote Quote  
  4. it's enought something that determine if progressive or not, but more quickly. Only detect if the source is flagged as progressive or not
    Last edited by marcorocchini; 6th Oct 2017 at 17:23.
    Quote Quote  
  5. Does this take too long?
    Code:
    Mediainfo.exe --Inform=Video;%%ScanType%% "%~1" > temp.tmp
    set /p scantype=<temp.tmp
    echo Mediainfo reports: scantype=%scantype%
    pause
    Quote Quote  
  6. thank you cat

    I have download mediainfo CLI 0.7.99 64bit: too long? 40 seconds to analyze 168 MXF video files: maybe is not the better but is acceptable
    Quote Quote  
  7. Maybe you should analyze those files using all CPU cores instead of one? Something tells me that you are analyzing those files one by one.
    Quote Quote  
  8. sorry I'm a Cat my english is bad, my brain is bed

    This is the batch that I use, but I'm thinking I'm analyze one by one the original source:

    Code:
    @rem unless otherwise specified for debugging reasons turn echo off
    @if "%EMode%"=="" Set EMode=ON
    @ECHO %EMode%
    @ECHO off   
    
            if exist "%cd%\tempTotale" del /f /q "%cd%\tempTotale"
            if exist "%cd%\tempTotale" rd /s /q "%cd%\tempTotale" /s
    
    SetLocal DisableDelayedExpansion
    
    Set "EXTLIST=*.mxf"
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    
    set "DestFolder=."
    Set "WorkFolder=%DestFolder%"
    
    rem process the arguments one by one
    :ARGS
    color
    	
    	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>
    color
    
    	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
    	rem 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 <FILENAME>
    color
    
            set "V_Q=undef"
            set "TIMECODE=undef"
            set "Frame_Rate=undef"
            set "V_Width=undef"
            set "V_Height=undef"
            set "Frame_Rate=undef"
            set "FULL_HD=0"
    
            for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\core\ffprobe64bit333.exe -hide_banner -loglevel fatal -pretty -select_streams v:0 -show_streams -show_entries stream^=codec_type^,r_frame_rate^,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"=="r_frame_rate" set "Frame_Rate=%%~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 "%%~g"=="codec_long_name" set "codec_long_nameFFprobe=%%~h"
                     	)  
    
            if "%V_Width%"=="" (
    		echo  ERROR: Video Width NOT FOUND!
    		timeout /t 3
    		goto :eof
    	)
    	if "%V_Height%"=="" (
    		echo  ERROR: Video Height NOT FOUND!
    		pause
    		goto :eof
    	)
            if "%Frame_Rate%"=="" (
    		echo  ERROR: Frame_Rate NOT FOUND!
    		)
    	if "%V_PAR%"=="" (
    		echo  ERROR: Video PAR NOT FOUND!
    		pause			)
    
    	if %V_Width% GTR 801 if %V_Height% GTR 609 set "V_Q=HD"
    	if %V_Width% LEQ 800 if %V_Height% LEQ 601 Set "V_Q=SD"
            if "%V_Width%"=="720" if "%V_Height%"=="608" Set "V_Q=XDCAM_IMX"
            if "%V_Width%"=="1920" if "%V_Height%"=="1080" Set "FULL_HD=1"
    
    
     
           	echo "%~1" Using %V_Q% Mode
    	echo  PAR = %V_PAR%
    
            Set "TokenS=0"
            Set "SDorIMX=NO"
            IF "%V_Q%"=="SD" Set "TokenS=1"
            IF "%V_Q%"=="XDCAM_IMX" Set "TokenS=1"
            IF "%TokenS%"=="1" Set "SDorIMX=YES"
            IF "%SDorIMX%"=="" Set "SDorIMX=NO"
            REM echo SDorIMX assume %SDorIMX%
    
            CALL :Make_File_OTHER "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1"
    
    	echo  FATTO
    	echo.
    	echo --------------------------------------------
    	echo.
    	EndLocal
    
    goto :eof
    
    
    :Make_File_Other <VCF_FILENAME> <AVS_FILENAME> <FILENAME> <ORG_FILENAME>
    
            rem *** interlaced or progressive recognize procedure ***************************************
            if exist temp.tmp del temp.tmp
            Set "scantype="
            Set "progressive="
            V:\automazioneclip\MediaInfoCLI64bit\MediaInfo.exe --Inform=Video;%%ScanType%% %4 > temp.tmp
            set /p scantype=<temp.tmp
            if exist temp.tmp del temp.tmp
            if "%scantype%"=="Progressive" set "progressive=1"
            if NOT "%scantype%"=="Progressive" set "progressive=0"
            IF NOT DEFINED scantype set "progressive=1"
            rem *****************************************************************************************
    
    
            Set "codec_nameFFprobe=undef"
            Set "pix_fmtFFprobe=undef"
    
            for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\core\ffprobe64bit333.exe -hide_banner -loglevel fatal -pretty -select_streams v -show_streams -show_entries format^ %4 2^>^&1') DO (
                     if "%%~g"=="codec_name" set "codec_nameFFprobe=%%~h"
                     if "%%~g"=="pix_fmt" set "pix_fmtFFprobe=%%~h"
                     	)  
    
            Set "AudioSource=%4"
    
            Set "eventualeIMXcrop="
            Set "eventualeColorMatrixDicitura="
            Set "eventualeBOB="
            Set "IResizeORlanczos="
            set "eventualeResize="
    
            if "%progressive%"=="1" Set "TrueFalse=false" 
            if NOT "%progressive%"=="1" Set "TrueFalse=true" 
    
            if "%progressive%"=="1" Set "IResizeORlanczos=LanczosResize" 
            if NOT "%progressive%"=="1" Set "IResizeORlanczos=IResize" 
            if NOT "%progressive%"=="1" Set "eventualeBOB=.bob().SelectEven()" 
            IF "%V_Q%"=="XDCAM_IMX" Set "eventualeIMXcrop=.crop^(0,32,0,0^)" 
            IF "%timecode%"=="" Set "timecode=00:00:00:00"
           
            IF NOT "%FULL_HD%"=="1" Set "eventualeResize=.%IResizeORlanczos%^(1920,1080)" 
            if exist "eventualeColorMatrixDicitura.txt" del "eventualeColorMatrixDicitura.txt"
    
    
            set "eventualeConvertToYUY2="
            if not "%pix_fmtFFprobe%"=="yuv422p" IF NOT "%codec_nameFFprobe%"=="dvvideo" set "eventualeConvertToYUY2=.ConvertToYUY2^(interlaced=%truefalse%^)"
         
            Set "eventualeColorMatrixDicitura="
            IF NOT "%V_Q%"=="HD" echo .colorMatrix(mode="Rec.601->Rec.709")>eventualeColorMatrixDicitura.txt
            IF NOT "%V_Q%"=="HD" set /p eventualeColorMatrixDicitura=<eventualeColorMatrixDicitura.txt
            IF NOT "%V_Q%"=="HD" echo eventualeColorMatrixDicitura assume %eventualeColorMatrixDicitura%
            if exist "eventualeColorMatrixDicitura.txt" del "eventualeColorMatrixDicitura.txt"
    
            Set "eventualeScanBottom="
            IF "%codec_nameFFprobe%"=="dvvideo" set "eventualeScanBottom=.convertToYUY2^().Crop^(0,1,0,0).AddBorders^(0,0,0,1)"
            set "fps25forOffset=fps=25,"
    
            for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\core\ffprobe64bit333.exe -hide_banner -loglevel fatal -pretty -select_streams a -show_streams %4 2^>^&1') DO (
            if "%%~g"=="index" set "audioIndexID=%%~h")
    
            Set "streamIndexNumber=undef"
            if "%NoAudioInsideInputFile%"=="1" Set "streamIndexNumber=0"
            if not "%NoAudioInsideInputFile%"=="1" Set "streamIndexNumber=1"
            IF "%AudioProc1%"=="true" Set streamIndexNumber=%audioIndexID%  
    
            Set "eventualeSmoothFPS2dicitura="
            if NOT "%Frame_Rate%"=="25/1" echo .yadif(1,1).SmoothFPS2(50000,1000).AssumeTFF().SeparateFields().SelectEvery(4,0,3).Weave()>eventualeSmoothFPS2dicitura.txt
            if NOT "%Frame_Rate%"=="25/1" set /p eventualeSmoothFPS2dicitura=<eventualeSmoothFPS2dicitura.txt
            if NOT "%Frame_Rate%"=="25/1" echo eventualeSmoothFPS2dicitura assume %eventualeSmoothFPS2dicitura%
            if exist eventualeSmoothFPS2dicitura.txt del eventualeSmoothFPS2dicitura.txt
    
            if not exist tempTotale md tempTotale
    
    rem echo V_Q assume %V_Q%
    rem echo audiosource assume %AudioSource%
    rem echo streamIndexNumber assume %streamIndexNumber%
    rem echo V_PAR assume %V_PAR%
    rem echo interlacedORprogressiveFFprobe assume %interlacedORprogressiveFFprobe%
    rem echo progressive assume %progressive%
    rem echo eventualeIMXcrop assume %eventualeIMXcrop%
    rem echo FULL_HD assume %FULL_HD% e eventualeResize assume %eventualeResize%
    
            rem ***Make The .avs Script File ************************************************************************************************************
                  
            echo Import^("v:\automazioneclip\avisynth\plugins\IResize.avsi"^)>"%cd%\tempTotale\%~n1.avs"
            echo LoadPlugin^("v:\automazioneclip\AviSynth\Lsmash64perVirtualDub64\LSMASHSource.dll"^)>>"%cd%\tempTotale\%~n1.avs"
            echo LoadCPlugin("v:\automazioneclip\avisynth\plugins64\yadif.dll")>>"%cd%\tempTotale\%~n1.avs"
            echo vid=LWLibavVideoSource^(%4^)%eventualeIMXcrop%%eventualeScanBottom%%eventualeResize%%eventualeColorMatrixDicitura%%eventualeConvertToYUY2%%eventualeSmoothFPS2dicitura%>>"%cd%\tempTotale\%~n1.avs"
            echo aud=LWLibavAudioSource^(%4^, stream_index=%streamIndexNumber%^)>>"%cd%\tempTotale\%~n1.avs"
    
            IF "%V_Q%"=="HD" echo left=LWLibavAudioSource^(%4, stream_index=1^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="HD" echo right=LWLibavAudioSource^(%4, stream_index=2^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="HD" echo both=mergechannels^(left^, right^)>>"%cd%\tempTotale\%~n1.avs"
    
            IF "%V_Q%"=="SD" echo left=LWLibavAudioSource^(%4, stream_index=1^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="SD" echo right=LWLibavAudioSource^(%4, stream_index=2^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="SD" echo both=mergechannels^(left^, right^)>>"%cd%\tempTotale\%~n1.avs"
    
            IF "%V_Q%"=="XDCAM_IMX" echo left=GetChannel^(aud, 1^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="XDCAM_IMX" echo right=GetChannel^(aud, 2^)>>"%cd%\tempTotale\%~n1.avs"
            IF "%V_Q%"=="XDCAM_IMX" echo both=mergechannels^(left^, right^)>>"%cd%\tempTotale\%~n1.avs"
    
    
            echo audiodub^(vid^, both^)>>"%cd%\tempTotale\%~n1.avs"
    
            echo ConvertAudioTo16Bit^(^)>>"%cd%\tempTotale\%~n1.avs"   
            
           
            rem ******************************************************************************************************************************************
            if exist "%cd%\tempTotale\concatList.txt" del "%cd%\tempTotale\concatList.txt"
    
    
            Set "nonCompleteMXFtoAVS=0"
            Set "CompleteMXFtoAVS=0"
            for %%a in ("*.mxf") do if not exist "%cd%\tempTotale\%%~na.avs" set "nonCompleteMXFtoAVS=1"  
            if "%nonCompleteMXFtoAVS%"=="1" set "CompleteMXFtoAVS=0"
            if "%nonCompleteMXFtoAVS%"=="0" set "CompleteMXFtoAVS=1"
     
            if "%CompleteMXFtoAVS%"=="1" for %%f in ("%cd%\tempTotale\*.avs") do echo file '%%f' >> "%cd%\tempTotale\concatList.txt"
            rem if "%CompleteMXFtoAVS%"=="1" v:\automazioneclip\core\ffmpeg64bit2014.exe -threads 12 -y -f concat -i "%cd%\tempTotale\concatList.txt" -vf scale=interl=1,format=pix_fmts=yuv420p -c:v libx264 -profile:v main -level:v 4.1 -g 33 -bf 2 -crf 23 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 "%cd%\totaleAvisynthHelp.mp4"
            if "%CompleteMXFtoAVS%"=="1" v:\automazioneclip\core\ffmpeg64bit2014.exe -threads 12 -y -f concat -i "%cd%\tempTotale\concatList.txt" -vf scale=interl=1,format=pix_fmts=yuv420p -c:v libx264 -profile:v main -level:v 4.1 -x264-params me_range=4:subme=1:rc_lookahead=1:chroma_qp_offset=0:8x8dct=1 -g 100 -bf 2 -crf 23 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 "%cd%\totaleAvisynthHelpVeloce.mp4"
    
            rem if "%CompleteMXFtoAVS%"=="1" v:\automazioneclip\core\ffmpeg64bit2014.exe -y -threads 12 -f concat -i "%cd%\tempTotale\concatList.txt" -af "pan=stereo:c0=c0:c1=c1" -vn -c:a ac3 -b:a 512k -ar 48000 -aspect 16:9 tempAUDIO.mp4
            rem if "%CompleteMXFtoAVS%"=="1" v:\automazioneclip\core\ffmpeg64bit2014.exe -y -threads 12 -y -f concat -i "%cd%\tempTotale\concatList.txt" -vf scale=interl=1,format=pix_fmts=yuv420p -c:v rawvideo -an -f rawvideo - |  V:\automazioneclip\core\QSVenc262\x64\QSVEncC64.exe --input-res 1920x1080 --fps 25 --raw -i - --codec h264 --tff --cbr 8000 --bframes 2 -o "%cd%\total.h264"
            rem if "%CompleteMXFtoAVS%"=="1" v:\automazioneclip\core\MP4Box\mp4box.exe -fps 25.000000 -add "total.H264#video:name=Video" -add "tempAUDIO.mp4#audio:name=Audio" -new "%cd%\totale.mp4"
            rem if "%CompleteMXFtoAVS%"=="1" if exist total.h264 del total.h264
            rem if "%CompleteMXFtoAVS%"=="1" if exist tempAUDIO.mp4 del tempAUDIO.mp4
            if "%CompleteMXFtoAVS%"=="1" if exist *.lwi del *.lwi 
            if "%CompleteMXFtoAVS%"=="1" if exist tempTotale del /f /q tempTotale
            if "%CompleteMXFtoAVS%"=="1" rd /s /q temptotale /s
    
            if "%CompleteMXFtoAVS%"=="1" exit
    
    goto :eof
    
    :GetTargetName
    color
    
    	Set "FileName="
    	Set /p FileName=InputFileName .mxf or 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
    color
    
    	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
    Quote Quote  
  9. All that just to tell if a video is interlaced? To check if it was encoded as interlaced, open it with MediaInfo. To check if it is actually interlaced, play it using a player without its deinterlacer turned on.
    Quote Quote  
  10. no it serve to encode all mxf to mp4-h264, pre-analizyng the source resolution, framerate, colorspace and scantype. The scantype routine is in blue, but is a little slow
    Quote Quote  
  11. You already call ffprobe and later on mediainfo as well that slowes you down. So can FFprobe give you interlace or progressive scan order? I think that was the reason why I picked mediainfo in my scripts. If ffprobe could do it, just find out that scanorder right away, no delay then. But I think ffprobe cannot do that. I could be wrong it is some years back I was in it. It might be added on since then or I did not look deep enough.
    Quote Quote  
  12. Image
    [Attachment 43309 - Click to enlarge]


    Code:
    rem *** interlaced or progressive FFPROBE recognize routine *****************************************
            Set "progressive="
            set "interlacedORprogressiveFFprobe="
            for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\core\ffprobe64bit333.exe -hide_banner -loglevel fatal -pretty -select_streams v -show_entries "frame=interlaced_frame" %4 2^>^&1') DO (
            if "%%~g"=="interlaced_frame" set "interlacedORprogressiveFFprobe=%%~h")
            if "%interlacedORprogressiveFFprobe%"=="0" set "progressive=1"
            if "%interlacedORprogressiveFFprobe%"=="1" set "progressive=0"
            echo progressive assume %progressive%
            rem *****************************************************************************************
    
            rem *** interlaced or progressive MediaInfo recognize routine *****************************************
        rem if exist temp.tmp del temp.tmp
        rem Set "scantype="
        rem Set "progressive="
        rem V:\automazioneclip\MediaInfoCLI64bit\MediaInfo.exe --Inform=Video;%%ScanType%% %4 > temp.tmp
        rem set /p scantype=<temp.tmp
        rem if exist temp.tmp del temp.tmp
        rem if "%scantype%"=="Progressive" set "progressive=1"
        rem if NOT "%scantype%"=="Progressive" set "progressive=0"
        rem IF NOT DEFINED scantype set "progressive=1"
            rem *****************************************************************************************
    processing 115 mxf files one time using ffprobe and one time (removing the rem and put rem on the ffprobe routine) using mediainfo:

    ffprobe: 07 minutes and 57 seconds
    mediainfo: 00 minutes and 25 seconds
    Quote Quote  
  13. and mediainfo 32bit: 00 minutes 36 seconds
    Quote Quote  
  14. ok,ffprobe checks every frame or something
    https://github.com/MediaBrowser/Emby/issues/68
    mediainfo just reads one value, does not check anything, so if checking a camcorder footage, it is always accurate, as long as camcorder flags it properly
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!