我试图把一个视频文件转换成一系列的帧在颤振。
目前,我已经尝试了两个颤振库:
export_video_frame: ^0.0.6video_thumbnail: ^0.4.3然而,这两个库都需要相当长的时间来处理视频文件。
视频文件的
是否有一种更有效地处理视频文件的方法,以限制在颤振应用程序?上将5秒视频文件转换为一系列帧的时间少于10s。
我尝试过的其他方法包括返回byteArray或filepath的列表,类似于video_thumbnail的处理逻辑(返回所有帧而不是单个帧)。但在实施过程中,我面临着一些问题。
当
ByteArray列表时,该应用程序在将ByteArray从本地Android解析回来时抛出Out of Memory Error。(应用程序不能在图像质量上妥协。因此,我无法将图像压缩成更小的大小。)。
发布于 2022-10-02 17:09:52
使用ffmpeg_kit_flutter_min_gpl:
如果您想将整个视频解耦成帧,我相信这是更有效的性能:
videoPath :视频的路径,使用路径提供程序获取本地目录: applicationDirectory fps :您想要的视频总帧
var command =
'-i $videoPath -r $fps -f image2 ${applicationDirectory}img-%03d.png';
await FFmpegKit.execute(command).then((session) async {
final returnCode = await session.getReturnCode();
await session.getAllLogsAsString();
if (ReturnCode.isSuccess(returnCode)) {
_logger.info('Frame Export Success');
var paths = <String>[];
for (var a = 1; a < fps; a++) {
if (a < 10) {
paths.add('${applicationDirectory}img-00$a.png');
} else if (a < 100) {
paths.add('${applicationDirectory}img-0$a.png');
} else {
paths.add('${applicationDirectory}img-$a.png');
}
}https://stackoverflow.com/questions/69387039
复制相似问题