jcodecを使用してビデオからフレームを取得したいのですが、NullPointerException が発生します。
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.jcodec.api.FrameGrab;
import org.jcodec.api.JCodecException;
public class App
{
public static void main( String[] args )
{
int frameNumber = 150;
try {
BufferedImage frame = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
try {
frame = FrameGrab.getFrame(new File("/Users/AG/Downloads/video.mp4"), frameNumber);
} catch (JCodecException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
ImageIO.write(frame, "png", new File("frame_150.png"));
} catch (IOException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
スタックトレース:
Exception in thread "main" java.lang.NullPointerException
at org.jcodec.codecs.h264.decode.deblock.DeblockingFilter.calcBsH(DeblockingFilter.java:167)
at org.jcodec.codecs.h264.decode.deblock.DeblockingFilter.deblockFrame(DeblockingFilter.java:80)
at org.jcodec.codecs.h264.H264Decoder$FrameDecoder.decodeFrame(H264Decoder.java:101)
at org.jcodec.codecs.h264.H264Decoder.decodeFrame(H264Decoder.java:61)
at org.jcodec.api.specific.AVCMP4Adaptor.decodeFrame(AVCMP4Adaptor.java:40)
at org.jcodec.api.FrameGrab.decodeLeadingFrames(FrameGrab.java:184)
at org.jcodec.api.FrameGrab.seekToFramePrecise(FrameGrab.java:111)
at org.jcodec.api.FrameGrab.getFrame(FrameGrab.java:331)
at com.mycompany.video_extractor.App.main(App.java:27)