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

前端 未结 6 1735
谎友^
谎友^ 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:09

    Here's how with BoofCV:

    String fileName = UtilIO.pathExample("tracking/chipmunk.mjpeg");
    
    MediaManager media = DefaultMediaManager.INSTANCE;
    
    ConfigBackgroundBasic configBasic = new ConfigBackgroundBasic(30, 0.005f);
    ImageType imageType = ImageType.single(GrayF32.class);
    BackgroundModelMoving background = FactoryBackgroundModel.movingBasic(configBasic, new PointTransformHomography_F32(), imageType);
    
    SimpleImageSequence video = media.openVideo(fileName, background.getImageType());
    
    ImageBase nextFrame;
    while(video.hasNext()) {
        nextFrame = video.next();
    
        // Now do something with it...
    }
    

提交回复
热议问题