如何在Dart / Flutter中监听RTMP URL?

e4yzc0pl  于 2024-01-03  发布在  Flutter
关注(0)|答案(1)|浏览(169)

我们有一个RTMP服务器,它从摄像头流,流URL被发送到Flutter应用程序中显示,我们使用软件包media_kit将其存档,它工作得很好。
我们现在需要实现一个功能,当按下按钮时,Flutter应用程序会记录X秒。
我的问题是,我可以创建一个类似HTTP的请求,监听流字节并编写一个mp4文件吗?
我已经尝试过这个:been widget.url = = rtmp://rtmp-server-the-rest-of-the-url

  1. var uri = Uri.parse(widget.url);
  2. try {
  3. final path = await _localPath;
  4. final file = await File('$path/test.mp4').create(recursive: true);
  5. var request = http.MultipartRequest("POST", uri);
  6. final response = await request.send();
  7. var bytes = <int>[];
  8. response.stream.listen((newBytes) {
  9. bytes.addAll(newBytes);
  10. });
  11. Future.delayed(const Duration(seconds: 10), (() {
  12. file.writeAsBytes(bytes);
  13. }));
  14. } catch (error) {
  15. print(error.toString());
  16. }

字符串
没有成功,我得到了一个错误:Invalid argument(s): Unsupported scheme 'rtmp' in URI rtmp://rtmp-server-rest-of-the-url

tcbh2hod

tcbh2hod1#

http包不适用于RTMP链接,因此您会收到无效的url错误,请尝试rtmp_broadcaster: ^2.2.4

相关问题