Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: DocBass on September 24, 2006, 08:15:06 AM

Title: Theora questions
Post by: DocBass on September 24, 2006, 08:15:06 AM
After doing the prerequisite searches, I still have a few questions. It appears that theora using the VLC player conversion is pretty bad. So that isn't an option. Using ffmpeg2theora results in a beautiful, clean looking file that blends perfectly where it matches but its resized wrong and doesn't exactly match up everywhere with the backgrounds. So am I stuck then? Using this theora video from ffmpeg2theora reduces file size immensly over sprites and it actually looks better with what I am using. If I couldnt use it because of a silly bug in the conversion process I would be quite disappointed...

Also the video entity appears on top of the actor no matter where it is located in the scene editor.
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 08:59:04 AM
Upon closer examination it doesnt appear to be resized. It appers that a black strip is being added almost at the very bottom of the video. This video does not appear this way if you watch it on its own. It appears to match up with the regular video just fine, and everything around it matches it up when put into the scene. It appers to only do this in WME. I have a screen grab of this if you would want to see Mneumonic. Also still having the problem with the video appearing on top of everything.
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 10:17:55 AM
One more update. The video is size 464x608 while the scene is 1280x1024. Not sure if that helps.
Title: Re: Theora questions
Post by: Finn on September 24, 2006, 01:46:06 PM
This may not be ideal but it is one way around your resize problem with ffmpeg2theora (which can only resize to output dimensions that are multiples of 8 even if you specify other dimensions). Try using an AlphaImage mask of the entity PlayTheora method to remove the unwanted extra borders due to the resizing limitation of ffmpeg2theora.

Open your favourite art package and create your alpha mask to the same 'oversized' dimension of your video (i.e. with it's unwanted black border). Use black for the video area you want to keep and leaving whatever area you want removed as the transparent alpha channel (possibly the very bottom and/or very right pixels). Save your image as a png and then specify it as the AlphaImage in your video entity's PlayTheora method.

Yeah, you might have a few extra pixels that are never seen but it shouldn't be a huge overhead (less that 8 pixels in width and height).

Title: Re: Theora questions
Post by: Mnemonic on September 24, 2006, 05:48:19 PM
WME is using the frame size reported by Theora. I'm not sure how can this happen, other than the video reporting other dimensions than it actually contains. Nevertheless, the trick suggested by Finn should work fine.
As for the z-order within scene, the videos work exactly like normal entities, that is, their Y position on screen determines the order in which they are drawn. Also their base point must be within some scene region (see this thread (http://forum.dead-code.org/index.php?topic=1721.0)).
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 06:55:40 PM
Thanks for the tips guys. Unfortunately the alpha mask is not applying at all. Not sure why at the moment. I should have thought of that myself too.  ;) But anyway it's still got the black bars. Plus my video resolution is a multiple of 8 as Finn said.

I still can't get the item to draw behind the floor. It was my understanding that the drawing order for entities is based on the order in which they appear in the scene list? I thought the Y position was only for free entities. Does the video need to be a free entity?
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 07:06:01 PM
If I move the video entity behind the background of the entire scene, listed as the first thing in the list, it still draws on top of everything.
Title: Re: Theora questions
Post by: Mnemonic on September 24, 2006, 07:56:22 PM
That's strange. I suppose you are using Entity.PlayTheora(), not Game.PlayTheora(), right?
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 08:02:12 PM
Yeah. This is the code for it.

var video = Scene.CreateEntity();
video.X = 403;
video.Y = 184;
video.PlayTheora("somepath\waterfallcolor2.ogg",true, "somepath\waterfallmask.png");

I used that somepath to avoid spoilers. ;-)

The alpha mask doesn't work nor the draw order as I stated before. This code is in a script attached to a region entity. I've tried sprite entities as well.
Title: Re: Theora questions
Post by: metamorphium on September 24, 2006, 10:38:12 PM
but you have created this entity dynamically, so it has no z order predefined.

Either create the entity in Scene Edit and modify your code to read:

var video = Scene.GetNode("your scene edit entity name goes here");
video.X = 403;
video.Y = 184;
video.PlayTheora("somepath\waterfallcolor2.ogg",true, "somepath\waterfallmask.png");

or use StickToRegion().
Title: Re: Theora questions
Post by: DocBass on September 24, 2006, 10:51:22 PM
but you have created this entity dynamically, so it has no z order predefined.

Either create the entity in Scene Edit and modify your code to read:

var video = Scene.GetNode("your scene edit entity name goes here");
video.X = 403;
video.Y = 184;
video.PlayTheora("somepath\waterfallcolor2.ogg",true, "somepath\waterfallmask.png");

or use StickToRegion().

I had just figured this out before you posted actually. I figured I must be creating a new entity and throwing it on top of the entire scene. I just changed it to this.X this.Y etc...and it worked. But thanks for your help!  :)

Except for the alpha thing which still doesn't work.
Title: Re: Theora questions
Post by: Finn on September 24, 2006, 11:36:45 PM
What colour depth have you saved the AlphaImage in? Try increasing it and see if that works any better (e.g. 32 bit depth). The AlphaImage definitely does work.

Yes, it's a wee bit odd that you're still getting borders with multiples of 8. I guess ffmpeg2theora is a bit finicky. I think it's a matter of playing around until you get something that works. It shouldn't really matter that much about the exact size because the good thing about using the mask is that you don't have to stick to the multiple of 8 for the video size - the mask can edit out the unwanted extra pixels.
Title: Re: Theora questions
Post by: DocBass on September 25, 2006, 04:07:56 AM
I was using a PNG-24. I'll try a different format. Been working on so much stuff that if I get stuck I usually move on until someone can help with the answer.  ;D
Title: Re: Theora questions
Post by: DocBass on September 25, 2006, 06:06:51 AM
Thank you gents, a 32 bit TGA file did the trick. All is well and everything is looking fantastic. Thanks all!