View Full Version : Remove immovable lines
thanhtu5013
8th February 2013, 20:31
Hi.
At first, sorry for my average English.
I recorded a video file from a game with Fraps and I get 2 black lines on it.
http://img138.imageshack.us/img138/7997/img3q.png
http://img825.imageshack.us/img825/418/img4c.png
Those defects are from PCSX2, a PS2 emulator for computers.
The emulator isn't 100% perfect so I can't do anything about it.
Does it exist any tip through Avisynth for removing those lines ? Any way I can fix it ?
Thx by advance.
lansing
10th February 2013, 04:44
are the two lines static? Did they move around or stay at the same place the whole time?
thanhtu5013
10th February 2013, 13:13
The two lines are static.
Didée
10th February 2013, 20:17
AviSource("yourvideo.avi",pixel_type="YV12")
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 318 > x 321 < & y 238 > y 241 < & | 255 0 ?")
rep = o.pointresize(320,180).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
Not ultimately perfect - more like 98% instead of 100%. :)
thanhtu5013
11th February 2013, 00:09
AviSource("yourvideo.avi",pixel_type="YV12")
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 318 > x 321 < & y 238 > y 241 < & | 255 0 ?")
rep = o.pointresize(320,180).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
Not ultimately perfect - more like 98% instead of 100%. :)
Doesn't work unfortunately.
Vdub doesn't know function mt_lutspa.
Didée
11th February 2013, 00:44
Required plugins are
- mt_masktools-25.dll (MaskTools_v2.0a48 (http://manao4.free.fr/))
- nnedi3.dll (NNEDI3 (http://web.missouri.edu/~kes25c/))
thanhtu5013
22nd April 2013, 21:11
The script doesn't work unfortunately while I got both plugins on plugins' directory of Aviynth.
Any other ideas ?
StainlessS
22nd April 2013, 21:51
What does The script doesn't work unfortunately mean.
Error message, video not corrected, what ?
If error message, what error message. Very few people here are clairvoyant.
thanhtu5013
22nd April 2013, 22:28
What does mean.
Error message, video not corrected, what ?
If error message, what error message. Very few people here are clairvoyant.
Avisynth open failure:
AVISource: the video compressor couldn't produce YV12 output (D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avs, line1)
StainlessS
22nd April 2013, 22:37
OK, then it is the AviSource line that fails, not the editing part of the script.
I personally have heard of Fraps, but no idea what container it uses ie is it AVI, or what.
Perhaps you have to use some other source filter.
Does it work (load) without the 'pixel_type="YV12"' arg.
eg:
AviSource("yourvideo.avi").ConvertToYV12()
thanhtu5013
22nd April 2013, 22:50
OK, then it is the AviSource line that fails, not the editing part of the script.
I personally have heard of Fraps, but no idea what container it uses ie is it AVI, or what.
Perhaps you have to use some other source filter.
Does it work (load) without the 'pixel_type="YV12"' arg.
- Fraps' recorded video files container is AVI.
- No, it doesn't work without pixel_type="YV12" yet.
I got this message :
Avisynth open failure:
mt_lutspa: unsupported colorspace. masktools only dupport planar YUV colorspaces (YV12, YV16, YV24)
(D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avs, line3)
Technical specs of my video from mediainfo :
General
Complete name : D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi
Format : AVI
Format/Info : Audio Video Interleave
Format profile : OpenDML
File size : 11.4 GiB
Duration : 4mn 3s
Overall bit rate : 401 Mbps
Writing library : VirtualDub build 32842/release
Video
ID : 0
Format : Fraps
Codec ID : FPS1
Duration : 4mn 3s
Bit rate : 400 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Bits/(Pixel*Frame) : 6.437
Stream size : 11.3 GiB (100%)
Audio
ID : 1
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 4mn 3s
Bit rate mode : Constant
Bit rate : 1 411.2 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Bit depth : 16 bits
Stream size : 40.9 MiB (0%)
Interleave, duration : 33 ms (1.00 video frame)
Interleave, preload duration : 500 ms
thanhtu5013
22nd April 2013, 23:02
I tried the following script like you said after the edit :
AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ConvertToYV12()
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 318 > x 321 < & y 238 > y 241 < & | 255 0 ?")
rep = o.pointresize(320,180).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
VirtualDub loaded it but I have no image at all.
StainlessS
22nd April 2013, 23:45
try
AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ConvertToYV12()
return last
and then
AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ConvertToYV12()
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 318 > x 321 < & y 238 > y 241 < & | 255 0 ?")
rep = o.pointresize(o.width/2,o.height/2).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
Forget this, see below
EDIT: Perhaps Didee presumed that the original source is 640x360 (thats the res of OP pics),
ie,
pointresize(320,180)
should have been
pointresize(o.width/2,o.height/2)
EDIT: On looking up mt_lutspa, it looks like
"x 318 > x 321 < & y 238 > y 241 < & | 255 0 ?"
are coordinates, so would have to be converted for the 1920x1080 clip.
so, after multiplying above mt_lutspa args by 3, we get (640x360 *3 == 1920x1080)
"x 954 > x 963 < & y 714 > y 723 < & | 255 0 ?"
so try this:
AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ConvertToYV12()
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 954 > x 963 < & y 714 > y 723 < & | 255 0 ?")
rep = o.pointresize(o.width/2,o.height/2).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
The coords may not be exactly correct, perhaps it helps to modify them if you know what they are,
they mean:
if(x>954 && x<963 || y>714 && y<723) then 255 Else 0 (255==fix : 0==dont fix)
EDIT: These might be a bit closer, but its hard to guess with only a low rez image.
"x 956 > x 961 < & y 716 > y 721 < & | 255 0 ?"
the x part creates a mask for the vertical line, the y for the horizontal line.
The 1st x arg should be 1 pixel left of the leftmost damaged vertical line,
the 2nd x arg should be 1 pixel right of the rightmost damaged vertical line
the 1st y arg should be 1 pixel above the topmost damaged horizontal line,
the 2nd y arg should be 1 pixel below the rightmost damaged horizontal line.
thanhtu5013
23rd April 2013, 01:38
Thanks a lot for your support. :)
I wrote my script as you said :
AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ConvertToYV12()
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 954 > x 963 < & y 714 > y 723 < & | 255 0 ?")
rep = o.pointresize(o.width/2,o.height/2).nnedi3_rpow2(2)
o.mt_merge(rep,msk)
Image changed a bit but still got those 2 lines.
Frame from original video :
http://img507.imageshack.us/img507/5782/originalc.png
After applied the mask :
http://img585.imageshack.us/img585/8618/aftermask.png
StainlessS
23rd April 2013, 04:38
Ok, this code fragment has I think the correct coords (1 outside of damage), but it dont work very well
#AVISource("D:\Ryu Ga Gotoku 1 - Yakuza 1 - A Late Friend'S Arrival.avi")
ImageSource("originalc.bmp")
ConvertToYV12()
o = last
msk = o.mt_lutspa(relative=false,yexpr="x 959 > x 965 < & y 719 > y 723 < & | 255 0 ?")
rep = o.pointresize(o.width/2,o.height/2).nnedi3_rpow2(2)
#rep = o.pointresize(o.width/4,o.height/4).nnedi3_rpow2(4) # try this line INSTEAD of above
o.mt_merge(rep,msk)
Perhaps we need the all powerful and mighty sage Didée.
poisondeathray
23rd April 2013, 05:53
Maybe a mirror bend ? or Maybe some inpainting or logo removal tools ? (avsinpaint, inpaintfunc, rm_logo, exinpaint) , Batch Gimp resynthsizer / Photoshop content aware fill ?
e.g
Exinpaint seems to do ok with some of the textures , like wood grain panelling , stucco ceiling ; but messes up other things like the hair, some carpet and bar textures
http://img594.imageshack.us/img594/1892/exinpaint.png
orig=ImageSource("originalc.png")
mymask=ImageSource("mask2.png")
ExInpaint(orig, mask=mymask, xsize=4, ysize=4)
mask used if anyone is interested , I uploaded 2 , a thin one and a thicker one. "mask2.png" was used for exinpaint example
(<2kb)
http://www.mediafire.com/?vrz17fc2qo1wya5
This was a essentially a mirror bend in after effects (cc wire removal) , not sure how to implement it in avisynth but I'm sure someone knows how to do it here
http://img708.imageshack.us/img708/7861/aeccwire.png
TheSkiller
23rd April 2013, 09:57
I'd simply use FillMargins (http://forum.doom9.org/showthread.php?t=55881).
Edit: Get it here (http://avisynth.org/warpenterprises/).
FillMargins(1,1,1,1)
thanhtu5013
23rd April 2013, 15:40
I'd simply use FillMargins (http://forum.doom9.org/showthread.php?t=55881).
Edit: Get it here (http://avisynth.org/warpenterprises/).
FillMargins(1,1,1,1)
Doesn't work at all unfortunately.
Maybe a mirror bend ? or Maybe some inpainting or logo removal tools ? (avsinpaint, inpaintfunc, rm_logo, exinpaint) , Batch Gimp resynthsizer / Photoshop content aware fill ?
e.g
Exinpaint seems to do ok with some of the textures , like wood grain panelling , stucco ceiling ; but messes up other things like the hair, some carpet and bar textures
http://img594.imageshack.us/img594/1892/exinpaint.png
orig=ImageSource("originalc.png")
mymask=ImageSource("mask2.png")
ExInpaint(orig, mask=mymask, xsize=4, ysize=4)
mask used if anyone is interested , I uploaded 2 , a thin one and a thicker one. "mask2.png" was used for exinpaint example
(<2kb)
http://www.mediafire.com/?vrz17fc2qo1wya5
This was a essentially a mirror bend in after effects (cc wire removal) , not sure how to implement it in avisynth but I'm sure someone knows how to do it here
http://img708.imageshack.us/img708/7861/aeccwire.png
Oh, thanks !
I've just checked both screens of yours and that's exactly what I'm looking for.
Your mask works well with images but it doesn't work with my video. I have this error message when I loaded my script :
Avisynth open failure
ExInPaint: Mask pixel type must be same as source clip type !
(D:\SAMPLE.avs, line3)
My script :
orig=AVISource("D:\SAMPLE.avi")
mymask=ImageSource("D:\mask2.png")
ExInpaint(orig, mask=mymask, xsize=4, ysize=4)
I guess it doesn't work cause my video and your mask don't have the same pixel type but I don't know how to fix it.
Interested about the 2nd mask method too. ( 2nd screen )
poisondeathray
23rd April 2013, 15:55
If it's fraps recording with AVISource , it should return RGB . One is probably RGB32, one is probably RGB24 . You're not using alpha channel here (it's just "fake") , so just convert them to RGB32
orig=AVISource("D:\SAMPLE.avi").ConvertToRGB32()
mymask=ImageSource("D:\mask2.png").ConvertToRGB32()
ExInpaint(orig, mask=mymask, xsize=4, ysize=4)
The 2nd method is basically a mirror blur , where you divide the line artifact in the middle and mirror the edges out. I'm not sure how to do in avisynth, but some of the gurus here will probably give you a similar or probably better method
thanhtu5013
23rd April 2013, 17:57
orig=AVISource("D:\SAMPLE.avi").ConvertToRGB32()
mymask=ImageSource("D:\mask2.png").ConvertToRGB32()
ExInpaint(orig, mask=mymask, xsize=4, ysize=4)
Yeah, thanks a lot. I can load it on VirtualDub. :)
I have a last request then I won' bother you anymore :
Does it possible to fix the same kind of bug with 1 transparent line ( not black ) at the middle this time ?
http://img822.imageshack.us/img822/4391/original1q.png
http://img543.imageshack.us/img543/7442/original2g.png
poisondeathray
23rd April 2013, 18:19
You would do the same thing; just make a mask that covers the area you want
You might try different exinpaint settings (look at the documentation) , or other inpainting filters or logo filters as well . Some might give better results
poisondeathray
23rd April 2013, 19:43
I think this is a similar method to the cc wire removal in AE. It basically crops to a 2 pixel strip left before the defect, shift it over right to cover the left side of the defect, (same thing on the right) , then blurs that strip horizontally , replacing it onto the original
orig=ImageSource("original2g.png")
l1=958
r1=960
l2=964
r2=954
orig
crop(l1,0,-r1,0)
#addborders(l1,0,r1,0)
Left=last
orig
crop(l2,0,-r2,0)
#addborders(l2,0,r2,0)
right=last
overlay(orig, left, x=960)
o1=last
overlay(o1, right, x=962)
blur(1.58,0).blur(1.58,0).blur(1.58,0)
blurred=last
blurred
crop(l1,0,-r2,0)
#addborders(l1,0,r2,0)
blurcrop=last
overlay(orig, blurcrop, x=958)
1q_blurred_overlay
http://img809.imageshack.us/img809/5144/blurredoverlay.png
2g_blurred_overlay
http://img543.imageshack.us/img543/6851/2gblurredoverlay.png
thanhtu5013
23rd April 2013, 21:26
It works very well.
But does it exist any way to crop from the middle or anywhere of the video ( not only the borders like usual ) ?
What I'm looking for it's removing the line, not blurring or compensate it.
Too bad I'm not English native.
poisondeathray
23rd April 2013, 21:32
It works very well.
But does it exist any way to crop from the middle or anywhere of the video ( not only the borders like usual ) ?
What I'm looking for it's removing the line, not blurring or compensate it.
Too bad I'm not English native.
Sorry - I don't understand - There is probably something lost in the translation
You can effectively do the same thing as "cropping from the middle" with stackhorizontal, stackvertical, or using overlay() with crops as shown above
You cannot just "remove the line." If you remove the line, you're left with a "black" line . You have to replace those pixels with something
thanhtu5013
23rd April 2013, 21:42
Sorry - I don't understand - There is probably something lost in the translation
You can effectively do the same thing as "cropping from the middle" with stackhorizontal, stackvertical, or using overlay() with crops as shown above
You cannot just "remove the line." If you remove the line, you're left with a "black" line . You have to replace those pixels with something
OK, so can I remove the line from the middle, then move a little bit to the left, the right side of the video ?
It would result a black line on the border right of the video that I can crop easily with usual methods.
poisondeathray
23rd April 2013, 21:48
OK, so can I remove the line from the middle, then move a little bit to the left, the right side of the video ?
It would result a black line on the border right of the video that I can crop easily with usual methods.
I don't understand
If you crop out e.g. 4 pixel strip in the middle , think of it has having 2 rectangles, divided by a 4 pixel strip down the center.
If you remove that strip and if you just join those rectangles together there will be a gap in the middle (width =1916 instead of 1920) . There will remain a seam down the middle because you are missing pixels
thanhtu5013
23rd April 2013, 21:53
I don't understand
If you crop out e.g. 4 pixel strip in the middle , think of it has having 2 rectangles, divided by a 4 pixel strip down the center.
If you remove that strip and if you just join those rectangles together there will be a gap in the middle (width =1916 instead of 1920) . There will remain a seam down the middle because you are missing pixels
OK.
I think I'll go with your last method.
Don't trouble yourself anymore. Thanks a lot for the help. :)
It's still very instructive to learn some tips for a newbie like me with AviSynth.
poisondeathray
23rd April 2013, 21:57
If it helps to visualize "crop middle out" :
orig=ImageSource("G:\Video Clips\Inpaint\original1q.png")
l=964
r=960
orig
crop(l,0,0,0)
#addborders(l,0,0,0)
rightblock=last
orig
crop(0,0,-r,0)
#addborders(0,0,r,0)
leftblock=last
stackhorizontal(leftblock,rightblock)
So the middle is cropped out, but there is a gap or "seam" of 4 missing pixels . The width is 1916 because you are missing 4 pixels width
thanhtu5013
23rd April 2013, 22:17
Oh, I see.
At first, I thought the line was in addition and moved out the right part of the video but in reality it's certainly the result of a bad alignment from bottom to top.
So cropping it doesn't fix the video.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.