Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
![]() |
#21 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
Like I said, you can use the call plugin to run a batch script or whatever, but it's only run once before the script starts.
Here's how to read and plot pixels: Code:
Function GetPixel(clip clip, int x, int y) { #Return luma of a pixel current_frame=0 clip IsYUY2 ? ConvertToYV12 : clip#AverageLuma only works on planar. YV12 is planar. pointresize(6,6,x,y,1,1)#Blow up the pixel at x,y by 6 times (minimum possible with resize) int(AverageLuma) } Function PutPixel(clip clip, int x, int y, int luma) { #Plot a pixel clip ClipIsYV12=IsYV12 ClipIsYV12 ? ConvertToYUY2 : last pointresize(width*2, height) u=128 v=128 pixel=blankclip(last, color_yuv=luma*65536+u*256+v, width=2, height=1) layer(last, pixel, "add", 256, x*2, y)#Layer only works with YUY2 pointresize(width/2, height) ClipIsYV12 ? ConvertToYV12 : last } The array implementation in avslib is quite slow. I have the same thoughts of a meta-data per-frame with another clip; but it could be added at the bottom. The garbage in the last few lines can be be cropped out. You can extend this to RGB with showred.converttoyv12 for example. You could also make a kind of array in a clip by plotting pixels and reading them. My slicer and addcode plugins can also read and plot int's on a line of video. http://forum.doom9.org/showthread.ph...74#post1582574 for myself: keywords pset, plot, plot a pixel, plot(x,y), pset(x,y) edit: thank you me! I swear, this is the 5th time I've searched for this post. Last edited by jmac698; 1st March 2015 at 12:30. |
![]() |
![]() |
![]() |
#22 | Link | ||||||
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
Quote:
I don't deny that object oriented programming is very useful in many scenarios, but pretty much none of its big features (inheritance, encapsulation, polymorphism, data abstraction) are of any particular use for video processing. Complain about Avisynth script all you want, but the dataflow/graph paradigm was definitely the correct choice for the kind of video clip manipulation Avisynth was intended for. As for writing actual video filtering functions, you pretty much have to do that in a low-level compiled and unmanaged language in order to get it fast enough, and when you're on that level you pretty much work with plain byte arrays, so there's really no point to object-orienting anything. Doing individual pixel manipulations in an interpreted language/managed code environment isn't really very useful in practice because even on modern hardware it's REALLY SLOW for any resolution bigger than a postage stamp, and at the time when Avisynth was designed it was, of course, a completely ridiculous idea, so the scripting language really doesn't try to help you when it comes to that kind of stuff. Quote:
Quote:
Quote:
Spoiler: the pattern is "don't use a simplistic graph description language if what you really want is an unmanaged environment that lets you poke arbitrary byte addresses". If you want C, write C. Quote:
Avisynth scripts are not executed. The script is compiled, yes, but the result of the compilation is a chain of filter functions, not a program that is executed. Absolutely nothing happens with it until the host application (which loaded the script) requests a video frame. At that point, Avisynth pulls the frame through the function chain, and it's only at this point that things happen in "filter" functions that have side effects (i.e. ImageWriter). In other words, if you want to call a function on each frame of a clip, you need to make sure all frames of that clip are actually requested, either directly by the host application or indirectly via something in your script (careful with that though, you may or may not run into funny issues if frames are requested multiple times). Your idea that the environment should execute scripts imperatively is, of course, completely ridiculous. Just try thinking it through for a while and you'll probably realize why it's completely wrong to try to process an entire video clip procedurally instead of via a per-frame callback-driven data flow (just think of what kind of memory footprint a source filter that returns an entire clip at once would have). Incidentally, your idea would require changing so much of Avisynth that it'd be easier to just rewrite the entire thing from scratch. Last edited by TheFluff; 6th August 2012 at 18:12. |
||||||
![]() |
![]() |
![]() |
#23 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,877
|
@TheFluff,
Excellent Tutorial ![]()
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#25 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,877
|
Quote:
Quote:
Code:
a=ImageSource("sm444.png") a.subtitle("not rendered").ImageWriter("not_rendered", type="png") a.subtitle("rendered").ImageWriter("rendered", type="png") by following line), so the result is never used (neither is the source of the result, ie 1st ImageWriter, nor the source of that ie the 'not rendered' Subtitle) as it plays no part in the output. a simple Code:
a=a.subtitle("not rendered").ImageWriter("not_rendered", type="png") "not_rendered" on it and the other with "rendered", assuming that you actually want two different outputs with two different subtitles, then you would need to somehow use the result of the 1st ImageWriter line in the second. (The problem here is there is only one output, but you want to have a clip with two different subtitles, and not one overwriting the other nor one without and one with a subtitle. [in the words of a famous movie script, 'There Can Be Only One']) There are any number of ways this could be done, eg Code:
a=ImageSource("sm444.png") Tmp = a.subtitle("not rendered").ImageWriter("not_rendered", type="png") dummy = Tmp.FrameCount() dummy = dummy - dummy a.subtitle("rendered").ImageWriter("rendered",start=0+dummy, type="png") EDIT: The dummy arg forces the 1st Imagewrite chain to be processed as the output is reliant on both subtitled paths through the graph, the advantages are that it is a highly efficient way of selecting what is and is not necessary due to various conditions, but results in seemingly silly kludges to force 'side effects' to occur. Avisynth could well do some things better, but is quite remarkable in what is does and the filter graph model itself is in no need of change.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 6th August 2012 at 22:56. |
||
![]() |
![]() |
![]() |
#26 | Link | ||
Registered User
Join Date: Sep 2011
Posts: 86
|
Quote:
Quote:
This one works for me Code:
a = ImageSource("sm444.png") a0 = a.subtitle("not rendered").ImageWriter("not_rendered", type="png") a1 = a.subtitle("rendered").ImageWriter("rendered", type="png") stackhorizontal(a1, a0).crop(0, 0, a1.width, a1.height) |
||
![]() |
![]() |
![]() |
#27 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,877
|
Perhaps a "Return me a zero", and "Return me a one" should be added to the clip status returns
so you dont have to be silly and be so creative. Was hard to tell what comment you were replying to, sorry, got it wrong. The '???' was a clue but I EVENTUALLY got it wrong just the same, Shoot me!
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 7th August 2012 at 01:48. |
![]() |
![]() |
![]() |
#29 | Link |
Registered User
Join Date: Jul 2012
Posts: 7
|
Thanks, for the replies, guys.... I have had my hands full with a big event, I'll have more time later today or tomorrow.
Fluff, As far as script execution goes you're arguing terminology -- I get it; it's event driven, the processing or "execution" of the various commands happens when a frame is requested. |
![]() |
![]() |
![]() |
#30 | Link |
Registered User
Join Date: Jan 2006
Posts: 1,867
|
And here's how to "execute" an Avisynth script without showing any frames:
http://forum.doom9.org/showthread.php?t=165528 You could wrap this all up into a program that processes text files, and never know it had anything to do with video. Rename it "sh.exe" and no one would be the wiser! |
![]() |
![]() |
![]() |
#31 | Link | |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
Last edited by TheFluff; 9th August 2012 at 00:51. |
|
![]() |
![]() |
![]() |
#32 | Link | |
Registered User
Join Date: Jun 2009
Location: UK
Posts: 262
|
Quote:
Avisynth has some flaws, sure, but "not being a totally different animal" isn't one of them! I'm going to have to agree with the overall concensus here and say, if you want a tool that works in a completey different way to AviSynth, then use a tool that isn't AviSynth. If the tool you want doesn't exist yet, then start recruiting a team to create one. (Hint: Annoying the people who might very well be glad to join such a team by denigrating the work they've already done on another project is probably not conducive to succesful recruitment!). If you can figure out how to make the new tool compatible with Avisynth plug-ins, you (and your users) would get the benefit of all the work that's already been done over the last decade in creating a huge variety of awesomely powerful video processing tools. You could even give it an Avisynth-like syntax, if you think that would be helpful... But you would probably find that designing an appropriate syntax to suit the way your new tool works would be better. Good luck! ![]() |
|
![]() |
![]() |
![]() |
#33 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,430
|
[Catching up on recent threads after a long absence]
Quote:
You need something that forces rendering of the frames, such as gyth's example: |
|
![]() |
![]() |
![]() |
#34 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,877
|
Thank you Maestro,
glad you're back, think D9 was about to go into mourning. ![]()
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#35 | Link |
typo lover
Join Date: May 2009
Posts: 595
|
why don't you use ImmaAVS?
ImmaRead() has 'size_x' and 'size_y' options to resize/pad automatically to the size you specified.
__________________
my repositories |
![]() |
![]() |
![]() |
Tags |
file i/o, frame, imagesource, imagewriter, metadata |
Thread Tools | Search this Thread |
Display Modes | |
|
|