Tuesday, June 28, 2022
HomeTechnologyios - Flutter get first frame from video

ios – Flutter get first frame from video


I’m trying to take picture at a moment and I was trying to turn off the shutter audio. (Here is my related question.) I read some related issues about that then I decided a record a very short video then extract first frame of it. Here is my code snippet:

if (!_camera.value.isRecordingVideo) {
  await _camera.startVideoRecording();
}
Future.delayed(const Duration(milliseconds: 5), () async {
  XFile video = await _camera.stopVideoRecording();
  File videoFile = File(video.path);
  var image = await ExportVideoFrame.exportImageBySeconds(videoFile, Duration.zero, 0);
  videoFile.delete();
  ImageRepository.add(image);
});

It works for once. But for second running there is an error: CameraException(Error -1008, Video is not recording!)

What I’m missing. I’m just trying to record video as image then convert it to image file then save it. What might be reason of this error?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments