VideoHelp Forum




+ Reply to Thread
Results 1 to 19 of 19
  1. Hi cats, please can you tell me if I can change the script so that the batch recognize if source is TFF or BFF?

    thanks








    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\MMIJG32.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpegSD.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\x264VFW.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\pvmjpg40.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\MMIJG30.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\lcodccmp2.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpSD.INI c:\windows
    xcopy /y v:\automazioneclip\system\morgan\m3jpHD.ini c:\windows
    
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\m3jpegHD.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\MMIJG32.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\m3jpegSD.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\MMIJG30.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\lcodccmp2.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\x264VFW.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\pvmjpg40.dll c:\windows\SysWOW64
    
    md c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\wavdest.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SamplesDropper.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SP_audio.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\dv_grabber.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SP_video.ocx c:\windows\spvideo
    
    regsvr32 /s c:\windows\spvideo\wavdest.ocx
    regsvr32 /s c:\windows\spvideo\SamplesDropper.ocx
    regsvr32 /s c:\windows\spvideo\SP_audio.ocx
    regsvr32 /s c:\windows\spvideo\dv_grabber.ocx
    regsvr32 /s c:\windows\spvideo\SP_video.ocx
    
    regedit /s v:\automazioneclip\system\VDreg.reg
    regedit /s v:\automazioneclip\system\PICreg.reg
    regedit /s v:\automazioneclip\system\drivers.reg
    del v:\automazioneclip\output\temp.avi
    del v:\automazioneclip\output\temp.wav
    
    cls
    
    SetLocal DisableDelayedExpansion
    
    Set "EXTLIST=*.*
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    Set VD_LOC="v:\automazioneclip\VirtualDub\vdub.exe"
    
    set "DestFolder=."
    Set "WorkFolder=%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 <FILENAME>
    
    	Set /a Count+=1
    	Set "FOUNDLVL=%STARTLVL%"
    	SetLocal DisableDelayedExpansion
            if exist "%~dpn1.wav" (
            set "Audio=%~dpn1.wav"
            ) else (
            set "Audio=v:\automazioneclip\system\empty.wav")
            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 -select_streams v:0 -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 "%V_Width%"=="" (
    		echo  ERROR: Video Width NOT FOUND!
    		pause
    		goto :eof
    	)
    	if "%V_Height%"=="" (
    		echo  ERROR: Video Height NOT FOUND!
    		pause
    		goto :eof
    	)
            if "%Frame_Rate%"=="" (
    		echo  ERROR: Frame_Rate 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%
            echo  Frame_Rate = %Frame_Rate%
    	if "%TimeCode%"=="" echo Warning! no TimeCode Found!
    	if NOT "%TimeCode%"=="" echo Timecode= %TIMECODE%
    
    
    CALL :Make_File "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1"
    
    
    	echo  FATTO
    	echo.
    	echo ---------------------------------------------
    	echo.
    	EndLocal
    	
    goto :eof
    
    
    :Make_File <VCF_FILENAME> <AVS_FILENAME> <FILENAME> <ORG_FILENAME>
    
            rem *** TRY extract audio from .MXF IMX SD FILE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (if "%V_Width%"=="720" (v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i %4 -map_channel 0.1.0 -map_channel 0.1.1 -af "volume=volume=9dB:precision=fixed" "%DestFolder%\%~n1.wav"))
            If "%TokenS%"=="1" (if "%V_Width%"=="720" (v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i %4 -map_channel 0.1.2 -map_channel 0.1.3 -af "volume=volume=9dB:precision=fixed" "%DestFolder%\%~n1ch3ch4.wav"))
    
            rem *** TRY extract audio from .MXF XDCAM-HD 4:2:2 FILE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (if "%V_Width%"=="1920" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] [0:2] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav"))
            If "%TokenS%"=="1" (if "%V_Width%"=="1920" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:3] [0:4] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1ch3ch4.wav")) 
    
            rem *** TRY extract audio from .MXF OTHER TYPE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] [0:2] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:3] [0:4] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1ch3ch4.wav")   
    
            rem *** TRY extract audio from GOPRO MP4 file ***
            Set "TokenS=0"
            IF "%~x4"==".MP4" Set "TokenS=1" 
            IF "%~x4"==".mp4" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
    
            rem *** TRY extract audio from .MP4 OTHER TYPE ***
            Set "TokenS=0"
            IF "%~x4"==".MP4" Set "TokenS=1" 
            IF "%~x4"==".mp4" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:0] volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
                            
            echo *** from various format to MorganMJPEG AVI SD 720x576i@25fps ***
         	
            rem ***Make The .vcf Script File***
    	echo VirtualDub.audio.SetSource^(0^)^;>%1
    	echo VirtualDub.audio.SetMode^(0^)^;>>%1
    	echo VirtualDub.audio.SetInterleave^(1,500,1,0,0^)^;>>%1
    	echo VirtualDub.audio.SetClipMode^(1,1^)^;>>%1
    	echo VirtualDub.audio.SetEditMode^(1^)^;>>%1
    	echo VirtualDub.audio.SetConversion^(0,0,0,0,0^)^;>>%1
    	echo VirtualDub.audio.SetVolume^(^)^;>>%1
    	echo VirtualDub.audio.SetCompression^(^)^;>>%1
    	echo VirtualDub.audio.EnableFilterGraph^(0^)^;>>%1
    	echo VirtualDub.video.SetInputFormat^(11^)^;>>%1
    	echo VirtualDub.video.SetOutputFormat^(11^)^;>>%1
    	echo VirtualDub.video.SetMode^(1^)^;>>%1
    	echo VirtualDub.video.SetSmartRendering^(0^)^;>>%1
    	echo VirtualDub.video.SetPreserveEmptyFrames^(0^)^;>>%1
    	echo VirtualDub.video.SetFrameRate2^(0,0,1^)^;>>%1
    	echo VirtualDub.video.SetIVTC^(0, 0, 0, 0^)^;>>%1
    	echo VirtualDub.video.SetCompression^(0x6a6d7674,0,10000,0^)^;>>%1
    	echo VirtualDub.video.SetCompData^(28,"TUpQRxgAAAAAAAAAAgAAAAgAAAACAAAAAQAAAA=="^)^;>>%1
    	echo VirtualDub.video.filters.Clear^(^)^;>>%1
            echo VirtualDub.audio.filters.Clear^(^);>>%1
    	echo VirtualDub.SaveAVI^("%DestFolder%\\%~n1_SD.avi"^)^;>>%1
    	echo VirtualDub.Close^(^)^;>>%1
    
            rem ***Make The .avs Script File***
          
            echo FFVideoSource^(%4^)>%2
            echo ConvertToYUY2^(interlaced=true^)>>%2
            echo src = last >>%2
            echo src = src.width==720^&^&src.height==608?src.crop^(0,32,0,0^):src >>%2
    
            echo src = src.width^>720 ^|^| src.height^>608?src.ColorMatrix^(mode="Rec.709->Rec.601"^): src >>%2
            echo src = src.width!=720 ^|^| src.height!=576 ? src.IResize^(720,576^): src >>%2
    
            echo function IResize^(clip Clip, int NewWidth, int NewHeight^) {>>%2
            echo Clip>>%2
            echo SeparateFields^(^)>>%2
            echo Shift=^(GetParity() ? -0.25 : 0.25) * ^(Height()/Float(NewHeight/2)^-1.0^)>>%2
            echo E  = SelectEven^(^).Spline36resize^(NewWidth, NewHeight/2, 0,    Shift^)>>%2
            echo O  = SelectOdd^( ^).Spline36resize^(NewWidth, NewHeight/2, 0,   -Shift^)>>%2
            echo Ec = SelectEven^( ^).Spline36resize^(NewWidth, NewHeight/2, 0,  2*Shift^)>>%2
            echo Oc = SelectOdd^( ^).Spline36resize^(NewWidth, NewHeight/2, 0, -2*shift^)>>%2
            echo Interleave^(E, O^)>>%2
            echo IsYV12^(^) ? MergeChroma^(Interleave(Ec, Oc)^) : Last >>%2
            echo Weave^(^)>>%2
            echo } >>%2
            echo AssumeTFF^(^)>>%2
            echo SeparateFields^(^)>>%2
            echo Ev=SelectEven^(^).sharpen(0.20^)>>%2
            echo Od=SelectOdd^(^).sharpen^(0.20^)>>%2
            echo Interleave^(Ev,Od^)>>%2
            echo Weave^(^)>>%2
            echo src.framerate^<26 ? src:src.AssumeTFF^(^).SeparateFields^(^).SelectEvery^(4,0,3^).Weave^(^) >>%2
            echo AssumeFPS^(25^)>>%2
            echo ChangeFPS^(25^)>>%2
            
            echo processing source file %4
        
            rem ***Call VirtualDub***
    	if NOT EXIST %VD_LOC% (
    		echo  Um, where the hell is VirtualDubMod?
    		pause
    	)
    	
            %VD_LOC% /min %2 /s %1
        	
           
    	for %%v in ("%DestFolder%\\%~n1_SD.avi") do (
    		if %%~zv LSS 128 (
    			echo  ERROR!!!  Extra Small File Size Detected!!!
    			pause
    		)
    	)
           
            v:\automazioneclip\virtualdub\cfourcc.exe -i "%CD%\%~n1_SD.avi" -u MJPG -d MJPG
          
            DEL %DestFolder%\*.ffindex
            DEL %DestFolder%\*.VCF
            
            goto :eof
    
    :GetTargetName
    
    	Set "FileName="
    	Set /p FileName=InputFileName .mxf .mp4 or .avi 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
    
    	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  
  2. Depends on what you mean - it impossible to accurately determine actual field order of the content - you have to use your eyes, human intervention

    For example, you can have TFF encoded as BFF, or TFF, or progressive. You can have BFF content encoded as BFF or TFF or proressive

    i.e. there can be a difference between content field order, and encoding field order
    Quote Quote  
  3. mmm my cats is nice cats....

    for "field order" I mean what I see in the mediainfo: for example I have a .mxf file in dvcam quality that mediainfo say:

    General
    Complete name : C:\f335\DVcamF335_2.mxf
    Format : MXF
    Commercial name : DV
    Format profile : OP-1a
    Format settings : Closed / Complete
    File size : 40.6 MiB
    Duration : 10s 560ms
    Overall bit rate : 32.3 Mbps
    Encoded date : 2014-09-19 11:54:18.000
    Writing application : SONY Opt 1.40
    Writing library : SONY Opt 1.40

    Video
    ID : 2
    Format : DV
    Format_Settings_Wrapping : Frame
    Codec ID : 0D01030102020201-0401020202010200
    Duration : 10s 560ms
    Bit rate mode : Constant
    Bit rate : 24.4 Mbps
    Encoded bit rate : 28.8 Mbps
    Width : 720 pixels
    Height : 576 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 25.000 fps
    Standard : PAL
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Interlaced
    Scan order : Bottom Field First
    Compression mode : Lossy
    Bits/(Pixel*Frame) : 2.357
    Time code of first frame : 17:07:58:24
    Time code source : Subcode time code
    Stream size : 30.8 MiB (76%)
    Encoded stream size : 36.3 MiB (89%)

    Other #1
    ID : 1
    Type : Time code
    Format : MXF TC
    Time code of first frame : 17:07:58:24
    Time code settings : Striped

    Other #2
    Type : Time code
    Format : SMPTE TC
    Muxing mode : SDTI
    Time code of first frame : 17:07:58:24

    Now I would like detect, possibly with ffprobe this scan order, and set the avisynth script so that use the ReverseFieldOrder() plugin ^^
    Quote Quote  
  4. But that might be incorrect. I can show you examples that "say" TFF in mediainfo but are actually BFF , others that "say" BFF , but are actually TFF . Others that say "progressive", but are TFF or BFF. ie. Mediainfo is reporting the encoded field order, this is not necessarily the ACTUAL field order of the content. The only way to determine that accurately is with your eyes

    Anyways, I don't see how ffprobe can pass field order information on anyways, even if it passes on incorrect or correct information

    Unless your source is ALWAYS from a DV cam, or always from some known source...with know field order. Then you can just assume BFF or whatever it supposed to be. But then you wouldn't need a conditional
    Quote Quote  
  5. ffprobe -i input.ext -show_frames will give you some info like this for each frame


    [FRAME]
    media_type=video
    key_frame=1
    pkt_pts=224
    pkt_pts_time=7.474133
    pkt_dts=224
    pkt_dts_time=7.474133
    best_effort_timestamp=224
    best_effort_timestamp_time=7.474133
    pkt_duration=1
    pkt_duration_time=0.033367
    pkt_pos=28114440
    pkt_size=120000
    width=720
    height=480
    pix_fmt=yuv411p
    sample_aspect_ratio=8:9
    pict_type=I
    coded_picture_number=0
    display_picture_number=0
    interlaced_frame=1
    top_field_first=0
    repeat_pict=0
    [/FRAME]
    top_field_first=0 is the key that means BFF. =1 would mean TFF. But it isn't always accurate. It reports the encoded field order, which isn't always the same as the content field order. The content field order is the important one, and can only be determined with your eyes, not ffprobe or mediainfo etc... So if you don't mind possible errors, you would have to somehow use that in your script
    Quote Quote  
  6. mmmm whats a cat

    poison please can ffproble retrive the specific information Codec ID : 0D01030102020201-0401020202010200 ?

    this is specific of .mxf and DVCAM/mode of the sony pdw-f800 cameras: in this way I'm shure to don't mistake
    Quote Quote  
  7. How many different sources do you have ? Seems to be more trouble doing this way

    Try ffprobe -i input.ext, and some metadata will be returned like uid's. I don't know if it's the one you want . Or can you use mediainfo cli in your batch ?
    Quote Quote  
  8. But if you only have IMX TFF, and DVCam BFF sources, straight from the camera - then you can use ffprobe to distinguish between them with ffprobe's top_field_first=1 or 0, respectively. Those two have encoded field orders which match the content field order. It's "other" sources that might cause problems e.g. if you get some random interlaced SD file from someone else, and you don't know the workflow history
    Quote Quote  
  9. the pdw-f800 pdw-f335 and many other models of sony do this mess: record alwais in .mxf files but dvcam .mxf files are recorded in BFF meanwhile IMX and XDCAMHD422 are recorded in TFF, strange but true

    so when I transcode with avisynth, each time I have to detect this condition, at least on the .mxf-dvcam mode, and apply the ReverseFieldOrder() to avoiding the mess

    I think codec id is specific only of this type of .mxf files, so the batch apply the ReverseFieldOrder() only on .mxf dvcam files.. I think
    Quote Quote  
  10. But at least files directly from camera are consistent. Their encoded field order matches their actual content field order. ie. you can use ffprobe or mediainfo and it will be correct (most of the time)

    And by convention, DV is always BFF, HD is always TFF. So it's expected

    Why do you have to swap field order in the first place ? It doesn't matter TFF or BFF, so as long as it's done properly and flagged
    Quote Quote  
  11. Originally Posted by poisondeathray View Post
    Or can you use mediainfo cli in your batch ?
    mm maybe yes but is a little complicated
    Quote Quote  
  12. Do you have a small sample of dvcam mxf ? I have samples of your other files somewhere, but not dvcam
    Quote Quote  
  13. Originally Posted by poisondeathray View Post

    Why do you have to swap field order in the first place ? It doesn't matter TFF or BFF, so as long as it's done properly and flagged
    to pass SD video in matrox digisuite hardware
    Quote Quote  
  14. Originally Posted by poisondeathray View Post
    Do you have a small sample of dvcam mxf ? I have samples of your other files somewhere, but not dvcam
    yes ^^ I'm uploading

    is this

    https://www.dropbox.com/s/4lgctkdw78lko4g/dvcam.MXF?dl=0

    seems ffprobe don't wont show codec_id
    Last edited by marcorocchini; 20th Sep 2014 at 15:53.
    Quote Quote  
  15. Originally Posted by marcorocchini View Post
    Originally Posted by poisondeathray View Post
    Or can you use mediainfo cli in your batch ?
    mm maybe yes but is a little complicated
    btw, it is not, but if you use ffprobe already, sure, you should be consistent with that
    (using this mediainfo)
    Code:
    if exist  "%temp_folder%\mediainfo.txt" del "%temp_folder%\mediainfo.txt"
    "%mediainfo%" %1 dumpinfo:"%temp_folder%\unicodefile.txt"
    REM unicode have to be changed to ascii, type command does that
    TYPE "%temp_folder%\unicodefile.txt" > "%temp_folder%\mediainfo.txt"
    findstr /c:"Scan order                               : Bottom Field First"  "%temp_folder%\mediainfo.txt" >nul
      if %ERRORLEVEL%==0 SET field_order=bff
    findstr /c:"Scan order                               : Top Field First"     "%temp_folder%\mediainfo.txt" >nul
      if %ERRORLEVEL%==0 SET field_order=tff
    findstr /c:"Scan type                                : Progressive"         "%temp_folder%\mediainfo.txt" >nul
      if %ERRORLEVEL%==0 SET field_order=none
    Last edited by _Al_; 20th Sep 2014 at 16:01.
    Quote Quote  
  16. You can still distinguish it in avisynth if you use FFMS2 . It distinguishes and reports field order correctly and distinguishes between IMX and DVCam

    To check you just use info()

    So

    FFVideoSource("dvcam.mxf")
    Info()

    or
    FFVideoSource("imx.mxf")
    Info()

    The parity is distinguised correctly in this case (BFF vs TFF)

    So you can use if/then in avisynth. This is saying if reported field order is TFF, then return src, otherwise swap field order of src


    Code:
    
    src = last
    
    filtered = src.getparity==true ? src : src.separatefields().trim(1,0).weave()
    
    filtered
    In this example, i swapped field order with separatefields.trim(1,0).weave(), this leaves you with 1 less field - But there are other methods you can use. Some insert a blank/black field. But there is no "perfect" way swap field order, all methods have drawbacks

    So again this only works in this case of these two file types (other files, other cameras, other workflows might not have parity detected correctly with ffms2 or other source filters )
    Quote Quote  
  17. And another way you might be able to distinguish it in ffprobe is -pix_fmt

    IMX50 will be yuv422p, DVCam will be yuv420p
    Quote Quote  
  18. mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm^^
    Click image for larger version

Name:	CCAT5a.jpg
Views:	204
Size:	273.1 KB
ID:	27587
    Quote Quote  
  19. thanks, because I put on the batch encoder varioius format (mp4, avi ecc..) that I'm not shure of the BFF/TFF tags, for the moment I have to filter only .mxf dvcam that have as codec_id "0D01030102020201-0401020202010200"

    I have download mediainfo cli dll ver. 0.7.70.0

    and the ReverseFieldDominance.dll: https://www.dropbox.com/s/updh4bjm2cg53ki/ReverseFieldDominance.dll?dl=0

    and modify the batch so:


    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\MMIJG32.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpegSD.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\x264VFW.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\pvmjpg40.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\MMIJG30.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\lcodccmp2.dll c:\windows\system32
    xcopy /y v:\automazioneclip\system\morgan\m3jpSD.INI c:\windows
    xcopy /y v:\automazioneclip\system\morgan\m3jpHD.ini c:\windows
    
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\m3jpegHD.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\MMIJG32.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\m3jpegSD.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\morgan\MMIJG30.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\lcodccmp2.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\x264VFW.dll c:\windows\SysWOW64
    if exist c:\windows\SysWOW64 xcopy /y v:\automazioneclip\system\pvmjpg40.dll c:\windows\SysWOW64
    
    md c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\wavdest.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SamplesDropper.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SP_audio.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\dv_grabber.ocx c:\windows\spvideo
    xcopy /y v:\automazioneclip\system\SP_video.ocx c:\windows\spvideo
    
    regsvr32 /s c:\windows\spvideo\wavdest.ocx
    regsvr32 /s c:\windows\spvideo\SamplesDropper.ocx
    regsvr32 /s c:\windows\spvideo\SP_audio.ocx
    regsvr32 /s c:\windows\spvideo\dv_grabber.ocx
    regsvr32 /s c:\windows\spvideo\SP_video.ocx
    
    regedit /s v:\automazioneclip\system\VDreg.reg
    regedit /s v:\automazioneclip\system\PICreg.reg
    regedit /s v:\automazioneclip\system\drivers.reg
    
    cls
    
    SetLocal DisableDelayedExpansion
    
    Set "EXTLIST=*.*"
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    Set VD_LOC="v:\automazioneclip\VirtualDub\vdub.exe"
    
    set "DestFolder=."
    Set "WorkFolder=%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 <FILENAME>
    
    	Set /a Count+=1
    	Set "FOUNDLVL=%STARTLVL%"
    	SetLocal DisableDelayedExpansion
            if exist "%~dpn1.wav" (
            set "Audio=%~dpn1.wav"
            ) else (
            set "Audio=v:\automazioneclip\system\empty.wav")
            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%
    
            v:\automazioneclip\virtualdub\mediainfo.exe "%CD%\%~n1.mxf" dumpinfo:unicodefile.txt
            TYPE unicodefile.txt>ascii.txt
            ren ascii.txt mediainfo.txt 
            findstr /c:"Codec ID                                 : 0D01030102020201-0401020202010200" "mediainfo.txt"
            IF NOT ERRORLEVEL 1 (set "dvcam=1")
    
    
    CALL :Make_File "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1"
    
    
    	echo  FATTO
    	echo.
    	echo ---------------------------------------------
    	echo.
    	EndLocal
    	
    goto :eof
    
    
    :Make_File <VCF_FILENAME> <AVS_FILENAME> <FILENAME> <ORG_FILENAME>
    
            rem *** TRY extract audio from .MXF IMX SD FILE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (if "%V_Width%"=="720" (v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i %4 -map_channel 0.1.0 -map_channel 0.1.1 -af "volume=volume=9dB:precision=fixed" "%DestFolder%\%~n1.wav"))
            If "%TokenS%"=="1" (if "%V_Width%"=="720" (v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i %4 -map_channel 0.1.2 -map_channel 0.1.3 -af "volume=volume=9dB:precision=fixed" "%DestFolder%\%~n1ch3ch4.wav"))
    
            rem *** TRY extract audio from .MXF XDCAM-HD 4:2:2 FILE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (if "%V_Width%"=="1920" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] [0:2] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav"))
            If "%TokenS%"=="1" (if "%V_Width%"=="1920" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:3] [0:4] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1ch3ch4.wav")) 
    
            rem *** TRY extract audio from .MXF OTHER TYPE ***
            Set "TokenS=0"
            IF "%~x4"==".MXF" Set "TokenS=1" 
            IF "%~x4"==".mxf" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] [0:2] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:3] [0:4] amerge,volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1ch3ch4.wav")   
    
            rem *** TRY extract audio from GOPRO MP4 file ***
            Set "TokenS=0"
            IF "%~x4"==".MP4" Set "TokenS=1" 
            IF "%~x4"==".mp4" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:1] volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
    
            rem *** TRY extract audio from .MP4 OTHER TYPE ***
            Set "TokenS=0"
            IF "%~x4"==".MP4" Set "TokenS=1" 
            IF "%~x4"==".mp4" Set "TokenS=1"
            If "%TokenS%"=="1" (v:\automazioneclip\core\ffmpeg.exe  -y -i %4 -filter_complex "[0:0] volume=1.5" -c:a pcm_s16le "%DestFolder%\%~n1.wav")
                            
            echo *** from various format to MorganMJPEG AVI SD 720x576i@25fps ***
         	
            rem ***Make The .vcf Script File***
    	echo VirtualDub.audio.SetSource^(0^)^;>%1
    	echo VirtualDub.audio.SetMode^(0^)^;>>%1
    	echo VirtualDub.audio.SetInterleave^(1,500,1,0,0^)^;>>%1
    	echo VirtualDub.audio.SetClipMode^(1,1^)^;>>%1
    	echo VirtualDub.audio.SetEditMode^(1^)^;>>%1
    	echo VirtualDub.audio.SetConversion^(0,0,0,0,0^)^;>>%1
    	echo VirtualDub.audio.SetVolume^(^)^;>>%1
    	echo VirtualDub.audio.SetCompression^(^)^;>>%1
    	echo VirtualDub.audio.EnableFilterGraph^(0^)^;>>%1
    	echo VirtualDub.video.SetInputFormat^(11^)^;>>%1
    	echo VirtualDub.video.SetOutputFormat^(11^)^;>>%1
    	echo VirtualDub.video.SetMode^(1^)^;>>%1
    	echo VirtualDub.video.SetSmartRendering^(0^)^;>>%1
    	echo VirtualDub.video.SetPreserveEmptyFrames^(0^)^;>>%1
    	echo VirtualDub.video.SetFrameRate2^(0,0,1^)^;>>%1
    	echo VirtualDub.video.SetIVTC^(0, 0, 0, 0^)^;>>%1
    	echo VirtualDub.video.SetCompression^(0x6a6d7674,0,10000,0^)^;>>%1
    	echo VirtualDub.video.SetCompData^(28,"TUpQRxgAAAAAAAAAAgAAAAgAAAACAAAAAQAAAA=="^)^;>>%1
    	echo VirtualDub.video.filters.Clear^(^)^;>>%1
            echo VirtualDub.audio.filters.Clear^(^);>>%1
            if NOT "%TimeCode%"=="" echo VirtualDub.project.ClearTextInfo^(^)^;>>%1
            if NOT "%TimeCode%"=="" echo VirtualDub.project.AddTextInfo^("ISMP", "%TIMECODE%"^)^;>>%1
    	echo VirtualDub.SaveAVI^("%DestFolder%\\%~n1_SD.avi"^)^;>>%1
    	echo VirtualDub.Close^(^)^;>>%1
    
            rem ***Make The .avs Script File***
          
            echo FFVideoSource^(%4^)>%2
            echo ConvertToYUY2^(interlaced=true^)>>%2
            if "%dvcam%"=="1" echo ReverseFieldDominance^(^)>>%2
            echo src = last >>%2
            echo src = src.width==720^&^&src.height==608?src.crop^(0,32,0,0^):src >>%2
    
            echo src = src.width^>720 ^|^| src.height^>608?src.ColorMatrix^(mode="Rec.709->Rec.601"^): src >>%2
            echo src = src.width!=720 ^|^| src.height!=576 ? src.IResize^(720,576^): src >>%2
    
            echo function IResize^(clip Clip, int NewWidth, int NewHeight^) {>>%2
            echo Clip>>%2
            echo SeparateFields^(^)>>%2
            echo Shift=^(GetParity() ? -0.25 : 0.25) * ^(Height()/Float(NewHeight/2)^-1.0^)>>%2
            echo E  = SelectEven^(^).Spline36resize^(NewWidth, NewHeight/2, 0,    Shift^)>>%2
            echo O  = SelectOdd^( ^).Spline36resize^(NewWidth, NewHeight/2, 0,   -Shift^)>>%2
            echo Ec = SelectEven^( ^).Spline36resize^(NewWidth, NewHeight/2, 0,  2*Shift^)>>%2
            echo Oc = SelectOdd^( ^).Spline36resize^(NewWidth, NewHeight/2, 0, -2*shift^)>>%2
            echo Interleave^(E, O^)>>%2
            echo IsYV12^(^) ? MergeChroma^(Interleave(Ec, Oc)^) : Last >>%2
            echo Weave^(^)>>%2
            echo } >>%2
            echo AssumeTFF^(^)>>%2
            echo SeparateFields^(^)>>%2
            echo Ev=SelectEven^(^).sharpen(0.20^)>>%2
            echo Od=SelectOdd^(^).sharpen^(0.20^)>>%2
            echo Interleave^(Ev,Od^)>>%2
            echo Weave^(^)>>%2
            echo src.framerate^<26 ? src:src.AssumeTFF^(^).SeparateFields^(^).SelectEvery^(4,0,3^).Weave^(^) >>%2
            echo AssumeFPS^(25^)>>%2
            echo ChangeFPS^(25^)>>%2
            
            echo processing source file %4
        
            rem ***Call VirtualDub***
    	if NOT EXIST %VD_LOC% (
    		echo  Um, where the hell is VirtualDubMod?
    		pause
    	)
    	
            %VD_LOC% /min %2 /s %1
        	
           
    	for %%v in ("%DestFolder%\\%~n1_SD.avi") do (
    		if %%~zv LSS 128 (
    			echo  ERROR!!!  Extra Small File Size Detected!!!
    			pause
    		)
    	)
           
            v:\automazioneclip\virtualdub\cfourcc.exe -i "%CD%\%~n1_SD.avi" -u MJPG -d MJPG
          
           DEL "%DestFolder%\*.ffindex"
           DEL "%DestFolder%\*.VCF"
           DEL "%DestFolder%\*.avs"
           DEL "%DestFolder%\ascii.txt"
           DEL "%DestFolder%\unicodefile.txt"
           DEL "%DestFolder%\mediainfo.txt"
    
           goto :eof
    
    :GetTargetName
    
    	Set "FileName="
    	Set /p FileName=InputFileName .mxf .mp4 or .avi 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
    
    	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  
Visit our sponsor! Try DVDFab and backup Blu-rays!