博客
关于我
利用JavaCV实现将视频以帧方式抽取
阅读量:328 次
发布时间: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/

    你可能感兴趣的文章
    PoE三种标准:标准 PoE、PoE+、PoE++,网络工程师必知!
    查看>>
    POI 的使用
    查看>>
    poi 读取单元格为null者空字符串
    查看>>
    poi-tl简介与文本/表格和图片渲染
    查看>>
    pointnet分割自己的点云数据_PointNet解析
    查看>>
    POI实现Excel导入Cannot get a text value from a numeric cell
    查看>>
    POI实现Excel导入时提示NoSuchMethodError: org.apache.poi.util.POILogger.log
    查看>>
    POI实现Excel导出时常用方法说明
    查看>>
    POI导出Excel2003
    查看>>
    POI数据获取及坐标纠偏
    查看>>
    Quartz入门看这一篇文章就够了
    查看>>
    POI解析Excel【poi的坑——空行处理】
    查看>>
    POI:POI+JXL实现xls文件添加水印
    查看>>
    POI:POI实现docx文件添加水印
    查看>>
    POJ 1006
    查看>>
    Quartz中时间表达式的设置-----corn表达式
    查看>>
    poj 1035
    查看>>
    POJ 1061 青蛙的约会 (扩展欧几里得)
    查看>>
    Quartz2.2.1简单使用
    查看>>
    POJ 1080 Human Gene Functions(DP:LCS)
    查看>>