【问题标题】:does flutter support rstp/rtmp video player?Flutter 支持 rstp/rtmp 视频播放器吗?
【发布时间】:2018-05-30 19:08:58
【问题描述】:

在IOS中发现基于AVPlayer的flutter video_player,不支持rtsp url。 谁能帮我知道如何在颤振中播放格式为“rstp/rtmp”的视频? ????

【问题讨论】:

  • 我也有兴趣!
  • 您找到 RTSP 的解决方案了吗?

标签: video flutter


【解决方案1】:

Flutter Vlc 播放器包可以处理 rtsp 流。

flutter_vlc_player

这是自述文件部分的示例,更改源地址的“urlToStreamVideo”值以进行测试。

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

class ExampleVideo extends StatefulWidget {
  @override
  _ExampleVideoState createState() => _ExampleVideoState();
}

class _ExampleVideoState extends State<ExampleVideo> {
  final String urlToStreamVideo = 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4';
  final VlcPlayerController controller = new VlcPlayerController(
      // Start playing as soon as the video is loaded.
      onInit: (){
          controller.play();
      }  
  );
  final int playerWidth = 640;
  final int playerHeight = 360;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SizedBox(
            height: playerHeight,
            width: playerWidth,
            child: new VlcPlayer(
                aspectRatio: 16 / 9,
                url: urlToStreamVideo,
                controller: controller,
                placeholder: Center(child: CircularProgressIndicator()),
            )
        )
    );
  }
}

【讨论】:

  • 邀请您改进插件github.com/oneeyedraven/flutter_rtsp_ffmpeg,它支持在 Flutter 上以最小延迟进行 RTSP 流式传输。由于这是一个非常幼稚的插件,因此需要支持和帮助才能使其完美。
【解决方案2】:

我有一个类似的要求,我必须以最小的延迟显示来自 IP 摄像机的流。我尝试了很多开源播放器,但没有一个能够以大约 200 毫秒的延迟进行流式传输。

在互联网上彻底搜索后,我发现了一些示例,这些示例涉及在 Android 上使用 Native FFMPEG 代码来接收和解码 RTSP 流,并使用 NativeWindow 接口直接在 SurfaceView 上呈现它。在此之后,我能够以最小的延迟获得一个流。

在此之后,我将当前的实现(非常幼稚但有助于入门)放在一个颤振插件中,代码可在 [Github][1] 上找到

如果我们能进一步改进这个插件并使其完美地用于生产版本,那就太好了。

PS:该插件目前只支持Android,但我希望iOS版本可以在类似的线路上开发。 [1]:https://github.com/oneeyedraven/flutter_rtsp_ffmpeg

【讨论】:

    猜你喜欢
    • 2014-09-05
    • 1970-01-01
    • 2018-07-08
    • 2013-07-08
    • 2017-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-04-25
    • 1970-01-01
    相关资源
    最近更新 更多