博客
关于我
利用JavaCV实现将视频以帧方式抽取
阅读量:327 次
发布时间:2019-03-04

本文共 1841 字,大约阅读时间需要 6 分钟。

??JavaCV??????????

?????

???JavaCV??????????????????????????????????????JavaCV?????????????JAR???????????IDEA?Eclipse???????????????????????????????????

???????

?????????JavaCV?????????????

  • ?????JavaCV?
  • ????????????JavaCV????

    import org.bytedeco.javacv.FFmpegFrameGrabber;import org.bytedeco.javacv.Frame;import org.bytedeco.javacv.Java2DFrameConverter;
    1. ????????
    2. ?????????????????

      public static final String VIDEO_PATH = "path/to/your/video.mp4";
      1. ???????
      2. ??FFmpegFrameGrabber?????????????????????

        public class VideoFrameGrabber {    public static void grabFrames(String videoPath, String outputDir, String fileName, int frameRate) throws IOException {        FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(videoPath);        grabber.start();                for (int i = 0; i < frameRate; i++) {            Frame frame = grabber.grabImage();            if (frame == null) continue;                        // ??????            saveFrame(frame, outputDir, fileName, i);        }                grabber.stop();    }        private static void saveFrame(Frame frame, String outputDir, String fileName, int index) {        Java2DFrameConverter converter = new Java2DFrameConverter();        BufferedImage image = converter.getBufferedImage(frame);                String filePath = outputDir + File.separator + fileName + "_" + index + ".jpg";        File output = new File(filePath);                try {            ImageIO.write(image, "jpg", output);        } catch (IOException e) {            e.printStackTrace();        }    }}
        1. ??????
        2. ???????????????

          public static void main(String[] args) throws IOException {    VideoFrameGrabber.grabFrames(VIDEO_PATH, "output/", "video", 30);}

          ????

          • ???????????????????FFmpeg???????MP4?AVI??
          • ????????????????????????????
          • ????????????????????????????

          ?????????????????????????????????????????

    转载地址:http://asgq.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现四阶龙格库塔法(附完整源码)
    查看>>
    Objective-C实现四阶龙格库塔法(附完整源码)
    查看>>
    Objective-C实现回调实例(附完整源码)
    查看>>
    Objective-C实现回转13位替换式密码算法(附完整源码)
    查看>>
    Objective-C实现国密SM9算法(附完整源码)
    查看>>
    Objective-C实现图-弗洛伊德FloydWarshall算法(附完整源码)
    查看>>
    Objective-C实现图书借阅系统(附完整源码)
    查看>>
    Objective-C实现图像二维熵的图像信号丢失检测(附完整源码)
    查看>>
    Objective-C实现图像去雾算法(附完整源码)
    查看>>
    Objective-C实现图像处理----resizeImageWidth调整图像宽度算法(附完整源码)
    查看>>
    Objective-C实现图像灰度变换(附完整源码)
    查看>>
    Objective-C实现图像相似度平均值哈希算法(附完整源码)
    查看>>
    Objective-C实现图像相似度平均值哈希算法(附完整源码)
    查看>>
    Objective-C实现图像移动(附完整源码)
    查看>>
    Objective-C实现图层混合算法(附完整源码)
    查看>>
    Objective-C实现图层混合算法(附完整源码)
    查看>>
    Objective-C实现图形着色算法(附完整源码)
    查看>>
    Objective-C实现图片dilation operation扩张操作算法(附完整源码)
    查看>>
    Objective-C实现图片erosion operation侵蚀操作算法(附完整源码)
    查看>>
    Objective-C实现图片格式转换(附完整源码)
    查看>>