Closed p-sco closed 2 weeks ago
try this
final player = Player();
NativePlayer native = player.platform as NativePlayer;
native.setProperty('profile', 'low-latency');
It works, thank you! It would be great to document this in the Readme.
For anyone else looking to do this:
class _RTSPFeedState extends State<RTSPFeedMediaKit> {
late final Player player;
late final NativePlayer native;
late final VideoController controller;
@override
void initState() {
super.initState();
player = Player();
native = player.platform as NativePlayer;
native.setProperty('profile', 'low-latency');
player.platform = native;
controller = VideoController(player,
configuration: const VideoControllerConfiguration(
width: 600, height: 400, enableHardwareAcceleration: true));
native.open(Media(widget.feedURI));
}
@override
Widget build(BuildContext context) {
return Center(
child: SizedBox(
width: widget.width.toDouble(),
height: widget.height.toDouble(),
child: Video(
controller: controller,
controls: NoVideoControls,
),
),
);
}
@override
void dispose() async {
player.dispose();
super.dispose();
}
}
btw @p-sco i dont recommend this
player = Player();
native = player.platform as NativePlayer;
native.setProperty('profile', 'low-latency');
player.platform = native;
it should be the code below, since it cleaner and it should not cause issues on web if you will use web
player = Player();
if (player.platform is NativePlayer) {
NativePlayer playerNative = player.platform as NativePlayer;
playerNative.setProperty('profile', 'low-latency');
}
I am attempting to write a flutter (android) application that views a live RTSP feed, and it needs lowest amount of latency possible to function as intended. The latency currently seems to be about 2 seconds for media_kit, when compared to around 0.5 seconds for VLC on the desktop at 100ms network caching, viewing the same RTSP stream.
I can't seem to find any configuration for media_kit that reduces latency closer to what desktop VLC has. The only semblance of an option is reducing the bufferSize on the PlayerConfiguration down from 32mb, but that doesn't seem to have any noticeable impact. I've also attempted to use the flutter_vlc_player package, which seems to be the only other package for flutter that supports RTSP, but that latency is even worse, no matter what settings I try.
Here is what I've tried for media_kit:
Any assistance would be greatly appreciated. Thanks.