GitHub 代码仓pinkfish/flutter_rtmppublisher

flutter_rtmppublisher

使用相机插件作为基础,实现所有基本的相机/录制管理,并发布到RTMP。

flutter_rtmppublisher 项目封面
星标
98
复刻
145
最近推送(UTC)
2023年4月10日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

rtmppublisher

RTMP streaming and camera plugin.

Getting Started

This plugin is an extension of the flutter camera plugin to add in rtmp streaming as part of the system. It works on android and iOS (but not web).

This means the API Is exactly the same as the camera and installation requirements are the same. The difference exists in an extra API that is startStreaming(URL), it takes an RTMP URL and starts streaming to that specific URL.

For android I use rtmp-rtsp-stream-client-java and for iOS I use HaishinKit.swift

Features:

  • Display live camera preview in a widget.
  • Snapshots can be captured and saved to a file.
  • Record video.
  • Add access to the image stream from Dart.

Installation

First, add camera as a dependency in your pubspec.yaml file.

iOS

Add two rows to the ios/Runner/Info.plist:

  • one with the key Privacy - Camera Usage Description and a usage description.
  • and one with the key Privacy - Microphone Usage Description and a usage description.

Or in text format add the key:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>
Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

Need to add in a section to the packaging options to exclude a file, or gradle will error on building.

packagingOptions {
   exclude 'project.clj'
}
Example

Here is a small example flutter app displaying a full screen camera preview.

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';

List<CameraDescription> cameras;

Future<void> main() async {
  cameras = await availableCameras();
  runApp(CameraApp());
}

class CameraApp extends StatefulWidget {
  @override
  _CameraAppState createState() => _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
  CameraController controller;

  @override
  void initState() {
    super.initState();
    controller = CameraController(cameras[0], ResolutionPreset.medium);
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    if (!controller.value.isInitialized) {
      return Container();
    }
    return AspectRatio(
        aspectRatio:
        controller.value.aspectRatio,
        child: CameraPreview(controller));
  }
}

A more complete example of doing rtmp streaming is in the example code

pinkfish GitHub avatar
GitHub 作者

pinkfish ↗

语言KotlinDartObjective-CSwiftRubyShell

分类

此仓库发布的插件

使用的依赖

依赖清单 7 项

  • flutter{"sdk":"flutter"}
  • path_provider开发依赖^2.0.1
  • video_player开发依赖^2.1.1
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_driver开发依赖{"sdk":"flutter"}
  • pedantic开发依赖^1.11.0
  • mockito开发依赖^5.0.7

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗