So I'm building a program that requires that I take a video and convert it to audio. I'm currently streaming the audio directly to the browser via node.js, but I've run into a major problem: I don't know how to find out how many bytes my audio is. As a result, the browser keeps throwing net::ERR_CONTENT_LENGTH_MISMATCH
when I don't get the right content-length. I've tried several strategies, all of which have failed:
Computing the size manually (Seconds * bitrate(kbps) * (1024 / 8)).
This produces an approximate answer, since I only know the length down to the nearest couple of seconds. Even though I'm relatively close, I still end up getting the same MISMATCH error.Piping the Stream to a buffer, getting the buffer's length, and piping the buffer to the browser
This works, but it can take 15-20 seconds to load each song. It's incredibly slow and puts a considerably larger load on the server