简体   繁体   中英

How to support video streaming from ESP32CAM using flutter video_player plugin?

I am using flutter video_player plugin for camera video streaming. Camera streaming is from ESP32Cam hardware.

ESP32Cam is streaming video on network using http protocol and in mjpeg format

Verified in VLC media player, Codec information are as below:

Codec: Motion JPEG Video (MJPG)

Decoded format: Planar 4:2:2 YUV full scale

What are the configuration required in video_player plugin to stream the video?

Here is my flutter code for streaming initialization:

late VideoPlayerController _controller;
 _controller = VideoPlayerController.network(
    //'https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4'
     "http://192.168.216.40",
    // formatHint: VideoFormat.hls,
    )
..initialize().then((_) {
  print("Streaming initialized...");
  // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
});

Then I am using widget in my Container widget

Container(
    child: VideoPlayer(_controller),
),

ESP32Cam setup for reference link

you can use live streaming pluging without null safety: https://pub.dev/packages/mjpeg

with null safety: https://pub.dev/packages/flutter_mjpeg

You can use the above comment's plug-in in the pubspec.yaml file and do the following steps

  1. Add new dummy variable bool isRunning = true; in State<YourStateName>

  2. put dummy variable in Mjpeg[isLive] -> child: Mjpeg(isLive: isRunning , stream: ' replace with your local streaming URL ')

you can use this link for more information https://youtu.be/2OjO6K5QuYs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM