📸 MJPEG Stream Flutter Package

MJPEG Stream Logo

Welcome to MJPEG Stream Flutter Package! 🚀 This package allows you to stream MJPEG video in your Flutter application easily. Perfect for real-time camera feeds and IP camera streaming. 📷🎥

🌟 Features

  • 📡 Live MJPEG streaming
  • 🎨 Customizable width, height, and fit
  • ⚡ Optimized for performance
  • 🚀 Easy to integrate
  • 🛠 Error handling and reconnection support
  • 📜 Built-in logging for debugging
  • 🎭 Blur sensitive content option
  • 🏷️ Watermark and branding support
  • 🎬 Live indicator display
  • 🔄 Stream reload feature

📦 Installation

Add this package to your pubspec.yaml:

dependencies:
  mjpeg_stream: latest_version

OR

mjpeg_stream:
    git:  
      url: https://github.com/MohammedShamseerPV/MJPEG-Stream.git
      ref: main  # Optional: specify the branch (default is 'main')

Then, run:

flutter pub get

🛠 Usage

Import the package:

import 'package:mjpeg_stream/mjpeg_stream.dart';

Example Usage 🎬

import 'package:flutter/material.dart';
import 'package:mjpeg_stream/mjpeg_stream.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: MJPEGStreamScreen(
                  streamUrl: "https://your-stream-url.com/video",
                  height: 250,
                  showLiveIcon: true,
                  watermarkText: "Hello",
                  showWatermark: true,
                  blurSensitiveContent: true,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

📚 Use this Package as a Library

📥 Depend on it

Run this command:

With Flutter:

flutter pub add mjpeg_stream

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  mjpeg_stream: ^latest_version

OR

mjpeg_stream:
    git:  
      url: https://github.com/MohammedShamseerPV/MJPEG-Stream.git
      ref: main  # Optional: specify the branch (default is 'main')

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

📌 Import it

Now in your Dart code, you can use:

import 'package:mjpeg_stream/mjpeg_stream.dart';

⚙️ API Reference

Property Type Description
streamUrl String The URL of the MJPEG stream.
fit BoxFit Defines how the image should be inscribed into the widget. Default: BoxFit.cover.
width double Width of the stream display. Default: double.infinity.
height double Height of the stream display. Default: 300.0.
timeout Duration Timeout for the network request. Default: 5 seconds.
enableLogging bool Enables logging for debugging. Default: false.
showWatermark bool Displays a watermark on the stream. Default: false.
watermarkText String Custom text for the watermark.
showLiveIcon bool Displays a "LIVE" indicator when streaming.
blurSensitiveContent bool Applies a blur effect over sensitive content.

🚀 How It Works

  1. The package establishes an HTTP connection to the MJPEG stream.
  2. It processes the received image frames in real-time.
  3. It updates the UI efficiently without performance issues.
  4. It handles errors and reconnection automatically. ⚡
  5. It provides logging for debugging purposes. 📜
  6. It allows blurring sensitive content for privacy. 🎭
  7. It enables branding with a watermark feature. 🏷️

🛠 Troubleshooting

  • Stream Not Loading? Check if your URL is correct and accessible.
  • 🔴 Slow Performance? Optimize the network or use a lower resolution stream.
  • 💥 Crashes? Ensure the stream URL is reachable and error handling is implemented.
  • 📝 Need Debugging? Enable logging by setting enableLogging: true.
  • 🎭 Blur Not Working? Ensure blurSensitiveContent is set to true.

🎯 Future Enhancements

  • ✅ Add support for pause/play functionality
  • ✅ Improve error handling
  • ✅ Optimize performance for low-latency streaming
  • ✅ Enhance logging and debugging features
  • ✅ Implement customizable UI overlays

📝 License

This package is open-source under the MIT License. Feel free to contribute! 😊

👨‍💻 Happy Coding! 🚀


🔗 Connect with Me


💰 Support My Work

If you found this package useful, consider supporting my work:

qr-code-phonePay

Libraries

mjpeg_stream