博客
关于我
利用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实现hill climbing爬山法用来寻找函数的最大值算法(附完整源码)
    查看>>
    Objective-C实现hornerMethod霍纳法算法(附完整源码)
    查看>>
    Objective-C实现Http Post请求(附完整源码)
    查看>>
    Objective-C实现Http协议下载文件(附完整源码)
    查看>>
    Objective-C实现IIR 滤波器算法(附完整源码)
    查看>>
    Objective-C实现IIR数字滤波器(附完整源码)
    查看>>
    Objective-C实现insertion sort插入排序算法(附完整源码)
    查看>>
    Objective-C实现integer partition整数分区算法(附完整源码)
    查看>>
    Objective-C实现integerPartition整数划分算法(附完整源码)
    查看>>
    Objective-C实现interpolation search插值搜索算法(附完整源码)
    查看>>
    Objective-C实现Interpolation search插值查找算法(附完整源码)
    查看>>
    Objective-C实现intersection交集算法(附完整源码)
    查看>>
    Objective-C实现intro sort内省排序算法(附完整源码)
    查看>>
    Objective-C实现inversions倒置算法(附完整源码)
    查看>>
    Objective-C实现isalpha函数功能(附完整源码)
    查看>>
    Objective-C实现islower函数功能(附完整源码)
    查看>>
    Objective-C实现isPowerOfTwo算法(附完整源码)
    查看>>
    Objective-C实现isupper函数功能(附完整源码)
    查看>>
    Objective-C实现ItemCF算法(附完整源码)
    查看>>
    Objective-C实现ItemCF算法(附完整源码)
    查看>>