Getting frame from movie

suggest change

Getting a single frame from a movie (supports only AVC, H.264 in an MP4, ISO BMFF, or QuickTime container). BufferedImage and ImageIO are Java SE APIs and are not in the Android SDK.

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

Getting a sequence of frames from a movie (supports only AVC, H.264 in an MP4, ISO BMFF, or QuickTime container):

double startSec = 51.632;
FileChannelWrapper ch = null;
try {
    ch = NIOUtils.readableFileChannel(new File("filename.mp4"));
    FrameGrab fg = new FrameGrab(ch);
    fg.seek(startSec);
    for (int i = 0; i < 100; i++) {
        ImageIO.write(fg.getFrame(), "png",
            new File(System.getProperty("user.home"), String.format("Desktop/frame_%08d.png", i)));
    }
} finally {
    NIOUtils.closeQuietly(ch);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents