dinesh.rajbhar
dinesh.rajbhar

Reputation: 321

How to capture photo while recording video in flutter?

I am working on flutter camera package. I wrote 2 separate method for capturing photo and video recording both are working well.

But I want to capture photo while recording video but unable to find how to do it in flutter.

Anyone has any idea about this? like how to capture photo while recording in flutter?

Upvotes: 4

Views: 853

Answers (2)

Edtimer
Edtimer

Reputation: 309

I would recommend implementing a button so that when the user clicks on it would extract a frame from the recording. The logic would require precise time calculation for when the user pressed the button vs the length of the recorded video. you can find some code snippets on how to implement that here

Upvotes: 2

Esmaeil Ahmadipour
Esmaeil Ahmadipour

Reputation: 1172

The simple way is to use the screenshot package.

for show in another widget:

    screenshotController.capture().then((Uint8List image) {
        //Capture Done
        setState(() {
            _imageFile = image;
        });
    }).catchError((onError) {
        print(onError);
    });

or , save in device storage:

final directory = (await getApplicationDocumentsDirectory ()).path; //from path_provide package
String fileName = DateTime.now().microsecondsSinceEpoch;
path = '$directory';

screenshotController.captureAndSave(
    path //set path where screenshot will be saved
    fileName:fileName 
);

Upvotes: 0

Related Questions