VideoHelp Forum
+ Reply to Thread
Results 1 to 25 of 25
Thread
  1. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Hey! I have a video file I'd like to restore, which has weird horizontal lines all over it. I think it might be a bad deinterlacing job, but to be honest I'm unsure what it is exactly. This is how the source looks. How would I go about fixing something like this? (I know the aspect ratio is not correct). Sample attached. Thanks!
    Image Attached Files
    Quote Quote  
  2. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    It looks like the image has been poorly resized in the vertical direction. Rather than interpolating smoothly from 720p to 480p, I believe two lines have simply been discarded every four lines. To try to undo this, you need to replace those missing rows somehow and then resize the video correctly.

    Original, stripey image:



    Empty space inserted every four pixels, stair stepping is largely gone:



    Missing lines filled in:



    And resized back to the original height:



    You can achieve this with something like the following in AviSynth

    Code:
    SeparateRows(8)
    
    x0 = SelectEvery(8, 0)
    x1 = SelectEvery(8, 1)
    x2 = SelectEvery(8, 2)
    x3 = SelectEvery(8, 3)
    x4 = SelectEvery(8, 4)
    x5 = SelectEvery(8, 5)
    x6 = SelectEvery(8, 6)
    x7 = SelectEvery(8, 7)
    
    # Create filler for missing lines
    a2 = Merge(x2,x3, 0.33)
    a3 = Merge(x2,x3, 0.67)
    a6 = Merge(x6,x7, 0.33)
    a7 = Merge(x6,x7, 0.67)
    
    # Insert filler and put image back together
    Interleave(x0,x1,x2, a2,a3, x3,x4,x5,x6, a6,a7, x7)
    WeaveRows(12)
    
    # Return image back to original dimensions
    BilinearResize(width(), 480)
    Of course, I have just used a rather crude Merge() call to fill in the missing lines. You could get more creative with NNEDI() or other ways to interpolate the missing data, and of course also add further anti-aliasing after the fix.

    Still, just doing this much removes a lot of the stripey-ness from the video; I've included a clip with the original and fixed side by side.
    Image Attached Thumbnails Click image for larger version

Name:	original.png
Views:	274
Size:	240.7 KB
ID:	57759  

    Click image for larger version

Name:	missing.png
Views:	290
Size:	254.1 KB
ID:	57765  

    Click image for larger version

Name:	filled.png
Views:	281
Size:	291.9 KB
ID:	57766  

    Click image for larger version

Name:	resized.png
Views:	281
Size:	226.2 KB
ID:	57767  

    Image Attached Files
    Quote Quote  
  3. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Thank you so much! I've moved away from Avisynth to Hybrid because scripts scare me a bit, but I'll try to get this to work.
    Quote Quote  
  4. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    It should be fairly straightforward as no external filters are used, except for a source filter of your choosing.

    I also realized that the stripe pattern already repeats after four lines - I went with eight while trying to figure out what exactly is missing. This shorter script should perform exactly the same correction:

    Code:
    SeparateRows(4)
    
    x0 = SelectEvery(4, 0)
    x1 = SelectEvery(4, 1)
    x2 = SelectEvery(4, 2)
    x3 = SelectEvery(4, 3)
    
    # Create filler for missing lines
    a2 = Merge(x2,x3, 0.33)
    a3 = Merge(x2,x3, 0.67)
    
    # Insert filler and put image back together
    Interleave(x0,x1,x2, a2,a3, x3)
    WeaveRows(6)
    
    # Return image back to original dimensions
    BilinearResize(width(), 480)
    Quote Quote  
  5. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    I'm getting this error, even though I installed the only version of Avisynth I can see, which should be 32 bit. What do I need to change?
    Image
    [Attachment 57770 - Click to enlarge]
    Quote Quote  
  6. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    Hmm... well the message certainly seems to indicate that a 64 bit AviSynth is being used - is it possible you have multiple copies installed, perhaps some other package you have installed included AviSynth with it?

    The versions I am using are AviSynth+ (64 bit) and the FFmpegSource plugin for loading videos.
    Quote Quote  
  7. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    I did install Avisynth+ first, but then I uninstalled it in favor of the base one. Maybe it left some stuff behind?
    Quote Quote  
  8. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Okay, so I reinstalled Avisynth+, and deleted it with its own uninstaller this time. Now it gives this error:Image
    [Attachment 57772 - Click to enlarge]


    Script looks like this:
    Code:
    # DGDecode:
    LoadPlugin("d:\Data\dgmpgdec2005\dgdecode.dll")
    MPEG2Source("d:\Data\MattyP\vegas\full.d2v")
    
    SeparateRows(4)
    
    x0 = SelectEvery(4, 0)
    x1 = SelectEvery(4, 1)
    x2 = SelectEvery(4, 2)
    x3 = SelectEvery(4, 3)
    
    # Create filler for missing lines
    a2 = Merge(x2,x3, 0.33)
    a3 = Merge(x2,x3, 0.67)
    
    # Insert filler and put image back together
    Interleave(x0,x1,x2, a2,a3, x3)
    WeaveRows(6)
    
    # Return image back to original dimensions
    Spline64Resize(width(), 480)
    Quote Quote  
  9. Open your scripts with VirtualDub2. It should give you a better error message.

    One of the main things to watch out for is "bitness". If you use a 32 bit editor/encoder you must have 32 bit AviSynth installed and 32 bit versions of all the 3rd party filters. If you use a 64 bit editor/encoder you need to have 64 bit AviSynth installed and 64 bit versions of all the 3rd party filters.

    Note that SeparateRows() and WeaveRows() are not included in AviSynth, only AviSynth+.
    Quote Quote  
  10. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    Looks alright to me - does it work if you leave out everything after MPEG2Source()? If yes, it could be the SeparateRows() call, it was added in AviSynth 2.60 so an older version would fail there.

    You could also try loading the script in VirtualDub, perhaps it can present a more meaningful error message.
    Quote Quote  
  11. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    I can try remaking the d2v file. I'm using Avisynth 2.60 by the way. Should I get Avisynth+ 32 bit?
    Quote Quote  
  12. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    I remade the d2v file with only one of the VOBs instead of all 3, it now opens the script without error messages in Virtualdub (still gives an error in command prompt). Processing seems to be non-existent though. Does it just not execute filters when they're not available? Because then the problem could be that they're just missing from the install.
    Quote Quote  
  13. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    It should definitely complain "There is no function named --" if an unknown command is used. Can you try the script on the exact same sample you posted here? It's possible that the broken scaling is not constant throughout the full video, and adjustments would be needed.
    Quote Quote  
  14. Originally Posted by blinkHQ View Post
    Does it just not execute filters when they're not available?
    No. It always gives an error message indicating the missing filter.

    Make a simple script with just "version()". Open it in VirtualDub and encode it with ffmpeg. Compare the results.
    Quote Quote  
  15. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    It looks like I can't process the exact sample I uploaded here, DGIndex says "Error: No video sequence header found!". I processed the entirety of the first VOB though (where it should've thrown an error for missing plugins), and it ran and finished it. It skipped over the missing plugins, because it did perform the resize (I changed it from 480 to 720) that was the very last command.
    Quote Quote  
  16. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    Hmm, well I don't know what to say. The script runs yet there is no visible difference at all, the jagged edges remain untouched? I mean this method won't get rid of all the aliasing (some information has simply been thrown away in the bad resize), but you should at least see the improvements like in my sample video.
    Quote Quote  
  17. Originally Posted by blinkHQ View Post
    Are you saying both ffmepg and VirtualDub both give the exact same message?
    Quote Quote  
  18. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Are you saying both ffmepg and VirtualDub both give the exact same message?
    No, sorry, I misunderstood you. ffmpeg throws a generic error:
    Image
    [Attachment 57775 - Click to enlarge]
    Quote Quote  
  19. Then you are probably using 32 bit VirtualDub with 32 bit AviSynth, and 64 bit ffmpeg but don't have 64 bit AviSynth installed. Or are trying to load a 32 bit filter into 64 bit AviSynth:

    Code:
    LoadPlugin("d:\Data\dgmpgdec2005\dgdecode.dll")
    That lines needs to point to a 64 bit version of dgdecode.dll. Or just get a 32 bit version of ffmpeg.
    Quote Quote  
  20. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    I have installed a 32 bit version of ffmpeg, and it outputs correctly now! I'll try to get the main project working an let you know how it goes.
    Quote Quote  
  21. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Originally Posted by ajk View Post
    It should definitely complain "There is no function named --" if an unknown command is used. Can you try the script on the exact same sample you posted here? It's possible that the broken scaling is not constant throughout the full video, and adjustments would be needed.
    So now that I can I did this through ffmpeg, and it didn't say anything. Here's the script and command I ran:
    Code:
    # DGDecode:
    # LoadPlugin("d:\Data\dgmpgdec2005\dgdecode.dll")
    # MPEG2Source("d:\Data\MattyP\vegas\full.d2v")
    LoadPlugin("c:\Users\Me\Downloads\ffms2-2.40-msvc\ffms2-2.40-msvc\x86\ffms2.dll")
    FFmpegSource2("d:\Data\MattyP\vegas\vegas08sample.mp4")
    
    
    SeparateRows(4)
    
    x0 = SelectEvery(4, 0)
    x1 = SelectEvery(4, 1)
    x2 = SelectEvery(4, 2)
    x3 = SelectEvery(4, 3)
    
    # Create filler for missing lines
    a2 = Merge(x2,x3, 0.33)
    a3 = Merge(x2,x3, 0.67)
    
    # Insert filler and put image back together
    Interleave(x0,x1,x2, a2,a3, x3)
    WeaveRows(6)
    
    # Return image back to original dimensions
    Spline64Resize(width(), 720)
    and the command:
    Code:
    ffmpeg -i script.avs -c:v libx264 -preset veryslow -crf 16 "output.264"
    It seems to me that it did run the script somehow, as the video was resized to 720 in height. It didn't complain about missing plugins though, but it didn't execute them either.
    Quote Quote  
  22. Member
    Join Date
    Dec 2005
    Location
    Finland
    Search Comp PM
    Are you sure the filters are not being executed? How about if you change the filler lines like this:

    Code:
    # Create filler for missing lines
    a2 = BlankClip(x0)
    a3 = BlankClip(x0)
    That should leave very obvious black lines in the image. If so, then the SeparateRows() etc. filters are definitely being run.

    You don't need to encode a long video to check the result - just load the script in VirtualDub and see what it looks like there.
    Quote Quote  
  23. Member blinkHQ's Avatar
    Join Date
    Mar 2020
    Location
    Hungary
    Search Comp PM
    Thank you for this, yes, you were right, they were being run. I'm doing a full encode of VTS 1 with the original filters to compare with the source.
    Quote Quote  



Similar Threads

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