Sitemap
Alwin Sunil

Alwin Sunil

Fullstack Developer, CS Student at Kalvium. Around 2-3 hours a day, I work on my project CodeHost. Track my progress in my journal.

Echo: Day 2

1 min readNov 28, 2024

Today, I started with research on how to get streams from the producer (client) to the backend and save them to disk.
I started with a basic UI that takes in a stream from the camera or screen or both and sends the data to the WebSocket connection, which then gets saved to disk for the time being. Initially, the backend to handle this was written in JavaScript and tried running in Node.js but found that the chunks of data were being dropped, and thus the video was not completely being saved onto the disk. Later, I tried bun.js, but this was worse than Node.js.

Get Alwin Sunil’s stories in your inbox

Join Medium for free to get updates from this writer.

With the help of an LLM, I generated a Go program that does the same thing. Now the performance is better and much lighter on the CPU and memory resources. The current script takes in a few messages: two are text (start and end), and the other data we are listening to on the WebSocket connection is binary data. This binary data comes from the video feed sent from the frontend MediaRecorder API to the backend.

The stream is saved to a WebM file on every message, and later, after the connection closes, FFmpeg is used to encode the video to a final file and store it on the disk. The code written today has not been added to the client but has been pushed to a new branch, testing-out-ws, as it was rough and used for learning purposes.

That’s all for today, thanks for reading.

--

--

Alwin Sunil
Alwin Sunil

Written by Alwin Sunil

Fullstack Developer, CS Student at Kalvium. Around 2-3 hours a day, I work on my project CodeHost. Track my progress in my journal.