VideoHelp Forum
+ Reply to Thread
Page 1 of 3
1 2 3 LastLast
Results 1 to 30 of 64
Thread
  1. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Hi cats,

    I would like do an avisynth script that, for all mp4 in various format that I can put, it output alwais a stream @ 25fps interlaced.

    Fo example, if the opened file is a 25fps it don't have do to nothing, but if the opened file is 50fps it have to convert it to 25 fps interlaced

    The output have to be alwais 25fps interlaced for all

    If for example, the input file i a 100 fps, it have to output a stream of 25fps interlaced

    is it possible that? thanks
    Quote Quote  
  2. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    Yes, there are methods, but any kind of conversion has consequences and as always there's no BEST way to do it other than not doing it in the first place.
    Quote Quote  
  3. Avisynth script would be created inside batch script, I do it that way, but it could get complicated ...
    this one creates letterboxed DV avi by VirtualDub with free Cedocida codec by dropping 60p mp4 HD onto batch script:
    Code:
    SET path_destination=%~dp0OUTPUT
    SET path_temp=%~dp0temp
    SET name=%~n1
    SET filename_input=%~d1%~p1%~n1%~x1
    SET destination_adr=%path_destination%\%name%
    SET temp_adr=%path_temp%\%name%\%name%
    SET temp_folder=%path_temp%\%name%
    SET destination_folder=%path_destination%
    if not exist "%destination_folder%" ( MD "%destination_folder%" )
    if not exist "%temp_folder%" ( MD "%temp_folder%" )
    echo emptying temp folder if folder exists: %temp_folder%\
    if exist "%temp_folder%" ( DEL /F /Q "%temp_folder%"\*.* )
    SET virtualdub="%~dp0tools\VirtualDub\vdub.exe"
    SET mediainfo=%~dp0tools\Mediainfo\MediaInfo.exe
    SET get_videoinfo="%~dp0tools\subroutines\get_videoinfo.BAT"
    SET ffms2_dll="%~dp0tools\plugins\ffms2.dll"
    SET ffms2_avsi="%~dp0tools\plugins\FFMS2.avsi"
    SET encode_DV_by_cedocida_vcf="%~dp0tools\plugins\encode_DV_by_cedocida.vcf"
    SET ColorMatrix="%~dp0tools\plugins\ColorMatrix.dll"
    REM ************************** MediaInfo for dropped video **************************
    REM mediainfo subroutine reads %filename_input%
    call %get_videoinfo%
    echo video found: %format%  %w%x%h%
    echo frame rate: %fps%
    echo field order: %field_order%
    echo aspect ratio: %ar%
    REM *************************** Creating Avisynth script ******************************
    echo+ 
    echo creating avisynth script: %name%.avs
    echo Import(%ffms2_avsi%)                                    > "%temp_adr%.avs"
    echo LoadPlugin(%ffms2_dll%)                                >> "%temp_adr%.avs"
    echo LoadPlugin(%ColorMatrix%)                              >> "%temp_adr%.avs"
    echo ffmpegsource2("%filename_input%", atrack=1)            >> "%temp_adr%.avs"
    echo spline16resize(720,366)                                >> "%temp_adr%.avs"
    echo Blur(0,0.5) #vertical blur 0.5 to 1.5                  >> "%temp_adr%.avs"
    echo AddBorders(0,57,0,57)                                  >> "%temp_adr%.avs"
    echo ConvertFPS("ntsc_double")                              >> "%temp_adr%.avs"
    echo ColorMatrix(mode="Rec.709->Rec.601", clamp=0)          >> "%temp_adr%.avs"
    echo assumeframebased().assumebff().SeparateFields().SelectEvery(4,0,3).weave()  >> "%temp_adr%.avs"
    
    REM *************************** encoding with Virtual Dub ******************************
    echo.
    type "%temp_adr%.avs"
    echo.
    echo command line:
    echo vdub.exe /c /s "encode_DV_by_cedocida.vcf" /p "%name%.avs","%name%.avi" /r /h /x
    echo.
    echo VirtualDub is encoding: %~n1.avi ...
    %virtualdub% /c /s %encode_DV_by_cedocida_vcf% /p "%temp_adr%.avs","%destination_adr%.avi" /r /h /x
    pause
    it is just taken out of even more larger script, so some things might be missing, point is that you'd have to add lines while creating avisynth script depending on frame rate etc.

    for example adding line:
    if %fps%==100 echo select even() >> "%temp_adr%.avs"
    etc., etc, there would be much more conditions, depending on the source, video might be anamorph, where script is a bit different etc., it could go out of hand, better is to check the source (mediainfo or ffprobe) andthen run separate function or batch file that sorts only that particular case, like HD mp4 , 100fps ...
    Quote Quote  
  4. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    Originally Posted by marcorocchini View Post
    If for example, the input file i a 100 fps, it have to output a stream of 25fps interlaced

    Where are you going to get a 100fps clip ?

    Aren't you only dealing with 25fps interlaced , and 50p source ?

    What would you do with 100fps ? Throw away 1/2 the frames then make it 25fps interlaced ?

    What if you had 66.586766 fps ? How would you do the division ?




    Here is the simple "if then" in avisynth for those two cases of 25fps interlaced, 50p. You will get wrong result with anything else:

    Code:
    src=last
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    Quote Quote  
  5. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Where are you going to get a 100fps clip ?

    OHH I'm a cat

    I shot my cat with a small gopro hero3+ for cats

    Name:  anigif_enhanced-buzz-20478-1323304311-1.gif
Views: 82
Size:  440.8 KB
    Quote Quote  
  6. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by poisondeathray View Post

    Code:
    src=last
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    Oh my *** Name:  oh-my-word.jpg
Views: 79
Size:  10.6 KB
    Quote Quote  
  7. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    src=last
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()


    Name:  anigif_enhanced-buzz-8114-1323304351-1.gif
Views: 75
Size:  486.2 KB
    Quote Quote  
  8. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    WOW!

    SORRY POISON MY CATS HAVE ANOTHER QUESTION:

    THIS IS THE SCRIPT THAT DO THIS: LOAD A MP4 FILE THAT IF SOURCE IS > 25FPS --> NORMALIZE FPS TO 25FPS. IF SOURCE IS 25FPS don't touch nothing:

    Code:
    FFVideoSource("c:\GOPR1225.mp4")
    
    src=last
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    
    ChangeFPS(25)
    AssumeFPS(25)
    ConvertToYUY2(interlaced=true)

    Now, if possibile, I would like do exaxtly the same with resolutions that Are Not 720x576: if the source file is a resolution more or lower 720X576 ----> the script have to apply the IResize(7520,576):

    IResize(720,576)

    function IResize(clip Clip, int NewWidth, int NewHeight) {
    Clip
    SeparateFields()
    Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
    E = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0, Shift)
    O = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -Shift)
    Ec = SelectEven( ).Spline36resize(NewWidth, NewHeight/2, 0, 2*Shift)
    Oc = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -2*shift)
    Interleave(E, O)
    IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last
    Weave()
    }
    AssumeTFF()
    SeparateFields()
    Ev=SelectEven().sharpen(0.20)
    Od=SelectOdd().sharpen(0.20)
    Interleave(Ev,Od)
    Weave()
    Assumetff().SeparateFields().SelectEvery(4, 0, 3).Weave()


    so the script become something like this (?):

    Code:
    FFVideoSource("c:\GOPR1225.mp4")
    
    ColorMatrix(mode="Rec.709->Rec.601")
    
    IResize(720,576)
    function IResize(clip Clip, int NewWidth, int NewHeight) {
    Clip
    SeparateFields()
    Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
    E  = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0,    Shift)
    O  = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0,   -Shift)
    Ec = SelectEven( ).Spline36resize(NewWidth, NewHeight/2, 0,  2*Shift)
    Oc = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -2*shift)
    Interleave(E, O)
    IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last 
    Weave()
    } 
    AssumeTFF()
    SeparateFields()
    Ev=SelectEven().sharpen(0.20)
    Od=SelectOdd().sharpen(0.20)
    Interleave(Ev,Od)
    Weave()
    
    src=last
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    
    ChangeFPS(25)
    AssumeFPS(25)
    ConvertToYUY2(interlaced=true)
    I wonder: can modify the script so that the IResize acts only for resolutions different from 720x576?

    And can I modify the script so that the colormatrix become from bt709tobt601 only if the source have is at a resolution that are more 720x576 (not if the the flags of a mp4 is specifically bt709, but only if the resolution is more of 720x576) ?

    thankssss!!!
    Last edited by marcorocchini; 31st Aug 2014 at 19:37.
    Quote Quote  
  9. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    http://avisynth.nl/index.php/Operators

    Colormatrix = src.width>720 || src.height>576 ? 709:601
    src = src.width!=720 || src.height!=576 ? src.IResize(720, 576): src

    You'd have to deal with aspect ratios in the batch though.
    Quote Quote  
  10. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by ndjamena View Post
    http://avisynth.nl/index.php/Operators

    Colormatrix = src.width>720 || src.height>576 ? 709:601
    src = src.width!=720 || src.height!=576 ? src.IResize(720, 576): src

    You'd have to deal with aspect ratios in the batch though.
    Name:  1CCAT5.jpg
Views: 61
Size:  60.5 KB

    Code:
    FFVideoSource("c:\GOPR1239HD25fps.MP4")
    
    src=last
    Colormatrix = src.width>720 src.height>576 ? 709:601
    src = src.width!=720 || src.height!=576 ? src.IResize(720, 576): src
    
    function IResize(clip Clip, int NewWidth, int NewHeight) {
    Clip
    SeparateFields()
    Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
    E  = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0,    Shift)
    O  = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0,   -Shift)
    Ec = SelectEven( ).Spline36resize(NewWidth, NewHeight/2, 0,  2*Shift)
    Oc = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -2*shift)
    Interleave(E, O)
    IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last 
    Weave()
    } 
    AssumeTFF()
    SeparateFields()
    Ev=SelectEven().sharpen(0.20)
    Od=SelectOdd().sharpen(0.20)
    Interleave(Ev,Od)
    Weave()
    
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    
    ChangeFPS(25)
    AssumeFPS(25)
    ConvertToYUY2(interlaced=true)
    Name:  anigif_enhanced-buzz-21905-1323304483-8.gif
Views: 60
Size:  496.9 KB


    Quote Quote  
  11. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    In case anyone is wondering, there's an OR operator on the on the Colormatrix line that the forum seems to be hiding. It shows if I try to 'quote' it though.
    Quote Quote  
  12. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    mmmmmm Name:  CCT11.jpg
Views: 56
Size:  57.2 KB


    Name:  CODE.jpg
Views: 57
Size:  217.2 KB
    Last edited by marcorocchini; 1st Sep 2014 at 07:07.
    Quote Quote  
  13. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    please cats I need to do another script that do this:

    load and convert all in 1920x1080HD except the source that are jet 1920x1080@25i AND if the source is SD BT601 ----> the script have to convert the source from 601 to 709

    As source, in this case, I use a 1440x1080@25i bt.709 .mxf file

    https://www.dropbox.com/s/df51oo8m5otdxnl/C0015.MXF?dl=0

    It have to be convert in fullHD

    I try with this script but I think there is a problem in the line of the colormatrix: using a SD (720x576) seems it don't do the 601-->709 colormatrix conversion. It should have to do the colormatrix conversion bt.601-->bt.709 when a SD file have resolution < (or equal) of 720x608

    Code:
    FFVideoSource("g:\xdcamF335\C0015.mxf")
    
    src=last
    Colormatrix = src.width<721 src.height<609 ? 601:709
    src = src.width<1920 || src.height<1080 ? src.IResize(1920, 1080): src
    
    
    function IResize(clip Clip, int NewWidth, int NewHeight) {
    Clip
    SeparateFields()
    Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
    E  = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0,    Shift)
    O  = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0,   -Shift)
    Ec = SelectEven( ).Spline36resize(NewWidth, NewHeight/2, 0,  2*Shift)
    Oc = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -2*shift)
    Interleave(E, O)
    IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last 
    Weave()
    } 
    AssumeTFF()
    SeparateFields()
    Ev=SelectEven().sharpen(0.20)
    Od=SelectOdd().sharpen(0.20)
    Interleave(Ev,Od)
    Weave()
    
    src.framerate<26 ? src : src.AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()
    
    ChangeFPS(25)
    AssumeFPS(25)
    ConvertToYUY2(interlaced=true)
    Name:  CODE2.jpg
Views: 53
Size:  217.3 KB

    All is ok with C0015.mxf, but when I use a SD source the colormatrix conversion seems don't work
    Is there a way to resolve?
    thanks
    Last edited by marcorocchini; 1st Sep 2014 at 09:45.
    Quote Quote  
  14. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    Originally Posted by ndjamena View Post
    In case anyone is wondering, there's an OR operator on the on the Colormatrix line that the forum seems to be hiding. It shows if I try to 'quote' it though.
    If you object to being called 'anyone' I'll happily call you no one.
    Quote Quote  
  15. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by ndjamena View Post
    Originally Posted by ndjamena View Post
    In case anyone is wondering, there's an OR operator on the on the Colormatrix line that the forum seems to be hiding. It shows if I try to 'quote' it though.
    If you object to being called 'anyone' I'll happily call you no one.

    but I'm a cat !!

    Name:  CCAT11.jpg
Views: 52
Size:  40.4 KB

    so the line how become?
    Quote Quote  
  16. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    I don't know why it's doing that and am not interested in finding out. Go back to post #9 and press 'quote' to see it properly.
    Quote Quote  
  17. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Name:  SCRC.jpg
Views: 49
Size:  229.5 KB

    in this case source is a 720x608 mxf SD file that need to ben cropped.



    c:Name:  CROP.jpg
Views: 50
Size:  436.3 KB



    But, for kindness, can I add a line that recognize if source is a 720x608 and a .mxf file (or simply a 720x608) -------[then]------> crop(0,32,0,0) ?
    Last edited by marcorocchini; 1st Sep 2014 at 11:10.
    Quote Quote  
  18. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    Originally Posted by marcorocchini View Post


    But, for kindness, can I add a line that recognize if source is a 720x608 and a .mxf file (or simply a 720x608) -------[then]------> crop(0,32,0,0) ?

    avisynth cannot distinguish between containers (mxf vs. mp4 vs. mkv etc....), because it frameserves uncompressed video

    Only clip properties

    http://avisynth.nl/index.php/Clip_properties
    Quote Quote  
  19. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    You'd have to do it from the batch.

    By the way:

    "FFmpegSource2 indexing app\n"
    Usage: ffmsindex [options] inputfile [outputfile]\n"
    "If no output filename is specified, inputfile.ffindex will be used.\n"
    "\n"
    "Options:\n"
    "-f Force overwriting of existing index file, if any (default: no)\n"
    "-v Set FFmpeg verbosity level. Can be repeated for more verbosity. (default: no messages printed)\n"
    "-p Disable progress reporting. (default: progress reporting on)\n"
    "-c Write timecodes for all video tracks to outputfile_track00.tc.txt (default: no)\n"
    "-k Write keyframes for all video tracks to outputfile_track00.kf.txt (default: no)\n"
    "-t N Set the audio indexing mask to N (-1 means index all tracks, 0 means index none, default: 0)\n"
    "-d N Set the audio decoding mask to N (mask syntax same as -t, default: 0)\n"
    "-a NAME Set the audio output base filename to NAME (default: input filename)\n"
    "-s N Set audio decoding error handling. See the documentation for details. (default: 0)\n"
    -m NAME Force the use of demuxer NAME (default, lavf, matroska, haalimpeg, haaliogg)"
    They're the instructions for FFMSIndex, apparently the only way to see them is to run FFMSIndex.exe with no arguments, I had to look at the source code to figure that out.

    So you can put the index file where ever you like by adding it as the second argument then reference it with the "cachefile=" option in FFVideoSource.
    Quote Quote  
  20. off topic, but thank you for bringing up that IResize, something that handles flickering ...
    Quote Quote  
  21. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Name:  TEMP2.jpg
Views: 52
Size:  143.0 KB


    sorry my cat have a question:
    can avisynth don't out audio? so virtualdub have No Audio?
    Quote Quote  
  22. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by _Al_ View Post
    off topic, but thank you for bringing up that IResize, something that handles flickering ...
    is poison that suggest it ^^^^^
    Quote Quote  
  23. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    Originally Posted by ndjamena View Post
    You'd have to do it from the batch.

    By the way:


    They're the instructions for FFMSIndex, apparently the only way to see them is to run FFMSIndex.exe with no arguments, I had to look at the source code to figure that out.

    So you can put the index file where ever you like by adding it as the second argument then reference it with the "cachefile=" option in FFVideoSource.
    thank for this particular, hoewver for I think is enought the only 720x608 .. only the IMX broadcast .mxf files have this bastard resolution ^^ so when the script recognize the only 720x608 is ok
    Quote Quote  
  24. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    Originally Posted by marcorocchini View Post
    can avisynth don't out audio? so virtualdub have No Audio?

    Instead of
    FFVideoSource()
    #this is for VIDEO only, hence FFVIDEOSource


    Use
    FFMpegSource2("video.ext", atrack=-1)

    or
    aud=FFAudioSource("video.ext")
    vid=FFVideoSource("video.ext")
    AudioDub(vid,aud)
    Quote Quote  
  25. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    ndjamena can I ask you a question?

    this is "your" mega powerful batch that I usually use. It filter only .mxf files, but can I modify it so that:

    1) it accept, for example .mxf and .avi files?

    or

    2) it accept all extensions?


    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=*.mxf"
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    Set VDM_LOC="v:\automazioneclip\VirtualDubMOD\virtualdubmod.exe"
    
    if not exist v:\automazioneclip\output\progetto3 mkdir v:\automazioneclip\output\progetto3
    set "DestFolder=v:\automazioneclip\output\progetto3"
    
    
    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\core\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -filter_complex "[0:1] [0:2] amerge,volume=2.0" -c:a pcm_s16le %WorkFolder%\%~n1.wav
            v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i "%CD%\%~n1.mxf" -filter_complex "[0:3] [0:4] amerge,volume=2.0" -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 FFVideoSource^(%4^)>%2
            echo AssumeFPS^(25^)>>%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
    	DEL %CD%\*.FFINDEX
    goto :eof
    
    
    :MAKEVCF_SD <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <MXF_FILENAME>
    
    
    
    
            v:\automazioneclip\core\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\core\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 FFVideoSource^(%4^)>%2
    	echo Crop^(0,32,0,0^)>>%2
            echo AssumeFPS^(25^)>>%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
    	DEL %CD%\*.FFINDEX
    
    
    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
    Quote Quote  
  26. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    EXTLIST is called EXTLIST for a reason.

    Set "EXTLIST=*.mxf *.avi"
    Quote Quote  
  27. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    You'll also have to modify the file extension code in Process_File:

    if /I NOT "%~x1"==".mxf" if /I NOT "%~x1"==".avi"
    If you intend on adding many file extensions, replacing that section with a for loop may be in order.
    Quote Quote  
  28. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    thanks ndjamena, only another question and I let yiu quite:

    in the batch, I cannot transpose some line (in red)


    the batch have to generate this
    Code:
    FFVideoSource("w:\cesenacalcio\c0075.mxf")
    
    src=last
    src=src.width==720&&src.height==608?src.crop(0,32,0,0):src
    src=src.width>720||src.height>608?src.ColorMatrix(mode="Rec.709->Rec.601"):src
    src=src.width!=720||src.height!=576?src.IResize(720,576):src
    
    function IResize(clip Clip, int NewWidth, int NewHeight) {
    Clip
    SeparateFields()
    Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
    E  = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0,    Shift)
    O  = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0,   -Shift)
    Ec = SelectEven( ).Spline36resize(NewWidth, NewHeight/2, 0,  2*Shift)
    Oc = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0, -2*shift)
    Interleave(E, O)
    IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last 
    Weave()
    } 
    AssumeTFF()
    SeparateFields()
    Ev=SelectEven().sharpen(0.20)
    Od=SelectOdd().sharpen(0.20)
    Interleave(Ev,Od)
    Weave()
    
    src.framerate<26?src:src.AssumeTFF().SeparateFields().SelectEvery(4,0,3).Weave()
    
    ChangeFPS(25)
    AssumeFPS(25)
    ConvertToYUY2(interlaced=true)

    This lines are accepted: but I caannot insert the red lines above


    Code:
         echo FFVideoSource^(%4^)>>%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 ChangeFPS^(25^)>>%2
         echo AssumeFPS^(25^)>>%2
         echo ConvertToYUY2^(interlaced=true^)>>%2
    Can you help me ?
    Quote Quote  
  29. Member
    Join Date: Apr 2013
    Location: Italy
    Search PM
    I can only do:

    echo src=last>>%2

    this is ok, but the others red dont' wont
    Quote Quote  
  30. Member
    Join Date: Sep 2012
    Location: Australia
    Search Comp PM
    ^<
    ^>
    ^|
    ^&
    ^\
    ^^
    %%
    Quote Quote