levelc-java和c/c++交互
程序员文章站
2024-03-25 08:22:28
...
github
源码地址是传送门。
音视频
VideoExtractFrames 提取视频的指定位置的帧
void testVideoExtractFrames() {
def files = io.vavr.collection.List.ofAll(VideoExtractFrames.videoExtractFrames("D:\\big.mp4", [333, 666, 999]))
.zipWithIndex()
.map(new Function<Tuple2<Frame, Integer>, String>() {
@Override
String apply(Tuple2<Frame, Integer> tuple2) {
String file = "D:\\pet" + tuple2._2 + ".jpg"
ImageIO.write(EnhanceFrameUtils.toBufferedImage(tuple2._1), "jpg", new File(file))
return file
}
}).asJava()
ShowImage.showImage(files as String[])
}
提取333/666/999帧,效果如下:
VideoFrameList 随机或均匀提取视频中的n张图片
void testVideoFrameList() {
def files = io.vavr.collection.List.ofAll(VideoFrameList.videoFrameList("D:\\big.mp4", 3, false))
.map(new Function<Rule<Integer, Frame>, String>() {
@Override
String apply(Rule<Integer, Frame> rule) {
String file = "D:\\big" + rule.getKey() + ".jpg"
ImageIO.write(EnhanceFrameUtils.toBufferedImage(rule.value), "jpg", new File(file))
return file
}
}).asJava()
ShowImage.showImage(files as String[])
}
上面代码随机在视频中选了3帧,显示如下: