From: JS <js...@dr...> - 2007-11-22 19:15:28
|
Hi Ken, Sorry, I have been in quite a hurry. Now back to production, still interested in fixing this frame grabbing control. There are two places where it needs a fix: for a VideoCamera and for a MovieReader class. Let's look first at the MovieReader class that is supposed to read a movie from a file and, each time its fire() method is called, will either skip one frame or seek to a particular frame (depending on an option "isFrameBased") and output it. It uses a FramePositioningControl and a FrameGrabbingControl. Here is a snippet of the code where they are initialized: +++++++++ _framePositioningControl = (FramePositioningControl) _player .getControl("javax.media.control.FramePositioningControl"); ... _frameGrabbingControl = (FrameGrabbingControl) _player .getControl("javax.media.control.FrameGrabbingControl"); +++++++++ And here one where the position is read from the input and the "_frame" variable is set. +++++++++ protected boolean _updateFrameTime(ScalarToken inputToken) throws IllegalActionException { if (_playerOpen == false) { _dataSource.disconnect(); return false; } else { try { if (_isFrameBased) { // frame based int frameNo = inputToken.intValue(); if (frameNo < 0) // default: skip to next frame _framePositioningControl.skip(1); else _framePositioningControl.seek(frameNo); } else { // time based double mediaTimeDouble = inputToken.doubleValue(); Time mediaTime; if (mediaTimeDouble < 0) { mediaTime = new Time(getDirector().getModelTime().getDoubleValue()); } else { mediaTime = new Time(mediaTimeDouble); } // FIXME: if mediaTimeDouble < 0 there is a much more efficient way to // do this by skipping a number of frames _framePositioningControl.seek(_framePositioningControl.mapTimeToFrame(mediaTime)); } _frame = _frameGrabbingControl.grabFrame(); } catch (Exception ex) { throw new IllegalActionException(this, ex, "Problem in call to postfire()."); } return true; } } +++++++++ The VideoCamera class has a similar approach. I guess I have to subclass the javax.media.control.FrameGrabbingControl and javax.media.control.FramePositioningControl classes somewhere and attach them to the different readers, but I really don't know where to start. Thanks for your help. J.S. Ken Larson wrote: > JS - > > That's great that you are interested in helping out, I'll do what I > can to help you help us. > > Perhaps you could send example source or a code snippet which shows > what you are trying to do with the frame grabbing control (how you are > finding/accessing/using it primarily), and I can give you some ideas > of places to look. > > Our video renderers do implement frame grabbing control, but I don't > believe that has been tested yet. > > Ken > > JS wrote: >> Hi, >> >> I am developing an free software (GPL) in Java targeted for interactive >> art installations and eventually performances (http://drone.ws). I have >> a mixed background as a programmer and as media artist. I am currently >> working on several projects, most of which include video and audio. The >> basic thing I need for now is a stable and performing library for media >> which would allow me to read, transform (filters) and playback audio and >> video. >> >> I have started using FMJ recently and was really impressed, in >> particular the integration with lti-civil, the only library with which I >> was able to read my webcam's input on OS X. However, the >> FrameGrabbingControl was not working on FMJ so I had to (temporarily) >> bypass it and use LTI civil. I would like to contribute to the FMJ >> project in several ways, but let's say I could start by implementing the >> FrameGrabbingControl. I am not sure where to start, however, I've digged >> pretty deep into the code but still wasn't sure. If people on this list >> could give me some advice, that would be welcome. Otherwise I'll jsut go >> on digging and ask more precise questions. >> >> Cheers, >> >> > -- J. S. Senécal http://drone.ws |