View Full Version : GUI Filter problems, how can i access videodata
hanfrunz
18th August 2004, 14:01
Hello,
i have a problem. I want to make a new GUI-based filter. The aim is to press a button on the GUI and then store the videodata to somewhere else (to a file or copy to clipboard). But how can the GUI access videodata? Normaly i do all the programming in myfilter::GetFrame and then change data in the GUI etc. The problem is that now two apps must talk to avisynth the mediaplayer (or whatever) and my GUI.
So i think it should work, if the GUI gets itself part of the myfilter class, but how can i do this?
@sh0dan have you done something like this in you tcpdeliver filter? Where can i get the sourcecode of that btw? sourceforge-web-cvs seems to be down :(
thanks
hanfrunz
sh0dan
18th August 2004, 15:07
TCPDeliver Source (http://83.90.202.89/kpo/TCPDeliver.zip).
TCPDeliver is multithreaded. If you could help me show the already prepared GUIs, when the filter is invoked, I'll spend a lot of time helping you here! :D
TCPServer:
When the filter is created it immediately spawns a new thread. This new thread is given the "PClip child" which will deliver the frames to the server. The filter itself does nothing, and just passes through frames.
This might be simply what you need.
TCPClient:
This is a bit more complex. There is also spawned a thread when the filter is called. This thread handles all communication with the server.
When the filter is created, these states occur.
* TCPClient filters is created.
* TCPClient creates a TCPClientThread object. (not as a thread yet)
* TCPClientThread connects to the server.
* TCPClientThread creates Events for communication.
* TCPClientThread spawns a new thread "StartClient(LPVOID p)"
* The new thread enters the "StartRequestLoop()"
* "StartRequestLoop()" blocks until is recieves a "evtClientReadyForRequest" Event.
* When the reply is ready from the RequestLoop, it will set the "evtClientReplyReady" Event.
When the TCPClient filter has a request, it signals the TCPClientThread with the event, and the second thread will do the request and recieve the data.
This also enables async communication, and is used for prefetching frames while the computer is still processing the last frame.
hanfrunz
18th August 2004, 16:13
mmmh i think the problem is that we both just use the "stolen" code from avsmon :-) maybe we should read a book about windows-gui-programming...
I don't even know what this code does exactly, for me it just works...
Was there a point, when it works for you? Wasn't there a version with gui?
My problem is that the export of a frame has to be done in the myfilter::GetFrame object, because thats the only object which is called every frame, but if you are in pause mode and press export frame nothing happens until i step a frame forward/backward... so the second thread (the gui) should also be possible to get data somehow...
So i think we should try to put the whole GUI-stuff in the myfilter object, so we have acces to the IScriptEnvironment-thing...
hanfrunz
sh0dan
18th August 2004, 18:59
Well... My first problem is popping up the window, but I guess I'll just have to dig a bit more around SimpleGUI/AvsMon. ;)
Anyway. I think you'll be the best judge of what's easiest, since you have the code, but you could also pass env to the GUI. But I'm not quite clear on what you're trying to achieve and what the problem is, so you'll have to help me a bit more on what your problem is.
hanfrunz
18th August 2004, 20:03
okay here is what i want to do:
i am writing a filter see here (http://forum.doom9.org/showthread.php?s=&threadid=80859)
You load the filter in the normal avisynth script:
example.avs:
SetMemoryMax(0) # don't use the avs-cache
avisource("somemovie.avi")
converttorgb24()
GUIFrameSubstitutor("inifile.ini")
inifile.ini:
1
2
3
4
10
100
what this filter does:
If one of the frames in the inifile (1,2,3,4,10 or 100) is requested it does not return the source, but the content of a file called [number].bmp
This part is working fine without problems.
The next part is that there is a GUI, right now the GUI is a textfield where you can read the actual framecount and a Button. If you press the Button the actual frame is marked to be substituted with a .bmp and the actual frame will be exported to a .bmp. This works too, but with limitations. That's because all the exporting routines are part of the GetFrame object. The GUI just writes a value to a global varible, if the button is pressed, so i check in the GetFrame if something has happened. If you press pause on your favourite avi-player and then press the button on the GUI, nothing will happen until another frame is requested. And always the wrong frame is exported, but this can be solved if i the GUI stores the framenumber, too. So my main problem is that the GUI can only talk to the GetFrame-object and has no access to the videodata itself. I tried to pass the env but then i got errormessages (can not access non-/static object or something like that).
My idea is to put all the GUI-stuff in the filter-object then i could access all the data i need...
I also tried to write a object called ExportFrame, which was very similar to the GetFrame, but is only called by the GUI, but i was not able to make it work :(
I will do my very best to solve this problem, but if anobody has a good idea...
hanfrunz
tritical
19th August 2004, 04:19
This may be completely wrong so bear with me if it is :). One thing I think you could do, if I understand the problem correctly, is make a pointer to the instance of your filter as a global variable (as Kurosu did in his filter). You would then have access to this inside your message handling code (though it would definitely screw up multinstance handling). You could then code a method in your filter class to do what you want and call that from your dialog message handling code. The big problem remaining is if you want to do something with the actual video... cause to call getframe() you need iscriptenvironment and as was shown in this thread: http://forum.doom9.org/showthread.php?threadid=71079 using a global IScriptEnvironment isn't a good idea (maybe if you updated it on every getframe call?). However, if I understand your needs correctly (i.e. you only need to have access to the previously processed frame), you could use a very easy workaround. Make a PVideoFrame object a member of your filter class. On each getframe call, BitBlt the currently processed frame into your PVideoFrame object so you have a local and independent copy. Then you can access that copy (a copy of the previously processed frame) inside the method you call from the dialog message handling code. Anyways, just an idea... there are probably better ways to do it and it would be more work then simply keeping track of the frame number.
Apparently Kurosu's post disappeared right before I posted this??
tedkunich
19th August 2004, 21:45
Originally posted by hanfrunz
okay here is what i want to do:
i am writing a filter see here (http://forum.doom9.org/showthread.php?s=&threadid=80859)
You load the filter in the normal avisynth script:
example.avs:
SetMemoryMax(0) # don't use the avs-cache
avisource("somemovie.avi")
converttorgb24()
GUIFrameSubstitutor("inifile.ini")
hanfrunz,
Any progress on this yet? I'd be very keen to beta and/or try out your filter - even in this prelim state with reading in from an ini file. I am in the process of writing out all the bad frames from my capture and was not quite certain how I would get all of those touched up frames back in... this tool simes like it would be a perfect fit. My LD's have a lot of laser rot and there are quite a few frames that most of the other spot removal filters cannot handle well....
T
hanfrunz
19th August 2004, 22:35
okay everyone. i have bad news and good news:
good news: the first beta version is working, but still with a lot of limitations.
bad news: i will go on holiday for a week tomorrow (without a computer!)
so i will post the first version in a few hours. I have to clean up the code a little bit...
BTW: how can i start photoshop.exe or any other programm out of a avisynth filter? In powerbasic i would just use SHELL "photoshop.exe"
[EDIT] its very simple:
#include <shellapi.h>
ShellExecute( NULL, "open", "C:\\Adobe\\Photoshop CS\\Photoshop.exe", NULL, NULL, SW_SHOW );
hanfrunz
Fizick
19th August 2004, 23:31
Look at these thread:
http://forum.doom9.org/showthread.php?s=&threadid=46506&highlight=call+plugin
hanfrunz
20th August 2004, 00:04
ahh i will check that!
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.