3

Is there an easy way to decode video in java/scala?

I need just the frames and have to do some computations with them. No need to be fast or real time.

I tried processing which worked but not nice and i wasn't able to embedded it in my project. I saw also jmf but it seams to be no longer maintained since 2004.

1
  • In the moment it's an AVI with DivX. But if needed we should be able to change the container/codec. But it have to be a compressed format. Commented Mar 8, 2011 at 15:31

3 Answers 3

2

Take a look at Xuggler or FMJ (which tried to pick up where JMF left off, but looks semi-dead).

Sign up to request clarification or add additional context in comments.

Comments

0

You can use 'FrameGrab' class from JCodec (http://jcodec.org).
Right now it supports MP4 ( ISO BMF, QuickTime ) file format with AVC ( H.264 ) video inside.
For just one frame

int frameNumber = 150;
BufferedImage frame = FrameGrab.getFrame(new File("filename.mp4"), frameNumber);
ImageIO.write(frame, "png", new File("frame_150.png"));

JCodec is available in maven:

<dependency>
    <groupId>org.jcodec</groupId>
    <artifactId>jcodec</artifactId>
    <version>0.1.3</version>
</dependency>

or as a download on it's web site.

Comments

0

It's easy to get frames from a video file compressed to any format supported by FFMpeg using velvet-video:

IVideoLib lib = new FFMpegVideoLib();
IDemuxer demuxer = lib.demuxer(new File("path-to-video-file"));
while(demuxer.nextPacket(frame -> {
    BufferedImage image = frame.image();
    // You get frames as BufferedImages here
}, null));

Disclaimer: I am the author of velvet-video.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.