博客
关于我
利用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实现BreadthFirstSearch广度优先搜索算法(附完整源码)
    查看>>
    Objective-C实现BreadthFirstShortestPath广度优先最短路径算法(附完整源码)
    查看>>
    Objective-C实现bubble sort冒泡排序算法(附完整源码)
    查看>>
    Objective-C实现bucket sort桶排序算法(附完整源码)
    查看>>
    Objective-C实现Burke 抖动算法(附完整源码)
    查看>>
    Objective-C实现Burrows-Wheeler 算法(附完整源码)
    查看>>
    Objective-C实现CaesarsCiphe凯撒密码算法(附完整源码)
    查看>>
    Objective-C实现calloc函数功能(附完整源码)
    查看>>
    Objective-C实现canny边缘检测算法(附完整源码)
    查看>>
    Objective-C实现cartesianProduct笛卡尔乘积算法(附完整源码)
    查看>>
    Objective-C实现check strong password检查密码强度算法(附完整源码)
    查看>>
    Objective-C实现chudnovsky algorithm楚德诺夫斯基算法(附完整源码)
    查看>>
    Objective-C实现CIC滤波器(附完整源码)
    查看>>
    Objective-C实现circle sort圆形排序算法(附完整源码)
    查看>>
    Objective-C实现CircularQueue循环队列算法(附完整源码)
    查看>>
    Objective-C实现clearBit清除位算法(附完整源码)
    查看>>
    Objective-C实现climbStairs爬楼梯问题算法(附完整源码)
    查看>>
    Objective-C实现cocktail shaker sort鸡尾酒排序算法(附完整源码)
    查看>>
    Objective-C实现cocktailShakerSort鸡尾酒排序算法(附完整源码)
    查看>>
    Objective-C实现CoinChange硬币兑换问题算法(附完整源码)
    查看>>