2

I need programmatically extract frames from mp4 video file, so each frame goes into a separate file. Please advise on a library that will allow to get result similar to the following VLC command (http://www.videolan.org/vlc/):

vlc v1.mp4 --video-filter=scene --vout=dummy --start-time=1 --stop-time=5 --scene-ratio=1 --scene-prefix=img- --scene-path=./images vlc://quit

Library for any of these Java / Python / Erlang / Haskell will do the job for me.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Anton Ashanin
  • 1,817
  • 5
  • 30
  • 43
  • An answer that I just posted here will be useful for anyone else who wants to do a similar thing: http://stackoverflow.com/a/22107132/398316 – Maghoumi Feb 28 '14 at 22:37

2 Answers2

1

Consider using the following class by Popscan. The usage is as follows:

VideoSource vs = new VideoSource("file://c:\test.avi");
vs.initialize();
...
int frameIndex = 12345; // any frame 
BufferedImage frame = vs.getFrame(frameIndex);
Alexander Serebrenik
  • 3,567
  • 2
  • 16
  • 32
  • VideoSource requires JMF. Source and docs available here, but it's too old to be useful: http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html – David Newcomb Oct 12 '13 at 22:48
0

I would personally look for libraries that wrap ffmpeg/libavcodec (the understands-most-things library that many encoders and players use).

I've not really tried any yet so can't say anything about code quality and ease, but the five-line pyffmpeg example suggests it's an easy option - though it may well be *nix-only.

scarfboy
  • 86
  • 3