Quantcast Avisynth: Script Speed up Possible? - digitalFAQ.com Forums [Archives]
  #1  
10-26-2004, 09:22 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Could anyone recommend ways to make this script a little faster? I`m not sure if it is possible but I`ve got it from 5 fps to 8 fps when encoding it to mpeg with FreeEnc and I`m hoping that an expert opinion could maybe eek out a bit more speed.

The script is between asterisks....

********

# red shifter (3d anaglyph?)
# this script shifts the red channel up and
# to the left an arbitrary amount of pixels

# load plugin that takes 29.970 fps source and converts to 25 fps
LoadPlugin("C:\AVI\plugins\decomb510.dll")


audio=AviSource("C:\AVI\video_data\video.avi")
audio=ConvertAudioToFloat(audio)
audio=SSRC(audio, 48000)

# load left and right sources
source=AVISource("c:\AVI\video_data\video.avi")
# Right source is same as left but one frame behind to show movement
source2=trim(source, 1, 0)



# if the source is yuv it needs to be converted to rgb
source=ConvertToRGB(source)
source2=ConvertToRGB(source2)

# split the red and cyan channels
red =RGBAdjust(source, 1,0,0,1)
cyan=RGBAdjust(source2, 0,1,1,1)

# overlay
video=Overlay(cyan,red,-4,-3,opacity=0.5,output="YV12")

# optionally crop and tweak
video=Tweak(video, sat=2,bright=2,cont=2)


# video=ConvertToYV12(video)

film=AssumeFPS(film, 25.000, true)
return(film)

********

The original script I found posted anonymously on an old 3d site, it simply shifted the red for one video to produce a really good anaglyph effect. I amended this to make the film a combination of two sources (identical avi) but with one started a frame later so that you get a true 3D effect based on the movement difference between the frames.

Trouble is I can`t make it speed up. Any help would be really appreciated
__________________
Dave
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
10-26-2004, 09:38 AM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
Remove all part concerning audio, you really don't need that !
The audio is processed outside freenc.
Reply With Quote
  #3  
10-26-2004, 10:39 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
I did as suggested but it didn`t change the encoding rate, stays at 8fps.

I think maybe I`ve got it as fast as it can go then

Thanks for the idea!
__________________
Dave
Reply With Quote
  #4  
10-26-2004, 10:42 AM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Mental
I think maybe I`ve got it as fast as it can go then
Your script has to work in RGB that is 50% slower than YUY2, that is already 30% slower than YV12... do the maths...
Reply With Quote
  #5  
10-26-2004, 11:04 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts

Phil, it means that tmpgenc is slow comparing with CCE cos the "colorspace" convertion turn the time to encode worse too?
Reply With Quote
  #6  
10-26-2004, 11:28 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Dumb question I suppose but is there any way of doing the same colour adjustment (the rgbshift type) but in yv12?

I don`t think there is but I can ask
__________________
Dave
Reply With Quote
  #7  
10-26-2004, 12:13 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by jorel

Phil, it means that tmpgenc is slow comparing with CCE cos the "colorspace" convertion turn the time to encode worse too?
Not at all. Tmpgenc is slow because it is badly coded. I guess that if they had choose an other colospace to work, the result would have been the same.

@Mental
I don't think it's possible.
Reply With Quote
  #8  
10-26-2004, 03:27 PM
rds_correia rds_correia is offline
Free Member
 
Join Date: Apr 2003
Location: Chinese Democracy starts now!
Posts: 2,563
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Dialhot
...Not at all. Tmpgenc is slow because it is badly coded. I guess that if they had choose an other colospace to work, the result would have been the same....
Always our Phil, sharp like a knife but most probably right on this one - as usual BTW.
__________________
Rui
Reply With Quote
  #9  
10-26-2004, 03:57 PM
Boulder Boulder is offline
Free Member
 
Join Date: Sep 2002
Location: Lahti, Finland
Posts: 1,652
Thanks: 0
Thanked 0 Times in 0 Posts
RGB is somewhat slower to process than YUY2 or YV12 due to the larger frame size (needs more memory and more calculations) so that contributes to TMPGEnc being slow. I think that TMPGEnc's internal filters work in RGB24 colorspace and that's why it is used as an intermediate colorspace before encoding to YV12. A very stupid thing to do IMHO - at least they should have went straight to YV12 by now. I don't know why CCE needs YUY2 data, maybe it's also due to the internal filters?
Reply With Quote
  #10  
10-27-2004, 03:43 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Ligh had a mail exchange with CCE Team and the answer related to YUY2 input was "like" this:

The problem is that YV12 sources do come as progressive and interlaced BUT compared to YUY2 ... there are diff. in YV12 interlaced descrip. compared YV12 Progressive decriptions which cant be recognised by a flag or ForCC. That would be mega risky for a well "professional" recognission by the encoder and so they made the risk almost "off" by forcing the input to YUY2.
THATS also why a XVID decoder (even if he knows encoding YV12 interlaced) CANT decode YV12 interlaced well .. repsective the system internal routines cant to that Stair artifacts in red edges on interl. YV12 streams in previews using no matter which movieplayer appl.
Also on SAP XVID players!! as most of them cant decode YV12 interl. properly and now you can assume how they do look on tv!

Related to TmpgEnc ... it's the mix between bad core in the code AND the internal RGB24 colorspace. Cause if it would be only the RGB24 space than Vdubs filter would be even more slow (RGB32) but actually they are fst as hell "compared!" to tmpgEncs internal filters.

TmpgEnc coding/develop. Team liked more to force on doing cosmetics on Userinterface then cleaning up or developing the core code. Not mention that silly senseless changes in tpr file syntax etc. worst decision IMHO. ------ Dont they do look/spy into mpeg communities??? Like other manages do read management based special interest magazines??
Reply With Quote
  #11  
10-27-2004, 03:58 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Is it possible to do scene detection with avisynth?

This script is great but because it shifts the second image forward by one frame it means on each scene change there is a sudden flash of red where you see the previous frame (when viewing at normal speed it just appears to be a brief red flash).

I would like to be able to remove these frames. Is it possible to make it so that when a scene changes the bright flash frame is deleted?

Thanks.
__________________
Dave
Reply With Quote
  #12  
10-27-2004, 04:08 AM
Boulder Boulder is offline
Free Member
 
Join Date: Sep 2002
Location: Lahti, Finland
Posts: 1,652
Thanks: 0
Thanked 0 Times in 0 Posts
See the Avisynth docs, section "Runtime Functions".
Reply With Quote
  #13  
10-27-2004, 04:18 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
ot

my hope:
i always save in HDD all interesting posts and threads from the forum.
the last posts here have more weight than thousands posts in the whole forum and i hope that some day my english and knowledge encrease reading this posts thousands times if needed.
boys,
do you can feel how much you can encrease the knowledge of this forum
simple answers and quesyions from you deserve a compilation to build the "kvcd forum mind" as FAQs....this posts and explanations can't be faded without reference for future consultations. you, and some more members here, are the live mind of the forum. take care of your knowledge that don't have price and build a compilation.
maybe you all still don't understand the weight of your knowledge....
i can't understand everything cos my english don't help and translators loose the sense but i can feel your knowledge flowing in wise posts.
don't let it all loose in posts that will be faded.
do something to compile and preserve it all!...
you're great and still don't know it!

ot ? this is not ot ! you're here are the topic.

and THANKS for all....like i always post and it's not
"automatic words" to post,..... is my real feeling!

thank you boys!!!
Reply With Quote
  #14  
10-27-2004, 04:19 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Quote:
Is it possible to do scene detection with avisynth?
Yep its possible by calculating the diff. between Ydifferencefromprevious() and Ydifferencetonext() .. if the diff. is ove a threshold, then a scenechange happened.

BUT: Thats not the solution in YOUR case as that chroma shifting technique above is mega unprofessional.

Here two solutions: http://www.geocities.com/siwalters_uk/chromashift.html
http://www.avisynth.org/MoveChroma

BUT:

in RGB = Chroma shift by MOD1 is possible in all directions.
in YUY2= Chroma shift only by MOD2 is possible in the width and by MOD1 in the higth.
in YV12= Chroma shift only by MOD2 is possible in the width and also by MOD2 in the higth.

(Mod1= devidable by 1 and MOD2 devidable by 2)

why??
Cause RGB in its chroma gots the the same resolution as in the luma.
YUY2 gots the HALF chroma horizontal resolution compared to Luma.
YV12 gots the HALF chroma horizontal resolution AND the half chroma vertical resolution compared to Luma.
http://www.mir.com/DMG/chroma.html
Reply With Quote
  #15  
10-27-2004, 04:34 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Eek! Is it possible to do something easier than and just detect the frame has excess red then reduce the red in that frame?

The problem is that when a scene changes the previous scene flashes up mixed in coloured bright red. Because it is brighter it is more noticeable. Reducing the red would solve the issue (I hope) because then there is no excess red to attract the attention.

I`ve looked through the docs but cannot figure out how to do what I want to.

Ideally I would like to check if the red level in the current frame is excssively higher than the previous. If so I could adjust the level in the current frame and this would make it un noticeable and hopefully reduce the effect.

Alternatively is it possible to just say "if the level of red is above x amount in this frame reduce it?".

I`ve no problem playing around with settings but I just don`t know how to start. Is it even possible to adjust the red level of one frame and swap the current frame for the adjusted version?

Thanks for the help, and the speed of reply
__________________
Dave
Reply With Quote
  #16  
10-27-2004, 04:47 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
???? Still on that Scenechange trip???
read my post.

or .... whats your real intention????

Do you want to "shift" the chroma plane or "tweak" the chroma channels according to their intensity???
Reply With Quote
  #17  
10-27-2004, 05:28 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
I would prefer to simply reduce the red level for frames that are much redder than the previous frame.

It sounds simple but is that as easy to do as it sounds?

The script itself is brilliant, because of the difference in movement between frames you get a genuine 3D result and the only annoying thing is the sudden red flash.

Thanks, again
__________________
Dave
Reply With Quote
  #18  
10-27-2004, 05:56 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Mental
I would prefer to simply reduce the red level for frames that are much redder than the previous frame.

It sounds simple but is that as easy to do as it sounds?
maybe....
http://www.avisynth.org/RGBAdjust

Reply With Quote
  #19  
10-27-2004, 06:21 AM
Mental Mental is offline
Free Member
 
Join Date: Sep 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Jorel.

I know I can use the rgb adjust, what I don`t know is how to check if the level in the current frame is much higher than the previous, and how to adjust the current frame without affecting the rest of the avi.

I`ve read the docs, essentially what I want to do is say "If the amount of red here is much higher than the previous frame lessen the red in this frame" but I can`t see how it can be done.

I know how to use the adjust, which as you suggest is what I need to reduce the red in a frame, but not how to check and replace an individual frame like:

If amount_of_red_in_frame>x THEN frame=RGBadjust(x,x,x)

Thanks for any ideas, and those already given
__________________
Dave
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: Way to measure filter speed? supermule Avisynth Scripting 8 04-05-2006 04:25 AM
Burning at low speed vs. high speed LeeKuid Blank Media / Burning Discs 11 12-07-2004 11:46 AM
Avisynth: Speed comparison shibumi Avisynth Scripting 7 05-10-2004 08:14 AM
Avisynth: CCE encoding Speed? Omega Avisynth Scripting 5 12-31-2003 12:58 PM
Avisynth: Don't add borders to increase speed ? phibertron Avisynth Scripting 7 05-29-2003 10:47 PM

Thread Tools



 
All times are GMT -5. The time now is 04:08 AM  —  vBulletin © Jelsoft Enterprises Ltd