Wrapper for OpenVIP Movie Library?

Blitz3D Forums/Blitz3D Userlibs/Wrapper for OpenVIP Movie Library?

jfk EO-11110(Posted 2005) [#1]
Hi
I am still looking for a good solution to replace and enhance Movie capabilities for Blitzbasic.

I have seen there's a free opensource Video Editor "OpenVIP" at sourceforge. It also allows to use the binary library as a wrapped DLL (windows and unix versions available, c++).

As far as I see it's a very stabile and flexible movie DLL (read and write movies, and more). I think this would be ideal for blitz, so me and you we finally could write fancy Special FX apps that are using movie layers and 3D layers and finally save the whole thing. This would open a door to an entire new tools genre for BLitz3D.

since I am not very fit with wrapping a DLL for Blitz, somebody may help me, or point me to the right adresses where I can start learning this wrapping thing?

OpenVIP is here: http://openvip.sourceforge.net/


Beaker(Posted 2005) [#2]
This any use? :
http://www.harrimansoftware.com/BlitzMovie.htm


John Blackledge(Posted 2005) [#3]
This link doesn't work?
Try www.harrimansoftware.com

I've been in touch with this guy. His code does indeed work perfectly, but I've asked him if it would be possible for the code to handle multiple movies (I need multiple movie textures), and he is very kindly rewriting it as we speak.
Look out for a reissue.


Beaker(Posted 2005) [#4]
According to the link I posted (which does work for me), the multiple movies issue has already been fixed.


John Blackledge(Posted 2005) [#5]
He only emailed me three days ago to say he was working on it. Already done? Excellent.


jfk EO-11110(Posted 2005) [#6]
There's a lot more that is required, especially, but not only:

Reliable and fast direct Frame access. So you can say "Display Frame number 234". I have used MCIsendString to do that, but it isn't very reliable, sometimes it displays the requested Frame, sometimes not. WThe reason why it acts like that may be it's implemented by MS. If you're working on a Movie FX Editor, dropped frames are in NO WAY acceptable.

I'd also wish a better movie exporter than BlitzAvi, something that allows to export/add multiple frames from a bank and lets you choose the codec by code.
Additionally I'd need a tol to mux a wav to the Avi, although there may exist third party commandline tools.

The most reliable System for explicit Frame access that I have working now is: Avisynth. A avisynth script (generated at runtime) will deliver a single frame out of a movie to directShow and Blitz is capable to open it with the OpenMovie command. Problems: pretty slow (2 secs per frame) and there is also this Memory problem with OpenMovie.

Other Apps, EG. MAGIX Movie Editor can access any frame in 100 Millisecs or less, depending on the codec. A DV Codec in full PAL or NTSC Resolution can even be accessed in frealtime (30HZ) I guess they use some kind of access table so they don't have to search for a keyframe like other players (eg. Mplayer2).


John Blackledge(Posted 2005) [#7]
As far as exporting avi goes, I've used BlitzAvi succesfully.
It seems really sound and stable.
Do you have a problem with it?

I agree - sync to frame would be good. (You and I have had the discussion before about MCIsendString ;-)

I've got Magix, and yes, I don't know what it's secret is either.

But more than anything I still need multiple (albeit only 2 or 3) movies running, with a handle to each.


jfk EO-11110(Posted 2005) [#8]
Hi John

BlitzAvi is great and I use it. But I wish I could choose the codec and do the overwrite confirmation automaticly, by the app. and it would also be nice to have some Sound options. Do you know a commandline tool that is capable of adding sound to an avi?

But basicly I need fast and reliable frame access. If I once got that, the only limit is my imagination.

I guess I will also try to use BlitzMovie to open an Avisynth movie (you know, the AVS avisynth script that delivers a single frame out of an Avi). With Blitzs OpenMovie and the Avisynth script it takes 2 seconds to read a frame. Maybe BlitzMovie is faster. If I can do it in one second then I'm happy since MCISendstring takes about one second too, for "almost-reliable" access. Let me know when you want to know more about utilizing Avisynth this way.


jfk EO-11110(Posted 2005) [#9]
Well I just tried to use BLitzMovie 2.0 with Avisynth. BlitzMovie creates a BlitzCC crash when the program ends, even when it's functions are not called (I guess this has something to do with the way the userlib functions are adressed).

THe main problem is: this player will also play in realtime, no matter what. So it tends to drop frames, especially in full MiniDV resolution on my 1.6 GHz machine. Although the Movie is opened etc. in 1500 Millisecs, I have to add a wait loop to make sure the frame is delivered at all, but even when I set the wait loop to 2000 ms (3500 ms in total), it still sometimes fails to deliver the requested 1-frame movie. So its reliability for my purposes is of no use.
I keep on searching. Maybe I should try MCISendstring together with AviSynth?


John Blackledge(Posted 2005) [#10]
HI jfk,

"But I wish I could choose the codec and do the overwrite confirmation automaticly"
- Windows is probably not going to let you do that automatically. It has to search for codecs then offer them to the user (- you did spot that function, didn't you?).

"Do you know a commandline tool that is capable of adding sound to an avi?"
- Sorry, no.

"BlitzMovie creates a BlitzCC crash when the program ends"
- The author's currently rewriting it. If I hear anything I'll keep you posted.

"it still sometimes fails to deliver the requested 1-frame movie"
- Unfortunately I have no need to get a single frame, so I've not investigated this sort of functionality.

"Maybe I should try MCISendstring"
- Like you I'm really frustrated about MCISendstring.
I used it for years with varying degrees of success (professionally for 8 years) but it always was a pig.
It's multi-tasking really is mutitasking: you issue one instruction and before it can complete it, it's already tackling the next. Usually the "wait" parameter cured that, but probably now screws up since MCI's probable point of view is that the Blitz window is a DOS window (?).

Ongoing frustration for everyone who needs to use movies.

I've emailed Blitz Support (a couple of months ago) about the memory leak in OpenMovie()/CloseMovie(), but no reply so far.


jfk EO-11110(Posted 2005) [#11]
Well let's recapitulate this - the memory leak - is it really a problem?

I have a radeon 9200se with 128 megs. Not a big deal, but it should work.

I can play an Avi about 70 times, then my Vram decreased to 12 megs. Then it remains stabile on 12 megs, I can continue replaying the movie, there seems to be no impact.

Now with this 12 megs left I will now create a 3D scene, containing 21 spheres and each one with a 1024^2 texture. Hey! it really works. Although, kind of a strange framerate:
40 fps.

Now I do the same 3D scene without to play the Avi in the first place, all of a sudden I get 125 FPS!

This means - yes, there is a serious loss and DirectX or whatever tries to utilize some "other" memory, probably emulating VRam in the system Ram?

In my situation, where I want to use OPenMovie to read in a single frame from an Avi (extracted by the Avisynth Frameserver system plugin) this is fatal. I can edit 70 Frames, then I run out of Vram :(

The only thing you can do to give back the Vram is: EndGraphics. But this doesn't seem to be a practical solution.


John Blackledge(Posted 2005) [#12]
I can see that you have a particular usage, but yes, the memory leak has reared its ugly head again.

One user reported leaving a looping avi running (constantly using CloseMovie()/OpenMovie() to loop as recommended) and eventually his system locked up.

Basically I wanted to be able to create user-defineable billboards (TVs, actual billboards etc) in my app, but now I have to explain this in my helpfile as 'not recommended due to a system/driver fault, hopefully will be fixed in the future'. Yuk!


CopperCircle(Posted 2005) [#13]
I would pay for a wrapper for OpenVIP, I really want to be able to create video effects also.


jfk EO-11110(Posted 2005) [#14]
CopperCircle - after some time of testing I think OpenVIP may not be the best choice for us. When you run the oringinal OpenVIP Editor, you'll notice that it's relatively slow when it has to jump to a certain frame. Of course, this is depending on the Codec used, but since I am using nonlossy HuffYuf a lot to prevent degeneration, it's real slow.

There is a method using Avisynth and MCIsendString together: A temporary Avisynth script is opened as a movie by MCI, but the script only sends one single frame (the wanted frame). This way, MCI couldnpt mess things up, and it would send the right frame, no matter what. The only problem I see right now, is: In BLitz I can grab the MCI Canvas video frame in fullscreen only, in windowed mode it simply didn't work. Then again, BlitzAvi that is used to save the Avi, requires windowed mode unless you want it to become frozen. In my current tool DrGreen I had to use some real weird tricks that will minimize and maximize the fullscreen app using some WinApi commands to make BlitzAvi work in fullscreen. Additionally it's pretty tricky to make the Api Alerts and Prompts work with the fullscreen Mode (see code archives, coordinated Flip).

Well, in DrGreen I used an extreme amount of complicated tricks, only to be able to access video frames. And after all, MCI isn't reliable at all, instead it misses/drops frames, something that is completely inacceptable.

I would be willing to use a commandline tool (eg. Avi2wav) that will seperate the Audio and Video of an Avi, then edit the frames only, then save it without Audio (eg. using BlitzAvi), then use some third party Avi Muxer that will mix and save the original Wav with the new Avi. I'm pretty sure there are several tools that are capable of this.

I still think if you want to access single frames as quick as possible, you (or the video reader) should use some kind of access table, in the best case with a SEEK adress for direct frame access, in the worst case a SEEK adress to a keyframe that is the basement for the wanted frame.

I am still thinking about to write my own AVI reader, and maybe I would accept a limitation in the number of possible codecs, since basicly it's an inhouse tool.

What do you think Lee, should we try to write an Avi reader that is using optimized access with adress tables? If so, I'd really suggest to use two nonlossy formats only: completely uncompressed and HuffYuf. Because, usually you are editing small scenes, a few seconds only, so the size isn't a huge problem. Using Huffyuf for example would allow to use max. 2GB files (at least on Win98 etc.), that's about 1.5 Minutes in full MiniDV resoltution, including sound.

The source to the huffyuf decoder/encoder is available for free from here:
http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html
I'm not a C++ expert and I don't know how useful this would be, maybe somebody have a look.
Other than that, I guess it can't be that hard to write an Avi Reader for uncompressed Avis. and isn't it the way a lot of pro tools use uncomressed Avi anyway?


jfk EO-11110(Posted 2005) [#15]
I just see Blitz3D Update 1.91 is out, with a fix for the movie leak problem!! This will probably solve most problems.


CopperCircle(Posted 2005) [#16]
jfk, thanks for all the info, I will look at the huffyuv stuff, I also only want to work with none lossy formats, miniDV or HD.


CopperCircle(Posted 2005) [#17]
jfk, do you have a binary of the latest CVS of OpenVIP?, I don't have the software installed to build the CVS at the moment and the old binary seems to crash on my system when using some filters.

Thanks.


jfk EO-11110(Posted 2005) [#18]
CVS? help me, what's that again? Concurrent Versions System?
Not sure what you are talking about. I just downloaded an installation package. I may have the same binary as you have too.
And I have to say, I experienced some crashes with OpenVIP too (used with the Gui), so I never meant to use it as a tool. I only wanted to make use of it's frame access. Creating Filters with Blitzbasic was the goal, and a sweet one too.

Currently I am using the following pipeline, that actually works, slowly but reliable:

I have installed Avisynth (>=2.5.something). If you don't know: it's a frame server that allows a lot of filter and convertion stuff to do in realtime, using scripts. so when you open a AVS script with OpenMovie(), Avisynth actually opens the scripted avi file, adds some stuff, depending on the script, then sends the modified frames one bye one to the Opener, that may be Blitz3D. There always need to be an Opener/Movie-Client. a script cannot be "executed" without a Client App that is reading "the movie".

Ok. Right now I use MciSendstring to determine the lenght of the Avi in frames.
Now since I want to edit a movie frame by frame, without to drop frames, I need to access single frames. So I write a little temporary AVS script using Writefile in Bitz, containing the following lines:

DirectShowSource("mymovie.avi")
Trim(frame_number,frame_number)


Avisynth will now open the avi and play a part of the avi, beginning at the first parameter, ending at the second parameter. As you can see they are the same here, cause I only need one frame. It works, but it's real slow. Depending on the avi codec and movie size (in pixels), up to 2 seconds.
BTW Avisynth seems to have problems with Huffyuf Avis without audio. When they have audio it seems to work nicely.

Let us assume I have written an AVS script file named "temp.avs", then I simply had to

m=OpenMovie("temp.avs")
if m<>0
 drawmovie m
 closemovie m
endif

Now I can grab the frame accurately and reliable from the backbuffer.

Even if it's so slow, it's still great fun. You can do a LOT. Use 3D, sprites, particles whatever. I just made some slowmotion stuff, using frame interpolation. While the time stretch mode in MAGIX is crap because it will only double frames (ignoring interlaced fields), I was able to split Bottom and Top fields, use a Deinterlace filter on the split fields to get 2 full frames out of them. So I already got half speed at 25 Hz. Now I still can interpolate these frames to get some real smooth slomotion, something you rarely see in video productions. (I'd also suggest to use some kind of delay mix of the interpolated sequences, with a delay ghost on every tween frame, needless to say this eats some tracks on the timeline).

Ah, well, uh now I gave some answers to questions nobody ever asked :)


CopperCircle(Posted 2005) [#19]
I want to be able to create filters using Blitz too, the slow mo thing your working on sounds great, will you be releasing any code or selling your filters? Im looking to create new and different looking video effects.

Im trying to get a Sobel edge detection filter working.

Thanks.


jfk EO-11110(Posted 2005) [#20]
well yo know this slomo thing is really very trivial. It even has no gui, I'll probably control it over the commandline. But of course, I can send you the source. As I said before, it's slow (coffee-break task) and you need to have Avisynth installed.

Doing some experinemnts with filters is sooo cool, many times I get some new FX by accident. Like, when you have to rename whatever.bb to predator_fx.bb :)

I am using a simple trick to deinterlace images. well it's not the best deinterlacing, but at least it's fast: Simply resize the image to the half height, then resize it back to full size. I am using the quick resizing method posted in the archives that is about 120 times faster than the internal 2D resize (using 3D).

The point is, if you once got a frame on the backbuffer, the only limit truely is your imagination :)

EDIT > sent email.