VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. Hi
    I'm trying to find a right script to use in Avisynth to get the same effect that some VD plugins achieves. The goal is to blur a hard subtitle in a video. I could notice that Logoaway, using XY mode is similar to RegionRemove and they do a good job. The problem with them is because they don't apply the filter to a range of frame. Correcting: RegionRemove does, but it's limited to 1024 bytes of frames data. The video I'm trying to remove the subs is much longer than this.

    So, I wrote a small program to generate the script using the list of frames created by another filter, MSUSubtitleRemover. All of this is to avoid to blur parts of the video where there are no subs to overlap.

    But the main question is very simple: how to blur some area of the video using Avisynth, getting the same effect of Logoaway (XY mode) or RegionRemove?

    Below, there are some samples:

    Original frame
    Click image for larger version

Name:	Original.jpg
Views:	1101
Size:	42.5 KB
ID:	8032

    Logoaway (XY mode)
    Click image for larger version

Name:	Logoaway-XY.jpg
Views:	998
Size:	36.9 KB
ID:	8033

    RegionRemove
    Click image for larger version

Name:	RegionRemove.jpg
Views:	986
Size:	37.0 KB
ID:	8034

    BilinearResize
    Click image for larger version

Name:	Bilinear.jpg
Views:	994
Size:	37.3 KB
ID:	8035

    The script I used was:
    Code:
    aux1 = Trim(270,271)
    aux2=Crop(aux1,150,374,-150,80).BilinearResize(30,6).BilinearResize(430,80)
    v1=Overlay(aux1,aux2,150,374)
    v1
    ConvertToRGB()
    As you see, Logoaway and RegionRemove had made a better job than my crop-resize script.
    Is there another way to write the script to get better results?
    Also to treat the borders. Borders at my script are too hard and visible...
    Thank you.
    Quote Quote  
  2. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by jairovital View Post
    I could notice that Logoaway, using XY mode is similar to RegionRemove and they do a good job. The problem with them is because they don't apply the filter to a range of frame.
    You can apply any filter to a range of frames using ApplyRange().
    For multiple uses, a more convenient method is to use ReplaceFramesSimple() from stickboy's RemapFrames plugin.
    Quote Quote  
  3. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by jairovital View Post
    But the main question is very simple: how to blur some area of the video using Avisynth, getting the same effect of Logoaway (XY mode) or RegionRemove?

    For that I use Xlogo. See https://forum.videohelp.com/threads/273109-Remove-an-opaque-logo-using-Xlogo-in-Avisynth

    To run it on specified segments, use ReplaceFramesSimple as Gavino said.

    Eg:
    Code:
    AviSource("whatever.avi")
    filtered = xlogo("logoZ_x_0_y_0_2.bmp", X=0, Y=0, alpha=0)
    ReplaceFramesSimple(last, filtered, mappings= \
    "[715	9638  ]
    [19056	24808 ]
    [25679	31862 ]
    [32703	38575 ]")
    Will filter the video only on the 4 segments specified, using the bitmap mask to define the area to be filled.

    Basically it's the same as a long list of Trims and joins (++).
    Quote Quote  
  4. Gavino

    I'm reading ApplyRange and ReplaceFrameSimple docs to better understand their syntax and usage.
    If I use RegionRemove filter, it reads a text file to apply its effect, like this:

    828 924
    4659 4755
    4784 4863
    4880 4971

    where the first is the frame when the filter is ON and the second, is the end of the range of the filter.

    I have a list of frames with 14kbytes, but RegionRemove accept only 1kb. I'm having difficulties to understand how to join this filter with ApplyRange, or even ReplaceFrameSimple into a single script. May you, please, give some example?

    AlanHK

    I'll take a look at XLogo soon. But as I saw in your example, it uses a static BMP mask. I think it could be better if the area were blurred and has the same colors of the original area. It cannot be a static picture as it varies along the video.

    So, I would insist to ask you both if there are some Avisynth internal function to blur an area with similar look of RegionRemove. I already have a script just waiting this magic function I don't know yet.
    Thank you.
    Quote Quote  
  5. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by jairovital View Post
    I'll take a look at XLogo soon. But as I saw in your example, it uses a static BMP mask. I think it could be better if the area were blurred and has the same colors of the original area. It cannot be a static picture as it varies along the video.
    It's a mask, not an overlay. It has no colour.

    The colour to fill in the mask area is taken from the area of each frame surrounding the mask.
    It does exactly what you want.


    Originally Posted by jairovital View Post
    So, I would insist to ask you both if there are some Avisynth internal function to blur an area with similar look of RegionRemove. I already have a script just waiting this magic function I don't know yet.
    You can use VDub filters in Avisynth.
    See http://forum.doom9.org/showthread.php?p=846088 for how to use Regionremove.
    Though I think XLogo is simpler.

    You can put such function definitions in an avsi file so you don't have to paste it into every script.
    Last edited by AlanHK; 5th Aug 2011 at 07:33.
    Quote Quote  
  6. AlanHK

    Sorry about static picture. I'm reading your excelent thread about to remove an opaque logo using XLogo and I see the mask uses the BMP just like DeLogo does, varying along the video.
    Thank you.
    Quote Quote  
  7. AlanHK

    Your tips are excellent! But they require time to read and understand everything, to avoid my stupid questions, about static picture... (shame)

    Have to read ApplyRange, ReplaceFrameSimple, your Xlogo guide, VDub filters in Avisynth...
    And join them with what I have, generating frame lists.

    I'm reading and trying. Later I'll bring feedbacks.
    Thank you.
    Quote Quote  
  8. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by jairovital View Post
    I have a list of frames with 14kbytes, but RegionRemove accept only 1kb. I'm having difficulties to understand how to join this filter with ApplyRange, or even ReplaceFrameSimple into a single script. May you, please, give some example?
    Basically, it's like AlanHK's example already shows.
    You can also use a text file instead of directly supplying the 'mappings' (the frames to be replaced).
    I'm not familiar with RegionRemove, so I don't know what parameters it needs, but combining it with ReplaceFramesSimple would look something like this:

    AviSource("whatever.avi")
    filtered = RegionRemove(...) #with necessary params to apply to whole clip
    ReplaceFramesSimple(filtered, "myfile.txt")

    where myfile.txt is your list of frames, edited to include '[' and ']' around each pair, eg

    [828 924]
    [4659 4755]
    etc
    Quote Quote  
  9. I have some results to show.

    Applying XLogo and AlanHK guide:
    Click image for larger version

Name:	xlogo01.jpg
Views:	1440
Size:	45.9 KB
ID:	8038

    Small clip using XLogo:
    http://www.4shared.com/video/78QxABYR/xlogo.html

    Using RegionRemove:
    http://www.4shared.com/video/QaBaDRSS/RegionRemove.html

    Using Logoaway-XY
    http://www.4shared.com/video/A6lIQh1V/Logoaway-XY.html

    I think the problem to handle a range of frames is over. Thank you Gavino and AlanHK. clap, clap.

    Now, I ask if I applyed XLogo correctly. As we can see, the other VD filters blur the area better than XLogo. Also, the performance (less time) to get the final AVI of RegionRemove and Logoaway is better than XLogo.
    The blurred area blinks to much using XLogo script.

    The mask I used is this one:
    Click image for larger version

Name:	xlogo_x_150_y_370_2.jpg
Views:	1654
Size:	3.0 KB
ID:	8040

    I put 4 pixels of clear black, as described at the guide.

    I'm still very curious about the way RegionRemove and Logoaway can show that very nice mode of blur, using XY parameters. XLogo trys to extrapolate from the edges of the mask to fill it inside.

    So, guys, do you know how to apply that kind of XY blur using Avisynth? I mean, using Avisynth internal functions, because I already know how to import VD plugins into Avisynth scripts.
    Last edited by jairovital; 5th Aug 2011 at 09:13. Reason: Improving the last question
    Thank you.
    Quote Quote  
  10. Take the line of pixels just above the logo (subs) and the line just below the logo, put them together (StackVertical), and resize that to the height of the logo area. Do the same for the line just to the left and just to the right (StackHorizontal). Blend (Merge) the two rectangles together and lay the result over the logo.
    Quote Quote  
  11. Thank you jagabo, for joining the thread.

    After some tests, the script now is:

    Code:
    Loadplugin("DGDecode.dll")
    Mpeg2Source("Untitled.d2v")
    
    function VD_RRemover(clip clip,
      \  int "removeWidth", int "removeHeight", 
      \  int "removeX", int "removeY",
      \  bool "softEdges", bool "softONOFF", 
      \  bool "ignoreTop", bool "ignoreBottom", 
      \  bool "ignoreLeft", bool "ignoreRight",
      \  int "softPixels", 
      \  int "softFRAME",
      \  string "ranges")
    {
      LoadVirtualdubPlugin("RegionRemove.vdf", "_VD_RRemover", 1)
      return clip._VD_RRemover(default(removewidth,420), default(removeHeight,80), 
        \  default(removeX,150), default(removeY,374),
        \  default(softEdges,false)?1:0, default(softONOFF,false)?1:0, 
        \  default(ignoreTop,false)?1:0, default(ignoreBottom,false)?1:0,
        \ default(ignoreLeft,false)?1:0, default(ignoreRight,false)?1:0, 
        \  default(softPixels,0), 
        \  default(softFRAME,0),
        \  default(ranges,""))
    }
    ConvertToRGB() 
    filtered=VD_RRemover()
    ReplaceFramesSimple(last, filtered, mappings= \
    "[75 80]
    [115 200]
    [215 300]
    [415 700]")
    Of course, using RegionRemove.

    But I'd like to try your suggestions, because it is the core of the beginning of this thread: how to use internal functions of Avisynth to get the same results of these filters, RegionRemove and LogoawayXY.

    I understand exactly what you're talking about: to join vertical and horizontal lines of pixels and blend them together. I think it is the right path to get that XY effect.

    But lacks to me the right syntax of the script. May you please write down some code?
    I know how to use stackHorizontal and Vertical to compare videos, but I never used them to take together lines of pixels.
    Thank you.
    Quote Quote  
  12. BilinearResize() didn't like 2 pixel high or wide images so I used 2 lines of pixels top and bottom, left and right. And because of that it was necessary to blur the 4 pixel thick boxes:

    ImageSource("sub.jpg")

    box1=StackVertical(Crop(172,368,380,2),Crop(172,45 2,380,2)).Blur(1.0).BilinearResize(380,84)
    box2=StackHorizontal(Crop(172,368,2,84),Crop(552,3 68,2,84)).Blur(1.0).BilinearResize(380,84)

    Overlay(Merge(box1,box2),172,368)
    Result:
    Click image for larger version

Name:	sample.jpg
Views:	890
Size:	31.5 KB
ID:	8042

    Warning: the forum software adds spaces here and there.

    Personally, I'd just leave the subtitles there. The ugly box of garbled pixels is more distracting.
    Quote Quote  
  13. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    It's a bit like you did yourself in the first post:
    Code:
    ConvertToRGB32()
    h = StackVertical(Crop(150, 374, 420, 1), Crop(150, 453, 420, 1))
    v = StackHorizontal(Crop(150, 374, 1, 80), Crop(229, 374, 1, 80))
    ov = Merge(h.BilinearResize(420, 80), v.BilinearResize(420, 80))
    Overlay(ov, 150, 374)
    By converting to RGB32, you can avoid the resizing restrictions Jagabo mentions.
    Last edited by Gavino; 5th Aug 2011 at 11:07. Reason: convert to rgb32
    Quote Quote  
  14. Hi guys!

    It's time to say thanks for all of you!

    With our pleasant discussion I could learn new things. First, how to call a VD plugin from as Avisynth script. Also, how to use a list of frames with ReplaceFrameSimple. How to use another logo remover, XLogo. And now, how to apply some Avisynth internal functions to get the same effect of the VD filters.
    Great. Not just for me, but anybody else who wants the same target.

    Jagabo,

    I agree. That ugly box of garbled pixels is crap. But I'll overlay new subs there, like this:
    Click image for larger version

Name:	SoftSub.jpg
Views:	979
Size:	85.5 KB
ID:	8047

    The script will affect just when hard subs appears.

    Gavino, AlanHK and Jagabo, you all helped a lot. Thx.
    Thank you.
    Quote Quote  
  15. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by jairovital View Post
    I agree. That ugly box of garbled pixels is crap. But I'll overlay new subs there, like this

    Well, in that case there is a much easier way.

    Make your new subtitles with a solid, or semi-transparent, background. No need to blur the original subs at all.

    I've done this several times, when ripping a Japanese video with burnt in Chinese subs and I want to add English.

    You need to make bitmap subs, such as SUP or SUB/IDX.

    Or make a DVD, add your subs as normal, then open the VOB files using DVDSubedit and adjust the background colour of the subs (normally transparent) to taste. If the original subs are bright and distracting, just dial it up to black.

    Usually the new subs will be synchronised with the old ones, so no problems with filtering ranges.
    Quote Quote  
  16. AlanHK

    More tips arriving... Nice.

    I think the best choice is to go ahead with scripts and filtering ranges. I use SMU SubtitleRemover to give me a mask file with all the frames it detects hard subs. I also wrote a small code in Delphi to generate a pair of frames suitable to use in Avisynth script, reading from the mask file. You gurus, gave me the right path to apply the ugly box. Now it's showtime.

    You need to make bitmap subs, such as SUP or SUB/IDX.
    I often make my subs using MaestroSBT, that gives SON+BMPs. Or I can use SubtitleCreator to make SUPs from the SRT. None of them has semi-transparent background. How do you make that?

    Or make a DVD, add your subs as normal, then open the VOB files using DVDSubedit and adjust the background colour of the subs (normally transparent) to taste. If the original subs are bright and distracting, just dial it up to black.
    With DVDSubEdit, if my soft sub has 1 line and the hard one has 2 lines, the background appears too thin to fully cover it. How do you fix it?

    If you have more ideas, I'll listen all of them.
    Thank you.
    Quote Quote  
  17. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by jairovital View Post
    I often make my subs using MaestroSBT, that gives SON+BMPs. Or I can use SubtitleCreator to make SUPs from the SRT. None of them has semi-transparent background. How do you make that?
    Like I said, edit the colours in DVDSubedit after you've made it.

    if my soft sub has 1 line and the hard one has 2 lines, the background appears too thin to fully cover it. How do you fix it?
    Obviously, add a line to the soft sub, divide the line or add a blank. And/or increase the font size.

    SubtitleCreator has a lot of options affecting the appearance and size of the subs.

    I don't worry if there is a bit of the original sub still visible, as long as the new sub is clear.
    Quote Quote  
  18. I'd consider just blacking out the entire bottom of the frame for the whole video and having the new subs there. Although that's butchering the picture it may be less annoying than black boxes with subs popping up all the time. Like cutting off a gangrenous leg...
    Quote Quote  
  19. Originally Posted by AlanHK View Post
    Like I said, edit the colours in DVDSubedit after you've made it.

    Obviously, add a line to the soft sub, divide the line or add a blank. And/or increase the font size.

    SubtitleCreator has a lot of options affecting the appearance and size of the subs.

    I don't worry if there is a bit of the original sub still visible, as long as the new sub is clear.
    I followed your advices, AlanHK. Good tips.

    Originally Posted by jagabo View Post
    I'd consider just blacking out the entire bottom of the frame for the whole video and having the new subs there. Although that's butchering the picture it may be less annoying than black boxes with subs popping up all the time. Like cutting off a gangrenous leg...
    Jagabo, I agree about the 'blinking bars' with subs. To avoid that, I adjusted my code to make a continuous range of adjacent frames where the difference was less than 20, 30, 50... (whatever, controlled by user) frames. It often occurs during dialogues. So, if there are few frames between two bars, I adjust the frames to give just only one bar along the whole dialogue, or bunch of successive speeches. It also avoids a bit of the original subs remains visible, because the continuous bar is covering all bellow of it. I may also add some frames before and after the bar to make sure it'll cover the original subs.

    Also, to get synchronized soft subs with the hard ones, I use the TXT mask file generated from the MSU SubtitleRemover to create an empty SRT file, just with time-codes, where I fill with text later, using SubtitleWorkshop, just in one step.

    But indeed, the blurred bars are far ugly. AlanHK and myself know what we must to do when some movie drops in hands and there are no other source of it. We have to close eyes and make the dirty work.
    Thank you.
    Quote Quote  



Similar Threads

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