VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    I have an AVI file ripped from a miniDV tape (PAL).

    The aspect ratio of the file changes from 4:3 to 16:9 every now and then.

    MPC-HC plays such a file correctly, but AviSynth assigns DAR from the first shot to the entire file.
    Can Avisynth even read such files correctly and "transfer" such a frame flag to ffmpeg (with -avisynth_flags all)?

    I use ffms2 to open the file (if that matters).
    Last edited by rgr; 18th Dec 2024 at 12:24.
    Quote Quote  
  2. Originally Posted by rgr View Post
    I have an AVI file ripped from a miniDV tape (PAL).

    The aspect ratio of the file changes from 4:3 to 16:9 every now and then.

    MPC-HC plays such a file correctly, but AviSynth assigns DAR from the first shot to the entire file.
    Can Avisynth even read such files correctly and "transfer" such a frame flag to ffmpeg (with -avisynth_flags all)?

    I use ffms2 to open the file (if that matters).

    Avisynth should be able to parse that information with frame properties if you use a source filter that reads it (e.g. ffms2, as you are using) - you can check with propshow() and _SARDen, _SARNum are read. Check to see if it switches on your video


    But ffmpeg avs demuxer does not pass that information. Currently it passes

    Code:
    _FieldBased 
    _ChromaLocation
    _Primaries
    _Transfer
    _Matrix
    _ColorRange
    You can make a request for someone to update the ffmpeg avs demuxer with more frame properties
    Quote Quote  
  3. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    ffms2 doesn't show correct _SarNum/Den (probably older version, but new ones have problems with file names). LWLibavVideoSource does.

    But ffmpeg with "-avisynth_flags all" can read DAR/PAR of avs file?

    Edit: I also did a test without AviSynth -- ffmpeg also couldn't handle the variable PAR with an avi file as a source.
    Quote Quote  
  4. Originally Posted by rgr View Post
    ffms2 doesn't show correct _SarNum/Den (probably older version, but new ones have problems with file names). LWLibavVideoSource does.
    Yes, tehre were a few versions of ffms2 that had unicode support broken , not sure what the current status is

    But ffmpeg with "-avisynth_flags all" can read DAR/PAR of avs file?
    I didn't think it would, but it does for me at least for a single AR DV-AVI file


    default
    Code:
      Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(bottom first), 720x576, 25 fps, 25 tbr, 25 tbn
    -avisynth_flags all (as an input option)
    Code:
      Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(bottom first), 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 25 tbn

    Can you verify if the switching AR is registered with lsmash , as least with the propshow()?
    Quote Quote  
  5. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    On every AVI file.



    LWLibav works.
    Last edited by rgr; 18th Dec 2024 at 12:19.
    Quote Quote  
  6. LSMASHVideoSource only works for MP4 and MOV files.
    Quote Quote  
  7. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Any ideas on how to properly convert such a file, preferably automatically?

    I'm thinking about using CropResize -- I need to check if it can scale using frame PAR.
    Or changing the resolution of the DAR 16:9 fragments to 960x576 and adding black bars to the DAR 4:3 fragments. And saving with PAR 16:15.
    I'll have to think about it.
    Quote Quote  
  8. Capturing Memories dellsam34's Avatar
    Join Date
    Jan 2016
    Location
    Member Since 2005, Re-joined in 2016
    Search PM
    The best way is to separate the scenes, then add black pillars to all 4:3 scenes before they can be added back to their locations and joined with the rest of 16:9 scenes and processed into one single file.

    At least that's what I would do if I have such tape. Use vdub to strip DV out, add black borders using the add border feature to the 4:3 frame one scene at a time and output into lossless AVI for each 4:3 segment, Then do the same thing for all 16:9 scenes, and rename all the output segments in a numerical order of their placement in the original footage, Use append feature in vdub to add all segments to the timeline and output as a single file and output in the same lossless AVI format, the entire process should be lossless.

    From this large file you can de-interlace, resize to 1920x1080 and encode to your desired format.
    Quote Quote  
  9. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    I wonder if something like this has a chance of working. I did something like that, but it was changing one command depending on the height. From the Avisynth syntax I see that the chances are slim.

    _prop("_SARNum") == 64 ? Eval("resize(960,576)" ? Eval("addBorders(left=120,right=120,color=0)")

    Invented syntax -- that's how I imagine it.
    Quote Quote  
  10. Here is a rough example using PropGetInt to parse the _SARNum, and it returns one version (b1) if SarNum is 64, otherwise (a1) . There is no error catching logic , and it's really rough

    In this example, the "c" test clip is dark grey 4:3 + light grey 16:9 + dark grey 4:3 all at 720x576

    Based on their SarNum value, those sections are replaced with a square pixel equivalent. Change the values as you see fit

    Code:
    blankclip(width=720,height=576,length=10,pixel_type="YV12",colors=[64,128,128]).killaudio()
    propSet("_SARNum",16)  
    propSet("_SARDen",15)  
    #4:3
    a=last
    
    blankclip(width=720,height=576,length=10,pixel_type="YV12", colors=[192,128,128]).killaudio()
    propSet("_SARNum",64)  
    propSet("_SARDen",45)  
    #16:9
    b=last
    
    a1=a.crop(8,0,-8,0).spline36resize(768,576).addborders(128,0,128,0).propSet("_SARNum",1).propSet("_SARDen",1)  
    b1=b.crop(8,0,-8,0).spline36resize(1024,576).propSet("_SARNum",1).propSet("_SARDen",1)  
    
    #testclip
    c=a+b+a
    
    scriptclip(c.spline36resize(1024,576), """propGetInt(c,"_SARNum") == 64? b1 : a1""")
    Quote Quote  
  11. did not know that dv avi can have alternating aspect ratio, would be interesting if ffms2 or BestSource read those, in vapoursynth perhaps more likely (BestSource likely?):
    Code:
    from vapoursynth import core
    from functools import partial
    import havsfunc
    
    #clip = core.ffms2.Source(r"E:\PAL_DV.avi")
    clip = core.bs.VideoSource(r"E:\PAL_DV.avi")
    clip = clip.std.SetFrameProps(_Matrix=5, _Primaries=5, _Transfer=5)
    clip = clip.std.CropAbs(width=704, height=576, top=0, left=8)
    # deinterlace or filters here
    clip = havsfunc.QTGMC(clip, Preset='slow', TFF=False)
    clip = clip.std.RemoveFrameProps(['_DurationNum', '_DurationDen'])
    
    def compare_ar(n, f, clip):
        if int(f.props['_SARNum']) == 64:
            clip = clip.resize.Spline36(width=1024, height=576)
        else:
            clip = clip.resize.Spline36(width=768, height=576)
            clip = clip.std.AddBorders(left=128, right=128, color=(16,128,128))
        return clip
    
    placeholder = clip.std.BlankClip(width=1024, height=576)
    clip = core.std.FrameEval(placeholder, partial(compare_ar, clip=clip),  prop_src=clip)
    clip = clip.std.SetFrameProps(_SARDen=1, _SARNum=1)
    clip.set_output()
    edit: I forgot to resize 4:3 parts
    Last edited by _Al_; 18th Dec 2024 at 20:59.
    Quote Quote  
  12. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Thanks for the idea, I modified it a bit to suit my needs. I also replaced the filter with ConditionalFilter (according to the description it is more stable with multiple threads).

    Code:
    name="Tape 1 (01.09.2007 11.52).avi"
    
    #4:3
    a=LWlibavvideosource(name).QTGMC(preset="slow",TR2=3)#.propshow
    a=AudioDub(a,LWlibavaudiosource(name))
    
    #16:9
    b=LWlibavvideosource(name).QTGMC(preset="slow",TR2=3)#.propshow
    
    a1=a.addborders(120,0,120,0)
    b1=b.spline36resize(960,576).propSet("_SARNum",16).propSet("_SARDen",15)
    
    #scriptclip(b.spline36resize(960,576), """propGetInt(a,"_SARNum") == 16 ? a1 : b1""")
    ConditionalFilter(a, a1, b1, """propGetInt(a,"_SARNum")""", "==", "16")
    I just don't know why after adding audio the whole thing is unusable (either it works terribly slowly or it crashes VirtualDub)

    Edit:
    This is a problem with LWLibavAudioSource with uncompressed audio, I just remembered.

    You need to use:
    Code:
    a=AudioDub(a,ffms2(name, atrack=-1))
    * - I didn't use ffms2 for video because my older version doesn't read the properties of each frame and I couldn't find a new one that works properly with Unicode.
    Last edited by rgr; 19th Dec 2024 at 07:16.
    Quote Quote  
  13. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    One more question for ffprobe experts. Is it possible to use this tool (or ffmpeg or avisynth) to check if a file has only one PAR or two?

    Based on the following principle:
    - all frames have the same PAR (16:15 or 64:45) - X value
    - there are frames in the file with different PAR - Y value
    Quote Quote  



Similar Threads

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