You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm trying to stream video frames (in this example Vec) from Rust to Flutter. But frb seems to eat more and more RAM growing exponentially.
Here is my code:
pubfnstream_video(stream_sink:StreamSink<Vec<u8>>,pipeline:String) -> anyhow::Result<()>{
gstreamer::init().unwrap();let element = gstreamer::parse::launch(&pipeline)?;let bin = element
.downcast::<Bin>().map_err(|_| anyhow::anyhow!("Failed to downcast initial element to bin"))?;let sink_element = bin.by_name("video-sink").ok_or(anyhow::anyhow!("Failed to find appsink named video-sink. The pipeline should always end with an appsink named video-sink"))?;let sink = sink_element.downcast::<gstreamer_app::AppSink>().map_err(|_| anyhow::anyhow!("Failed to map sink element to appsink. The pipeline should always end with an appsink"))?;
bin.set_state(gstreamer::State::Playing).unwrap();
std::thread::spawn(move || {loop{let sample = sink.pull_sample().unwrap();let buf = sample.buffer().unwrap().map_readable().unwrap().to_vec();
stream_sink.add(buf).unwrap();}});Ok(())}
Notes:
Removing the line with stream_sink.add results in constant memory use (aka no problem.) (I think this means the problem is not with Gstreamer)
Even when I remove the dart side code handling the stream (inside the Stream.listen function), memory use continues to grow.
If further information is needed, just write a comment and I will answer asap.
Thanks for everything
The text was updated successfully, but these errors were encountered:
Btw, if you want to show videos, then I guess it is great to avoid such rust-to-dart transfer, because after you transfer the bytes to Dart, indeed dart has to again transfer to its engine and display, which is quite long and slow.
Hi. I'm trying to stream video frames (in this example Vec) from Rust to Flutter. But frb seems to eat more and more RAM growing exponentially.
Here is my code:
Notes:
stream_sink.add
results in constant memory use (aka no problem.) (I think this means the problem is not with Gstreamer)Thanks for everything
The text was updated successfully, but these errors were encountered: