#Is it possible to display video stream from the Rust server to Tauri React?

6 messages · Page 1 of 1 (latest)

orchid veldt
#

I get the image on the client from my MacBook Pro camera. I send the bytes to the Rust server, then I send the bytes to Tauri React using the event:

app_handle.emit_all(“event-server-data”, video_base64).unwrap();

On the Tauri React side:

const [videoData, setVideoData] = useState<string>("");
  
  useEffect(() => {
    const unlistenAddMarker = listen<string>('event-server-data', (event) => {      
      
      setVideoData(event.payload)

    });

    return () => {
      unlistenAddMarker.then(f => f());
    };
  }, []);

return (
    <div className="container">
      <h1>Welcome to Tauri!</h1>

      {videoData && (
        <img src={`data:image/jpeg;base64,${videoData}`}/>

        // <video controls>
        //   <source src={`data:video/mp4;base64,${videoData}`} type="video/mp4" />
        //   Your browser does not support the video tag.
        // </video>
      )}
    ...

I can see the image.
I send frames every 16 milliseconds.
But it's really putting a lot of strain on my mac. I think this is very unoptimized and wrong approach. It also increases memory consumption.
How do I properly transfer a large amount of information (In this case it is uncompressed footage from my MacBook Pro camera)?

Or is Tauri not suitable for this? Or is Tauri more suitable for small amounts of data that are not transferred that often?

Thanks for your reply.

knotty ibex
orchid veldt
knotty ibex
#

The issue is getting the data into the webview(browser) sandbox. Your frontend stack doesn't matter that much.

orchid veldt
knotty ibex
#

From what i've heard of others yes, that should work well enough.