VideoHelp Forum
+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 50 of 50
Thread
  1. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Yes, the wider the range of colors the more likely you are to find those colors elsewhere in the picture. You can always check the mask (eg, return(mask)) to verify just the text is being changed. Of course, you'd have to look through the entire video.
    Which is where my overcomplicated horror comes into the picture. It isn't finished because I only had one short sample to work with and had no feedback. I really need to write a 'paint fill' AVISynth function to overcome some of it's shortfalls, then I need to add frame comparison to rule out anything that moves, but as long as you've got the right settings for the font the text is rendered in it should be pretty much set and forget.

    Really I should turn it into a dll to hide all the crap it's doing to fix such a seemingly simple problem. But for now I should probably Overlay the wmask over the final mask to stop the dead black from being tinted by the new chroma... and allow settings for modifying the MaskHS values...
    Last edited by ndjamena; 11th Oct 2014 at 11:30.
    Quote Quote  
  2. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    No need to create a new thread, this one is precisely what I am looking for.

    I'm looking for a script capable to change the color of a harcoded subtitle. Here is a sample: https://framadrop.org/r/znJhfsO4lW#RLppqRZQ6Fk75G1JaNFT4WguyQN+syTNXzdQlpmmqi8=

    I tweaked a bit but I can't properly change the grey subtitles into white. And there is lot of artefact created on the picture and/or around the outline sub.

    My script:

    Code:
    mask=MaskHS(30,30, 20,5).mt_expand().BilinearResize(last.width, last.height)
    overlay(last, GreyScale().ColorYUV(cont_y=100), 0, 0, mask)
    Any help is welcome.
    Quote Quote  
  3. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    You seriously want to turn GREY into WHITE?

    DAMN!

    And you thought you could take the easy way out too...
    Quote Quote  
  4. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    Originally Posted by ndjamena View Post
    You seriously want to turn GREY into WHITE?

    DAMN!

    And you thought you could take the easy way out too...
    What's your point? Is it impossible to do that?
    Quote Quote  
  5. Originally Posted by HelpVid View Post
    Originally Posted by ndjamena View Post
    You seriously want to turn GREY into WHITE?

    DAMN!

    And you thought you could take the easy way out too...
    What's your point? Is it impossible to do that?

    The point is there are too many overlapping "shades" similar to "grey" . You will get contamination of the mask, it's very difficult to generate a clean mask based on a neutral tone like grey

    Maybe you can try several methods to combine masks to improve the results, perhaps a luma mask limited by a motion mask . Eitherway it's not going to give perfect results
    Quote Quote  
  6. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    Originally Posted by poisondeathray View Post
    The point is there are too many overlapping "shades" similar to "grey" . You will get contamination of the mask, it's very difficult to generate a clean mask based on a neutral tone like grey

    Maybe you can try several methods to combine masks to improve the results, perhaps a luma mask limited by a motion mask . Eitherway it's not going to give perfect results
    This is a constructive reply for someone (me) who doesn't know not much.

    Now I understand why it's hard. The thing is I know that the program Avisubdetector is able to "whitening" the sub without affecting the frame itself.
    I wonder how the program applies its setting to do that...

    thx
    Quote Quote  
  7. Originally Posted by HelpVid View Post
    Now I understand why it's hard. The thing is I know that the program Avisubdetector is able to "whitening" the sub without affecting the frame itself.
    I wonder how the program applies its setting to do that...
    I don't know, I've never used it before

    But why don't you use that instead if it works ?
    Quote Quote  
  8. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    Don't really use this program. Maybe I should but would be more convenient to use a script instead.
    Quote Quote  
  9. Here's an example that combines a mask for greys and a mask for blacks then masks off only the subtitle area near the bottom of the video:

    Code:
    function PackRGB(int r, int g, int b)
    {
       return(r*256*256 + g*256 + b)
    }
    
    LWLibavVideoSource("greysubs.mkv") 
    src=last
    
    greymask = ResetMask(ConvertToRGB(src)).ColorKeyMask(PackRGB(203,203,203), 15, 15, 15).ShowAlpha().ConvertToYV12(matrix="PC.601").mt_inpand().mt_inpand()
    blackmask = ResetMask(ConvertToRGB(src)).ColorKeyMask(PackRGB(15,15,15), 15, 15, 15).ShowAlpha().ConvertToYV12(matrix="PC.601").mt_inpand.mt_inpand()
    submask = Overlay(greymask, blackmask, mode="add").Invert().Crop(350,540,-350,-48).AddBorders(350,540,350,48).ColorYUV(cont_y=40).Blur(1.0)
    
    overlay(last, GreyScale().ColorYUV(cont_y=200), 0, 0, mask=submask)
    Interleave(src, last, submask.ConvertToYV12().GreyScale())
    Quote Quote  
  10. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    Originally Posted by jagabo View Post
    Here's an example that combines a mask for greys and a mask for blacks then masks off only the subtitle area near the bottom of the video:

    Code:
    function PackRGB(int r, int g, int b)
    {
       return(r*256*256 + g*256 + b)
    }
    
    LWLibavVideoSource("greysubs.mkv") 
    src=last
    
    greymask = ResetMask(ConvertToRGB(src)).ColorKeyMask(PackRGB(203,203,203), 15, 15, 15).ShowAlpha().ConvertToYV12(matrix="PC.601").mt_inpand().mt_inpand()
    blackmask = ResetMask(ConvertToRGB(src)).ColorKeyMask(PackRGB(15,15,15), 15, 15, 15).ShowAlpha().ConvertToYV12(matrix="PC.601").mt_inpand.mt_inpand()
    submask = Overlay(greymask, blackmask, mode="add").Invert().Crop(350,540,-350,-48).AddBorders(350,540,350,48).ColorYUV(cont_y=40).Blur(1.0)
    
    overlay(last, GreyScale().ColorYUV(cont_y=200), 0, 0, mask=submask)
    Interleave(src, last, submask.ConvertToYV12().GreyScale())
    Cheers. Seems cool but unfortunately it changes the fps to 75 if I recall. Any idea why is that? It inserts the white sub frames I guess.
    Quote Quote  
  11. I interleaved the original video, the updated video, and the mask -- so you can open the video in an editor, step through frame by frame, and see exactly what's going on. Remove the last line to get just the updated video.
    Last edited by jagabo; 2nd Jan 2017 at 08:44.
    Quote Quote  
  12. Member
    Join Date
    Sep 2013
    Location
    Europe
    Search PM
    Originally Posted by jagabo View Post
    I interleaved the original video, the updated video, and the mask -- so you can open the video in an editor, step through frame by frame, and see exactly what's going on. Remove the last line to get just the updated video.
    Right. Definitely better without interleave ^^
    cheers you helped me a lot
    Quote Quote  
  13. Originally Posted by jagabo View Post
    Here's a variation I came up with using a greyscale (contrast enhanced) version of the video as the replacement color:

    Code:
    ffVideoSource("cut.mkv") 
    mask=MaskHS(160,180, 100,80).mt_expand().BilinearResize(last.width, last.height)
    overlay(last, GreyScale().ColorYUV(cont_y=50), 0, 0, mask)
    Image
    [Attachment 25221 - Click to enlarge]


    You'll need mt_masktools to use mt_expand(). If you want to use the single threaded Expand() (in the Masktools package) instead of mt_expand(), ConvertToYV12() before Expand().

    Code:
    mask=MaskHS(160,180, 100,80).ConvertToYV12().Expand().BilinearResize(last.width, last.height)
    Someone has an idea because it is now shown in black and white with avisynth+.

    Image
    [Attachment 43857 - Click to enlarge]


    This script it showed correctly with my previous avisynth.

    Thanks in advance.
    Quote Quote  
  14. Post the complete script and a sample or at least MediaInfo of the source video.
    Quote Quote  
  15. thanks

    is the script that jagabo posted:

    ffVideoSource("cut.mkv")
    mask=MaskHS(160,180, 100,80).mt_expand().BilinearResize(last.width, last.height)
    overlay(last, GreyScale().ColorYUV(cont_y=50), 0, 0, mask)
    and the same post sample #5 (new)
    Quote Quote  
  16. Yes, the image post #11 was made from that video and that script. Just ran it again and verified it works.
    Quote Quote  
  17. It looks like AviSynth+ got something backward. Try inverting the mask, or reversing the order of the two videos in Overlay.
    Quote Quote  
  18. Like this?
    Code:
    ffVideoSource("cut.mkv") 
    mask=MaskHS(160,180, 100,80).mt_expand().BilinearResize(last.width, last.height)
    inv=Invert(mask) #workaround for broken AVS+ r2173 to r2544
    overlay(last, GreyScale().ColorYUV(cont_y=50), 0, 0, inv)
    Quote Quote  
  19. @ sneaker

    Apparently it works.

    but the subtitle appears with some blocks of yellow.

    Image
    [Attachment 43860 - Click to enlarge]


    Modifying the script with 'mt_inpand' the sub show much better,...is this correct?

    ffVideoSource("cut.mkv")
    mask=MaskHS(160,180, 100,80).mt_inpand().BilinearResize(last.width, last.height)
    inv=Invert(mask) #workaround for broken AVS+ r2173 to r2544
    overlay(last, GreyScale().ColorYUV(cont_y=50), 0, 0, inv)
    Image
    [Attachment 43861 - Click to enlarge]


    I had changed to avisynth+ and wanted to start all my samples script.

    Now I'm satisfied.

    Thanks sneaker, jagabo.
    Last edited by sekininsha; 29th Nov 2017 at 23:16.
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!