How can I get a frame sample (jpeg) from a video (mov)

前端 未结 6 1731
谎友^
谎友^ 2020-11-30 20:13

I want to get a frame sample (jpeg) from a video file (mov) with java. Is there an easy way to do this. When I search in google all I can find is to make mov from multiple j

6条回答
  •  無奈伤痛
    2020-11-30 21:00

    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import org.bytedeco.javacpp.opencv_core.IplImage;
    import org.bytedeco.javacv.FFmpegFrameGrabber;
    import org.bytedeco.javacv.FrameGrabber.Exception;
    
    public class Read{
        public static void main(String []args) throws IOException, Exception
        {
            FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber("C:/Users/Digilog/Downloads/Test.mp4");
            frameGrabber.start();
            IplImage i;
            try {
    
                i = frameGrabber.grab();
                BufferedImage  bi = i.getBufferedImage();
                ImageIO.write(bi,"png", new File("D:/Img.png"));
                frameGrabber.stop();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
    
        }
    }
    

提交回复
热议问题