我们有一个RTMP服务器,它从摄像头流,流URL被发送到Flutter应用程序中显示,我们使用软件包media_kit
将其存档,它工作得很好。
我们现在需要实现一个功能,当按下按钮时,Flutter应用程序会记录X秒。
我的问题是,我可以创建一个类似HTTP的请求,监听流字节并编写一个mp4文件吗?
我已经尝试过这个:been widget.url
= = rtmp://rtmp-server-the-rest-of-the-url
var uri = Uri.parse(widget.url);
try {
final path = await _localPath;
final file = await File('$path/test.mp4').create(recursive: true);
var request = http.MultipartRequest("POST", uri);
final response = await request.send();
var bytes = <int>[];
response.stream.listen((newBytes) {
bytes.addAll(newBytes);
});
Future.delayed(const Duration(seconds: 10), (() {
file.writeAsBytes(bytes);
}));
} catch (error) {
print(error.toString());
}
字符串
没有成功,我得到了一个错误:Invalid argument(s): Unsupported scheme 'rtmp' in URI rtmp://rtmp-server-rest-of-the-url
1条答案
按热度按时间tcbh2hod1#
http包不适用于RTMP链接,因此您会收到无效的url错误,请尝试rtmp_broadcaster: ^2.2.4