FFmpegKit.executeAsync("-y -f rawvideo -pixel_format rgba -video_size image.widthx{image.width}ximage.widthx{image.width} -framerate $fps -i $pipe -c:v libx264 -g 5 -pix_fmt yuv420p -preset superfast -q 11 $path") FFmpegKitConfig.registerNewFFmpegPipe().then((pipe) async { _pipeWriter = File(pipe!).openWrite();
FFmpegKit.executeAsync("-y -f rawvideo -pixel_format rgba -video_size ${image.width}x${image.width} -framerate $fps -i $pipe -c:v libx264 -g 5 -pix_fmt yuv420p -preset superfast -q 11 $path", (FFmpegSession session) async { _pipeWriter?.close(); _pipeWriter = null; FFmpegKitConfig.closeFFmpegPipe(pipe); _isRecording = false; notifyListeners(); if (Platform.isAndroid) { Future.delayed(const Duration(milliseconds: 300)).then((_) => PlatformPlugin.scanFile(path)); } findLastImagePath(); }); Timer.periodic(const Duration(milliseconds: 50), (timer) { if (!_isRecording) { timer.cancel(); return; } _getRenderImage()?.toByteData(format: ui.ImageByteFormat.rawRgba).then((value) { _pipeWriter?.add(value!.buffer.asUint8List()); }); frameIndex++; var recordTime = frameIndex ~/ fps; if (recordTime != _recordTime) { _recordTime = recordTime; notifyListeners(); } }); }, onError: (_) { _isRecording = false; notifyListeners(); });
}
之前ffmpeg没加libx264,现在加上去了,用 1.0.3-rc1分支试一试
FFmpegKit.executeAsync("-y -f rawvideo -pixel_format rgba -video_size image.widthx{image.width} -framerate $fps -i $pipe -c:v libx264 -g 5 -pix_fmt yuv420p -preset superfast -q 11 $path")
FFmpegKitConfig.registerNewFFmpegPipe().then((pipe) async {
_pipeWriter = File(pipe!).openWrite();
}