Is it possible to stream a video with flutter camera plugin?

16,655

Solution 1

Looks like it is possible as it was done at Flutter Live with one of the development demos. Check out the YouTube video here . at 24:17. There is a method on the CameraController called getByteStream. The gist of the method shown below.

void cameraBytesToDetector({@required CameraController camera}){
  camera.startByteStream( (image) {
    // do something with the image stream here
  });
}

But I can find no reference anywhere as I am also looking for a way to read the video stream.

Solution 2

You can call Java/Kotlin or Objective-C/Swift libraries from Dart.

I can suggest that libraries for Android,

https://github.com/begeekmyfriend/yasea

https://github.com/ant-media/LiveVideoBroadcaster

The only thing that you have to do is developing a dart interface to this kind of libraries.

Solution 3

The startByteStream feature mentioned by Steve was not actually added to the plugin, because it was only called startByteStream initially, but actually only provided images. As a result, during development, this function was renamed to startImageStream, as seen in this commit. So there is a startImageStream, and you can send over image frames as soon as you get it over web-rtc to your backend. Then, you can try record the audio separately and send it over too.

However, startImageStream does not include any audio, and may not be performant. There is an open issue for adding byte streaming capability, including audio. GitHub issue

As of now, startByteStream does not exist in the code.

Share:
16,655
dev_mush
Author by

dev_mush

I work as a full stack software developer (mainly focused on development and deployment of mobile products) at ufirst, an Italian startup which aim is to solve one of the most tedious problems of the world: Queues! Now my focus is oriented in building great apps with Flutter. In my free time I try to be in the present. Constantly seeking for new stuff to discover, mildly interested in generative arts obsessed by free climbing, piano playing and pizza🍕.

Updated on June 03, 2022

Comments

  • dev_mush
    dev_mush almost 2 years

    I've been playing around with the camera plugin, I know there's the possibility to capture a video via the CameraController with the functions start/stopVideoRecording, the functions will take a path for a file as an input.

    I'd like to be able to stream this video to a server while it's being recorded, is it possible somehow with the current capabilities of the camera plugin?

  • Noel
    Noel over 5 years
    It looks like the change hasn't been merged yet. Check out this pull request: github.com/flutter/plugins/pull/965. The author is the same person from the video
  • Oliver Dixon
    Oliver Dixon about 4 years
    This was never merged?
  • Oliver Dixon
    Oliver Dixon about 4 years
    Only for agora.io streams.
  • chornge
    chornge almost 4 years
    It was merged jan 2019
  • Ben Butterworth
    Ben Butterworth almost 4 years
    In the end, startByteStream was renamed to startCameraStream, so no audio is provided.
  • Kamlesh
    Kamlesh over 3 years
    I am looking solution of Stream Screen Recording in flutter, is there any suggestion?? Thanks in advance.