Hi, Here's the code I've been using to capture videos from a canvas3d. Just a couple of points to go along with it:
1. I'm not in any way an expert on JMF so I make no promises that the code is the best it could be. 2. The FilmGenerator class transcodes images in it's own thread - hence frame rates and interactive behavior for j3d suffer. I'm using a 1.4GHz Athlon and with large scenes I drop from 33 to about 10 or 12 fps. To get smooth films I prerecord viewing transformations and rendering attributes so that the transitions are smooth rather than the jerky results you can get from trying to interact while the image processor is running. If you have enough memory you might like to leave off starting the FilmGenerator until after you have generated your frames. i.e. move the fg.start() command from beginLiveCapture() to endLiveCapture() (in the LiveCaptureCanvas3D class) and post process the data into a film. This delivers pretty good interactivity whilst recording because there isn't an extra thread grabbing all the cpu cycles. 3. There may well be more synchronization than is strictly necessary but I had a lot of problems with my image processor blocking due to flags being reset at critical points so I found it best to synchronize most of the live capture code. 4. The ImageSourceStream uses the frame rate to generate time stamps. This ensures the video is smooth even when it's generation is not! However be careful about a frame rate of 0. Seems obvious I know but you will get a zero division exception. 5. All capture is done in the postSwap() method. This means if you move the mouse over the canvas whilst capturing - you get a new frame whether the display actually changed or not. I thought about generating frames at given time intervals but the extra overhead with working out when to capture seemed like too much work so I opted for this approach. 6. For some reason the first frame is always captured twice! I'm not sure why so if someone spots it I'd love to hear from you. 7. The ImageDataSource is a JMF data source so you can use it in the same way as any other data source. I'm quite interested in seeing how it might work as a dynamic texture because I know people have been working on that. Might be nice to have a monitor in your 3D world where you could see what someone else was doing on their canvas?! 8. Final silly point remember to disable heavyweight popups otherwise you'll end up with menus and tooltips all over your video. Well I hope it's useful to someone, feel free to rip it to pieces but if you find any significant improvements or modifications then please let me know because I'm using it quite a lot just now so improvements are always welcome. Oh, here's my setup in case there are any problems: jdk1.4 j3d1.3beta1 (GL version) jmf2.1.1 Cheers, Ewan ----- Original Message ----- From: "Ra�l" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, March 21, 2002 6:23 PM Subject: Re: [JAVA3D] Video & file formats > Many thanks for your help! > > I 'll be waiting for the code. > > Ewan Borland wrote: > > > Hi, > > > > I created a custom JMF data source which my canvas writes into every frame > > and then have a separate thread which runs a JMF processor transcoding these > > captured stills into quicktime or avi. It's bundled up in the middle of a > > big app but if you're interested then give me a couple of days to separate > > it out and I'll send you the code, > > > > Ewan > > > > ----- Original Message ----- > > From: "Ra�l" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, March 20, 2002 7:19 PM > > Subject: [JAVA3D] Video & file formats > > > > > > > >>Hello!! > >> > >> > >>Has anybody got saving a video from a rendered scene? Which file format? > >>How (any tips or advice)? > >> > >> > >> > > =========================================================================== > > > >>To unsubscribe, send email to [EMAIL PROTECTED] and include in the > >> > > body > > > >>of the message "signoff JAVA3D-INTEREST". For general help, send email to > >>[EMAIL PROTECTED] and include in the body of the message "help". > >> > >> > > > > =========================================================================== > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > > of the message "signoff JAVA3D-INTEREST". For general help, send email to > > [EMAIL PROTECTED] and include in the body of the message "help". > > > > > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA3D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". >
LiveCapture.zip
Description: Zip compressed data
