为什么frameGrabber.start()不从视频文件中抓取帧

时间:2017-03-17 07:23:00

标签: java ffmpeg javacv

这里是JAVA中的下面代码

公共课阅读{

public static void main(String []args) throws IOException, Exception, InterruptedException, ExecutionException
{

// Runtime.getRuntime()。exec(" ffmpeg -r 1 -i sample%d.png -s 320x240 -sepect 4:3 CHANDIGARH.mp4");         FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(" C:/Users/Danish/Music/CHANDIGARH.mp4");         frameGrabber.setFrameNumber(0);         frameGrabber.start();

    IplImage i;



    try {
        for(int ii=0;ii<=frameGrabber.getLengthInFrames();ii++){

            OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();      

              Java2DFrameConverter paintConverter = new Java2DFrameConverter();
             i = converter.convert(frameGrabber.grab());


            Frame frame = converter.convert(i);
            BufferedImage img=paintConverter.getBufferedImage(frame,1);
            IplImage iplImage = converter.convert(paintConverter.convert(img));

        String path = "F:\\"+ii+".png";
        ImageIO.write(img,"png", new File(path));

        }
        frameGrabber.stop();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

}

0 个答案:

没有答案