Extracting individual frames from a video clip (AVI)

From: Tom Robinson (tom.robinson_at_durham.ac.uk)
Date: 03/11/04


Date: Thu, 11 Mar 2004 00:00:32 +0000


(Posted to comp.lang.java.programmer and jmf-interest.)

I'm trying to write an application which can accept a video clip in
the form of an AVI file as input, and produce a series of still images
taken from specific frames in the video. The goal is to be able to
extract every nth frame as an Image object or similar.

I'm currently using JMF to do this, working from the FrameAccess.java
example. The output tells me that the AVI I'm using for input has the
following format:

Video format: IV32, 640x480, FrameRate=5.0, Length=921600 0 extra
bytes

I have already run into trouble trying to use FramePositioningControl
and FrameGrabbingControl for this (using Player rather than Processor
- what is the distinction between the two? why does it exist?), and
I've read that this is because these are not supported for AVI files
(although they might work with mpegs). (Does anyone know why?)

My current solution is to add a BufferToImage converter to
PostAccessCodec.accessFrame() in FrameAccess.java, but this is no good
either because firstly when playing the movie clip through the codec
doesn't seem to "catch" every frame, about 3/4 of them slip through.
And secondly, the BufferToImage converter doesn't work, returning
null, which the documentation says means the conversion failed. Could
anyone tell me why these two problems are occuring?

I think I can access the raw data from the Buffer using
Buffer.getData(), but even so the problem of skipping frames still
remains. The solution isn't ideal anyway because you have to play the
whole movie clip through at normal speed, and wait for the frames to
pass through the codec.

I have noticed through searching archives of jmf-interest and looking
on google groups and the web in general that a few people appear to
have come across the same problems in the past, when trying to
accomplish the same task. There doesn't seem to be a definitive
solution, and I think that extracting frames from a video clip should
definitely be something that JMF is capable of, so I would like to
work towards this.

Perhaps there are better approaches that can be taken to solving this
problem using the JMF. Should I investigate using something like a
PullBufferStream?

If anybody has any suggestions of other routes I could take with this,
perhaps using something other than JMF, please tell me.

Thanks very much for your help,

Tom

References:

http://java.sun.com/products/java-media/jmf/2.1.1/solutions/FrameAccess.java



Relevant Pages

  • Re: Creating AVI file from bitmaps
    ... an AVI file using DirectShow to be lacking. ... > For extracting the frames from the source file I use the AviFileWrapper ... > have the Mandelbrot example) By the way, the video is uncompressed RGB ...
    (microsoft.public.dotnet.languages.csharp)
  • writing avi file on ppc2005
    ... i want to make avi file by writing some frames in it. ... for this i parse one avi file frame by frame and write each frame using ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Make multiple avi files in one run
    ... I think I've seen the CAviFile wrapper class you are using or at least a ... AVI file, then it should reset the m_lSample parameter to 0. ... > That lStart parameter is a static member of the CAviFile::AppendFrameUsual ... >>> write the frames to the AVI File. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Powerpoint adding Video
    ... I was not able to insert .avi file through Insert Movie/Sound. ... > I have office 2000 and I created a presentation in PowerPoint 2000. ... > I insert a video clip as an object in a slide and set up to run ... > automatically when the show hits that slide. ...
    (microsoft.public.powerpoint)
  • Re: Missing the video frames
    ... .avi file, but in my final .AVI file the some of the ... frames are missing, this happens only in the case of the ... frames are missing int the resultant .AVI file. ... Are you using the SG in sample mode or buffer mode? ...
    (microsoft.public.win32.programmer.directx.video)