Log in

View Full Version : Need help with delogo optimisation


Hironimo
1st February 2006, 12:57
Hello

I've recorded a film from dvb-s and tried to remove the logo with DeLogo using an avisynth script. I followed some instructions from Didee.

This are the scripts:
fpkw1_final.avs:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
Import("F:\capture\encoding\kabel1_delogo.avs")
MPEG2Source("F:\capture\encoding\fpkw1.d2v",cpu=4,idct=5)
vid=Trim(477,19706)+Trim(29053,59192)+Trim(70189,99501)+Trim(109677,142294)+Trim(150605,170038)
return Kabel1Delogo(vid)

kabel1_delogo.avs:
function VD_DeLogo(clip clip, bool "on_frames", string "range", string "file_deblend", string "file_alpha",
\ string "file_color", string "file_repair", float "depth", float "power", int "par_X", int "par_Y", bool "interlaced")
{
LoadVirtualdubPlugin("F:\capture\encoding\delogo.vdf", "_VD_DeLogo")
X = round(10*depth)
Y = round(10*power)
z = 100*log(par_X/par_Y) / log(10)
return clip._VD_DeLogo(default(on_frames,false)?1:0, default(range,""), default(file_deblend,""), default(file_alpha,""),
\ default(file_color,""), default(file_repair,""), default(X,15), default(Y,40), default(interlaced,false)?1:0, z)
}

function Kabel1Delogo (clip clp, float "LumaMix") {
LumaMix=default(LumaMix,0.8)
logo=clp.crop(0,0,112,144)
bottom=clp.crop(0,144,-0,-0)
right=clp.crop(112,0,-0,144)
ConvertToRGB(logo)
logY=VD_DeLogo(false, "", "F:\capture\encoding\kabel1_deblend.bmp", "F:\capture\encoding\kabel1_alpha.bmp", "F:\capture\encoding\kabel1_color.bmp", "F:\capture\encoding\kabel1_repair-Y.bmp",
\ 2.0, 4.0, 1, 1, false).ConvertToYV12()
logC=VD_DeLogo(false, "", "F:\capture\encoding\kabel1_deblend.bmp", "F:\capture\encoding\kabel1_alpha.bmp", "F:\capture\encoding\kabel1_color.bmp", "F:\capture\encoding\kabel1_repair-C.bmp",
\ 2.0, 4.0, 1, 1, false).ConvertToYV12()
mergeluma(logC,logY,LumaMix)
top=stackhorizontal(last,right)
return ( stackvertical(top,bottom) )
}

Here some frames with bad results:
http://forum.doom9.org/attachment.php?attachmentid=5374&stc=1&d=1138794771
http://forum.doom9.org/attachment.php?attachmentid=5375&stc=1&d=1138794771

As you can see there is still a shimmer of the logo which you can observe more closly by the alpha-version of the logo section:
http://forum.doom9.org/attachment.php?attachmentid=5377&stc=1&d=1138795217

If you need them, I'll also post the other snips used to remove the logo.

What can I do to improve the removal of the logo?

Hironimo

PS: How can I make the images appear directly and not as link and hide the attachments listing?

Hironimo
1st February 2006, 17:53
I've tweaked the deBlend shift value to 0.15 and that helped reduce the hue,
but in quite a few frames the logo is still evident.
I may post more details later.

foxyshadis
2nd February 2006, 02:48
You know, avisynth has a log() (actually ln), so you could replace the whole numeric approximation mess with

z = 100*log(par_X/par_Y) / log(10)

But I notice that was originally a vdub function, so it makes sense.

Otherwise, I'm interested but don't have anything to test with. (Well, short of creating something.) When I get time I'll check it out and see if I can help.

Wilbert
2nd February 2006, 10:42
But I notice that was originally a vdub function, so it makes sense.
When I wrote that AviSynth didn't have a log function :)

Hironimo
2nd February 2006, 13:06
I've extracted some parts of the video which you can use to test:
fpkw_test1.mpg (http://81.223.129.75/video/fpkw_test1.mpg)
fpkw_test2.mpg (http://81.223.129.75/video/fpkw_test2.mpg)

I've also provided my test scripts for you that includes all you need except the mpeg files you need to download from the urls above and put in the same folder as the other files of the attachment.

As it seemes the attachment needs approval I've put it on my server too:
delogo_test.zip (http://81.223.129.75/video/delogo_test.zip)

At the first glance it might seem well done I think but when you look closer there are noticable distortions.

I don't understand what you mean with the mentioned formula.
Can you explain and how to use it?
It would be nice if you changed the attached script.

Cheers!

Didée
2nd February 2006, 13:27
Basically, the logo removal is already very good. For more improved results, make your way through the delogo thread (http://forum.gleitz.info/showthread.php?t=15004) on Gleitz'.
You should use a later version of the delogo script, which includes a more efficient Lmix option (with values >1.0 for noise damp-down like in Spresso() ), and enables additional postprocessing for artefact removal as well as the possibility to combine everything with a 2nd masking process, which is useful both for restricting if very strong postprocessing is needed, and for the YUV->RGB->YUV-color-mismatching problem which sometimes becomes visible on flat-colored backgrounds.

The thread is long, I know. But it holds all answers as well.

Wilbert
2nd February 2006, 13:28
I edited your script and approved your attachment. Your results won't change though.

Hironimo
2nd February 2006, 13:43
What did you change Wilbert? I didnt notice anything.

I'll look through the thread as I come to it, Didée.

Where can I find the latest delogo version?
Do you only mean the VD_DeLogo function or should I also change my customized Kabel1Delogo (if yes, to what)?

Hironimo

Hironimo
2nd February 2006, 18:17
I also tried to use iip to get a clearer image, but I failed to find the Dustv5.dll which contians the pixie dust filter from steady.
Can anyone point me to it?

Mr_Odwin
2nd February 2006, 18:25
I also tried to use iip to get a clearer image, but I failed to find the Dustv5.dll which contians the pixie dust filter from steady.
Can anyone point me to it?

It took me literally hours to find it just the other day:
http://www.avisynth.org/warpenterprises/attic.html
It's under dust, as you might expect. You may also need LoadPluginEx.dll to load dust and that was difficult to find too. Can't remember where I found it in the end.

Hironimo
2nd February 2006, 18:32
Thanx very much.

The LoadPluginEx can be found in the warpsharp package.

I managed to get iip 0.5a working, however I had to remove the useMMX options and the masktools 1.5.8 alone were not enough as awarpsharp was not found. I had to include aWarpSharp.dll too.

Is that ok like this ore is there a later version of iip?

I found that iip is even slower then I thought. I tried it by encoding with xvid and estimated time of an 1 hour 20 minute film were 48 hours, singlepass.

When I tried to feed the script to CCE SP 2.5 I got the error "AVIFileGetStream: error (-2147205005)".
Any ideas?

Is there a filter that does something similar as iip (let the image be more clear and sharp) but more stable and fast?

Hironimo

Didée
3rd February 2006, 12:21
I managed to get iip 0.5a working, however I had to remove the useMMX options and the masktools 1.5.8 alone were not enough as awarpsharp was not found. I had to include aWarpSharp.dll too.

Is that ok like this ore is there a later version of iip?
It's OK that way.


When I tried to feed the script to CCE SP 2.5 I got the error "AVIFileGetStream: error (-2147205005)".
Any ideas?
It's always risky to feed complex scripts directly into CCE. (Not fully sure, but I suppose it's just that CCE itself draws so much system ressources that it can't coexist with a complex Avisynth script ... if you sit two elephants on either side of a seesaw, it will break in the middle.)
The safe way is to create intermediate lossless files from avisynth, then feed those into CCE. In the end, this is the faster way, too.


Is there a filter that does something similar as iip (let the image be more clear and sharp) but more stable and fast?
Not really. iiP does many different processing tasks at once ... that's why the results look how they look, and also why it runs so slowly.

Something you could try:

orig = last
NR = orig .FluxSmoothST(7,1)
sharp = NR .LimitedSharpen(Smode=4,strength=150,soft=32,Lmode=3,overshoot=8,wide=true)

Soothe(sharp,NR,24)
However, be warned! The ultimate problem is that your source stream is from "kabel1" ... and that is one of those channels I do not capture from anymore, because the image quality is rather poor, to an amount that IMHO it's not worth to spend any time on their stuff at all ...

Hironimo
3rd February 2006, 12:37
Thanx.

I got the idea of saving it to huffyuf myself before you posted, and found mention of it in the iip thread.

My question to that: CCE cannot use YV12, so I have to convert to YUY2.
Does it make sense to use a YV12 version of huffyuf to store the intermediate video? If yes, where can I find this huffyuf?

The other question: you mentioned a later avisynth delogo script that does better. Can you point me to it?

Kabel1's quality may not be good, but its still sufficcient for me, and I am a farscape fan, so I just HAVE to create a dvd with decent quality of my recordings.

Finally: the current script is like this (I have a 16:10 monitor so I just have to change to 16:9 amamorpic to get it displayed properly fullscreen):

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mpasource.dll")
Import("F:\capture\encoding\kabel1_delogo.avs")
Import("F:\capture\encoding\iip.avs")
V=MPEG2Source("F:\capture\encoding\fpkw1.d2v",cpu=4,idct=7)
A=MPASource("F:\capture\encoding\fpkw1 MPA T01 DELAY -551ms.mpa").BufferAudio()
DelayAudio(A,-0.551)
AudioDub(V,A)
vid1=Trim(477,19706)+Trim(29053,59192)+Trim(70189,99501)+Trim(109677,142294)
vid=Kabel1Delogo(vid1)+Trim(150605,150822)+Kabel1Delogo(Trim(150823,170038))
Crop(vid,0,74,0,-74)

iip( dest_x = 720, dest_y = 576,
\ duststr = 2, dustweight = 1.0,
\ ss1_x = 1.414, ss1_y = 1.414,
\ detailcontr1= 127, detailcontr2=255+40, contr_radius=2, PixSharp=0.38,
\ ss2_x=3.25, ss2_y=3.25,
\ Xstren=255, Xlimit=255,
\ subpelstren = 1.0, antiflicker1=false, antiflicker2=true,
\ flatweight = 0,
\ protect_floor = 0, protect_bias = 12,
\ dering = -80, dering_weight = 1.0,
\ dering_floor = 10, dering_bias = 12,
\ EQ = 2, detail_floor = 15,
\ warp_Y = true, warp_UV=true, exborder = true,
\ debug="-showall", cropx=36, cropy=56
\ )

ConvertToYUY2()

I used the iip parameters you used for enterprise from Sat 1 so I thought that is adequat. I did not come around to check each parameter in detail and play with them.

I have put the other imports necessary in the iip script itself.

For intermediate encoding it might be a good idea to remove the audio processing and just put a dummy audio stream in, right?

Hironimo

Didée
3rd February 2006, 13:15
If you're not too short with HD space, I'd just put a ConvertToYUY2() at the script's end, and use normal Huffyuv. Using YV12 gives smaller files, but then you can't load the file directly into CCE, but have to frameserve & convert colorspace again, which is noticeably slower.
If space is plenty, you'll get the fastest result with huffyuv in YUY2, and set "prediction" to "left", not "median". (Median compresses the best, but is pretty slow to decompress. "Left" compresses not as much, but still OK ... and it's the fastest on de/compression.)
BTW, huffyuv compression in YV12 colorspace is possible through ffdshow.


The iiP settings should be fine like that ... perhaps lower "detailcontr2" back to 255.
However, what I can almost guarantee is that your results on Farscape will look inferior compared to my results on Enterprise ... blame kabel1 for that. (Once I started capping Voyager from kabel1 - and stopped with it immediately again, after having seen the very first episode.)

Oh, and have a look here (http://forum.gleitz.info/showthread.php?t=26534), too ... ;)

Hironimo
3rd February 2006, 13:31
Thanx for the info.

I tried to get the mentioned alternate script for sharpening to run, but it crashed virtualdub all the time when trying. So i'm sticking with iip, as I have plenty of time to do the encoding in the background and there's no rush on getting it finished.

Maybe I won't get the result you got with enterprise, but results are still decent enough for ME. I only noticed some compression artefacts which I deal with by using MPEG2Source with idct=7.
What is the problem with the quality of kabel1 in your opinnion?

The list of filters from you is really handy, thanx.

You missed to comment on my question to the latest/best delogo avisynth script, btw...

Hironimo

Didée
3rd February 2006, 13:55
You missed to comment on my question to the latest/best delogo avisynth script, btw...
No, I didn't. If you follow the link I gave you, you'll find more links. The one named "DeLogo" might be of interest for you. ;)

I tried to get the mentioned alternate script for sharpening to run, but it crashed virtualdub all the time when trying.
You need FluxSmooth and the Soothe() function, obviously ... and also the latest version (http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar) of RemoveGrain.

Maybe I won't get the result you got with enterprise, but results are still decent enough for ME. I only noticed some compression artefacts which I deal with by using MPEG2Source with idct=7.
idct=7 won't help a bit against compression artefacts. What's working against those is the cpu=4 postprocessing that you have active. That's fine for kabel1 - it will make the blurry appearance of the content somewhat more solid in its blurriness.

You might try to not use deblocking in Mpeg2Source, but to use Deblock_QED instead. It should retain more detail.

What is the problem with the quality of kabel1 in your opinnion?
Detail and sharpness. If you look very very close, you will see that ... there is nothing to see. It's "empty" of detail.

It's very similar to the difference between the "Germany" and "Austria" variants of the TV stations RTL, SAT1 and Pro7. Take a look at the screenshots in this RAR (http://home.arcor.de/dhanselmann/_stuff/comparison.rar). Having compared these, imagine that kabel1 is "three times" farther away from a satisfying signal than SAT1-Germany is ...

Hironimo
3rd February 2006, 14:53
I've looked into the delogo script.

Sadly t here is no description for this actual version anywhere I looked, namely the parameters string "name2", bool "i", bool "PP",float "amount".

This version of the script seemes to me to be in "work in progress" status due to the commented test-calls, not to mention the fixed call name2=default(name2,"G:\Temp\pva\doku_strange.bmp") which I do not like as this script is supposed to be generic.
Diese version des scripts scheint mir eher wie "work in progress" wegen den ganzen auskommentierten (test-)befehlen, auch das fixe

I like the version found in "Tutoriöser DeLogo-Guide.pdf" which is more cleaned up and and understandable...

Ofcourse I have checked the thread for details on the parameters, but could not find anything without reading the whole thing word-by-word which I do not even want to know how long it would take me.

Am I right that the above postet VD_DeLogo script can be used as it is?

Didée
3rd February 2006, 15:16
Now you've mixed up the forums ... this here actually is Doom9's, where the official language is still English.

Yes, that was/is a WIP version of the delogo-script. Moreover it seems like Eriman put a version in the package with modifications made by himself ... the "doku_strange.bmp" definetly is not from me, and also the un/commented sections are different from I had once posted. Still, glancing over the script, it should work the way it is.

PP = false/true will de/activate postprocessing.

i = false/true will de/activate interlaced processing for sources with interlaced frame strucure.

"name2" is the name of the bitmap that will be used for the final masking step. (should basically look like the repair mask, plus soft feathering outwards. white=use processing, black=use original source picture.)

"amount" actually isn't used in the script at all - I knew there was missing something.


This script needs a severe cleanup, that's for sure. :)

Hironimo
3rd February 2006, 15:38
Sorry, I know that the official language is english, its just that english is almost a second mothertoung to me so it often happens to me that I do not even realize in which language I type. I will translate the above post to english asap.

Is it even worth trying to get the latest version running or will the one in the PDF suffice?

The name2 bitmap doesnt seem to be for the original virtualdub delogo plugin as I do not recall it interprets the color white,
only black, blue and green. Is there a description on how to create it?

I'll try with the deblended for now as this matches the description you gave.

After a while now trying to get that frecking thing to work it tells me "MaskedMerge: Clip's size must be the same".
But I think I'm giving correct parameters.

Please Didée, fix that latest delogo version or let it be replaced by the latest, hopefully cleaned up version of your own.
I think it's not ok that someone else posts a changed version and posts it under your name.

I have compared the results of the version in the PDF with the one I posted here, and I find the one here yields better results.
Maybe with some tweaking of the Cmix and Lmix values that can be compensated, but the little tweaking I tried did not magage it.

Hironimo

Eri2
6th February 2006, 09:39
Oh, and have a look here (http://forum.gleitz.info/showthread.php?t=26534), too ... ;)
Nice Link ;) :D

mg262
6th February 2006, 11:33
Superb! Wiki time...