博客
关于我
利用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实现关系矩阵A和B的乘积(附完整源码)
    查看>>
    Objective-C实现关系矩阵乘法(附完整源码)
    查看>>
    Objective-C实现关系矩阵乘法(附完整源码)
    查看>>
    Objective-C实现关键字移位字母表密码算法(附完整源码)
    查看>>
    Objective-C实现内存映射文件(附完整源码)
    查看>>
    Objective-C实现内存泄露检查(附完整源码)
    查看>>
    Objective-C实现内核中的自旋锁结构(附完整源码)
    查看>>
    Objective-C实现内格尔·施雷肯伯格算法(附完整源码)
    查看>>
    Objective-C实现冒泡排序(附完整源码)
    查看>>
    Objective-C实现农历与公历转换 (附完整源码)
    查看>>
    Objective-C实现几何级数的总和算法 (附完整源码)
    查看>>
    Objective-C实现凯撒密码算法(附完整源码)
    查看>>
    Objective-C实现凸多边形的凸包问题算法(附完整源码)
    查看>>
    Objective-C实现分块查找算法(附完整源码)
    查看>>
    Objective-C实现分块查找算法(附完整源码)
    查看>>
    Objective-C实现分层聚类算法(附完整源码)
    查看>>
    Objective-C实现分水岭算法(附完整源码)
    查看>>
    Objective-C实现分而治之算法(附完整源码)
    查看>>
    Objective-C实现分解质因数(附完整源码)
    查看>>