12 ms·
We replaced H.264 streaming with JPEG screenshots (and it worked better)
- gethly 9mo agooof. i knew instantly what the problem was and realised these people have no clue about how video even works. yet another vibe coded AI startup.
- mring33621 9mo agoThis is such a great post. I love the "The Oscillation Problem"!
- robrain 9mo ago"Think “screen share, but the thing being shared is a robot writing code.”" Thinks: why not send text instead of graphics, then? I'm sure it's more complicated than that...
- bambax 9mo agoYeah, I'm thinking the same thing. Capture the text somehow and send that, and reconstruct it on the other end; and the best part is you only need to send each new character, not the whole screen, so it should be very small and lightning fast?
- jodrellblank 9mo agoThinks: this video[1] is the processed feed from the Huygens space probe landing on Saturn's moon Titan circa 2005. Relayed through the Cassini probe orbiting Saturn, 880 million miles from the Sun. At a total mission cost of 3.25 billion dollars. This is the sensor data, altitude, speed, spin, ultra violet, and hundreds of photos. (Read the description for what the audio is encoding, it's neat!) Look at the end of the video, the photometry data count stops at "7996 kbytes received"(!) > "Turns out, 40Mbps video streams don’t appreciate 200ms+ network latency. Who knew. “Just lower the bitrate,” you say. Great idea. Now it’s 10Mbps of blocky garbage" Who could do anything useful with 10Mbps. :/ [1] https://en.wikipedia.org/wiki/File:Huygens_descent.ogv https://en.wikipedia.org/wiki/File:Huygens_descent.ogv
- stefan_ 9mo agoThis is a great new "you can land on the moon with 10 MHz".
- petcat 9mo agoso did they reinvent mjpeg
- scoopdewoop 9mo agoI was blown away when I realized I could stream mjpeg from a raspberry pi camera with lower latency and less ceremony than everything I tried with webrtc and similar approaches.
- ok123456 9mo agofrom first principles.
- rzzzt 9mo agoAn MPEG-1-based screen sharing experiment appeared here 10 years ago: - https://news.ycombinator.com/item?id=9954870 https://news.ycombinator.com/item?id=9954870 - https://phoboslab.org/log/2015/07/play-gta-v-in-your-browser-sort-of https://phoboslab.org/log/2015/07/play-gta-v-in-your-browser...
- dimatura 9mo agoYup, when reading this I immediately thought of jsmpeg, which I'm fond of.
- wood_spirit 9mo agoA long time ago I was trying to get video multiplexing to work over mobile over 3G. We struggled with H264 which had broad enough hardware support but almost no tooling and software support on the phones we were targeting. Even with engineers from the phone manufacturer as liaison we struggled to get access to any kind or SDK etc. We ended up doing JPEG streaming instead, much like the article said. And it worked great but we discovered we were getting a fraction of the framerate reported in Flash players - the call to refresh the screen was async and the act of receiving and deciding the next frame staved the redraw so the phone spent more time receiving lots of frames but not showing them. Super annoying and I don’t think the project survived long enough for us to find a fix.
- egorfine 9mo ago> The constraint that ruined everything: It has to work on enterprise networks. > You know what enterprise networks love? HTTP. HTTPS. Port 443. That’s it. That’s the list. That's not enough. Corporate networks also love to MITM their own workstations and reinterpret http traffic. So, no WebSockets and no Server-Side Events either, because their corporate firewall is a piece of software no one in the world wants and everyone in the world hates, including its own developers. Thus it only supports a subset of HTTP/1.1 and sometimes it likes to change the content while keeping Content-Length intact. And you have to work around that, because IT dept of the corporation will never lift restrictions. I wish I was kidding.
- rcarmo 9mo agoThey even break server-sent events (which is still my default for most interactive apps)
- deleted 9mo ago[deleted]
- j45 9mo agoThere are other ways to make server-sent events work. I try to remember many environments once likely supported Flash.
- ris 9mo agoCorporate IT needs to die.
- embedding-shape 9mo agoI think the general idea/flow of things is "numbers go up, until $bubble explodes, and we built up smaller things from the ground up, making numbers go up, bloating go up, until $bubble explodes..." and then repeat that forever. Seems to be the end result of capitalism. If you wanna kill corporate IT, you have to kill capitalism first.
- 9mo ago
- HocusLocus 9mo agoThis is a beautiful cope. Every time technology rolls out something that works great 90% of the time for 90% of the people, those 10%s pile up big time in support and lost productivity. You need functional systems that fall back gracefully to 1994 if necessary. I started the first ISP in my area. We had two T1s to Miami. When HD audio and the rudiments of video started to increase in popularity, I'd always tell our modem customers, "A few minutes of video is a lifetime of email. Remember how exciting email was?"
- rcarmo 9mo agoThis was the most entertaining thing I read all day. Kudos. I've had similar experiences in the past when trying to do remote desktop streaming for digital signage (which is not particularly demanding in bandwidth terms). Multicast streaming video was the most efficent, but annoying to decode when you dropped data. I now wonder how far I could have gone with JPEGs...
- binocarlos 9mo ago> I mashed F5 like a degenerate. I love the style of this blog-post, you can really tell that Luke has been deep down in the rabbit hole, encountered the Balrog and lived to tell the tale.
- jamiesonbecker 9mo agoI like it too, even though it has that distinctive odor of being totally written by chatgpt though. (a bit distracting tbh)
- deleted 9mo ago[deleted]
- KptMarchewa 9mo agoThat's amazing! You're going to see a lot more of those AI generated blogs in the coming century!
- lostmsu 9mo agoIf you have latency detection already why not pause H.264 frames, then when ack comes just force a key frame and resume (perhaps with adjusted target bitrate)?
- bobmcnamara 9mo agoYeah, monitor the send queue length and reduce bit rate accordingly.
- brigade 9mo agoThat would require that they understand the protocol stack they're using to send H.264 frames
- epx 9mo agoWould HLS be an option? I publish my home security cameras via WebRTC, but I keep HLS as a escape for hotel/cafe WiFi situations (MediaMTX makes it easy to offer both).
- originalvichy 9mo agoThought of the same. I have not set it up outside of hobby projects, but it should work over HTTP as it says on the box, even inside a strict network?
- epx 9mo agoYes, it is strictly HTTP, not even persistent connections required.
- bob1029 9mo ago> Why JPEGs Actually Slap JPEG is extremely efficient to [de/en]code on modern CPUs. You can get close to 1080p60 per core if you use a library that leverages SIMD. I sometimes struggle with the pursuit of perfect codec efficiency when our networks have become this fast. You can employ half-assed compression and still not max out a 1gbps pipe. From Netflix & Google's perspective it totally makes sense, but unless you are building a streaming video platform with billions of customers I don't see the point.
- Dylan16807 9mo ago> When the network is bad, you get... fewer JPEGs. That’s it. The ones that arrive are perfect. You can have still have weird broken stallouts though. I dunno, this article has some good problem solving but the biggest and mostly untouched issue is that they set the minimum h.264 bandwidth too high. H.264 can do a lot better than JPEG with a lot less bandwidth. But if you lock it at 40Mbps of course it's flaky. Try 1Mbps and iterate from there. And going keyframe-only is the opposite of how you optimize video bandwidth.
- HelloUsername 9mo ago> Try 1Mbps and iterate from there. From the article: “Just lower the bitrate,” you say. Great idea. Now it’s 10Mbps of blocky garbage that’s still 30 seconds behind.
- Dylan16807 9mo agoRejecting it out of hand isn't actually trying it. 10Mbps is still way too high of a minimum. It's more than YouTube uses for full motion 4k. And it would not be blocky garbage, it would still look a lot better than JPEG.
- vscode-rest 9mo ago1Mbps for video is rule of thumb I use. Of course that will depend on customer expectations. 500K can work, but it won’t be pretty.
- Dylan16807 9mo agoFor normal video I think that's a good rule of thumb. For mostly-static content at 4fps you can cut a bunch more bitrate corners before it looks bad. (And 2-3 JPEGs per second won't even look good at 1Mbps.)
- deleted 9mo ago[deleted]
- ddtaylor 9mo ago> I mashed F5 like a degenerate Bargaining.
- mannyv 9mo agoAwesome! Good engineering: when you're not too proud to do the obvious, but sort of cheesy-sounding solution.
- ddtaylor 9mo agoA very stupid hack that can work to "fix" this could be to buffer the h264 stream at the data center using a proxy before sending it to the real client, etc.
- jamiesonbecker 9mo agoOne of the big issues was latency.
- ddtaylor 9mo agoYes, but the real issue (IMO) is that something is causing an avalanche of some kind. You would much rather have a consistent 100ms increased latency for this application if it works much better for users with high loss, etc. Also, to be clear, this is basically just a memory cache. I doubt it would add any "real" latency like that. The idea is that if the fancy system works well on connection A and works poorly on connection B, what are the differences and how can we modify the system so that A and B are the same from it's perspective.
- deleted 9mo ago[deleted]
- refulgentis 9mo agoThe LinkedIn slop tone, random bolding, miscopied Markdown tables makes me invoke: "please read the copy you worked on with AI" smaller thing: many, many, moons ago, I did a lot of work with H.264. "A single H.264 keyframe is 200-500KB." is fantastical. Can't prove it wrong because it will be correct given arbitrary dimensions and encoding settings, but, it's pretty hard to end up with. Just pulled a couple 1080p's off YouTube, biggest I-frame is 150KB, median is 58KB (`ffprobe $FILE -show_frames -of compact -show_entries frame=pict_type,pkt_size | grep -i "|pict_type=I"`)
- jamiesonbecker 9mo agoat least it had a minimum of Clause. Clause. Punchline.
- escapecharacter 9mo agoI guess this is great as long as you don't worry about audio sync?
- keepamovin 9mo agoThis is similar to what BrowserBox does for the same reasons outlined. Glad to see the control afforded by "ye olde ways" is recognized and widely appreciated.
- algesten 9mo agoWebSockets over TCP is probably always going to cause problems for streaming media. WebRTC over UDP is one choice for lossy situations. Media over Quic might be another (is the future here?), and it might be more enterprise firewall friendly since HTTP3 is over Quic.
- hmontazeri 9mo agoAnother case of we’re going backwards. The boring stuff is what works every time…
- the8472 9mo ago> looks at TCP congestion control literature > closes tab Eh, there are a few easy things one can try. Make sure to use a non-ancient kernel on the sender side (to get the necessary features), then enable BBR and NOTSENT_LOWAT (https://blog.cloudflare.com/http-2-prioritization-with-nginx/ https://blog.cloudflare.com/http-2-prioritization-with-nginx...) to avoid buffering more than what's in-flight and then start dropping websocket frames when the socket says it's full. Also, with tighter integration with the h264 encoder loop one could tell it which frames weren't sent and account for that in pframe generation. But I guess that wasn't available with that stack.
- tverbeure 9mo agoI’m surprised that H264 I-frame only compresses less than JPG. Maybe because the basic frequency transform is 4x4 vs 8x8 for JPG?
- plorkyeran 9mo agoTheir h264 iframes were bigger than the jpegs because they told the h264 encoder to produce bigger images. If they had set it to produce images the same size as the jpegs it most likely would have resulted in higher quality.
- Sean-Der 9mo agoDoesn’t matter now, but what led you to TURN? You can run all WebRTC traffic over a single port. It’s a shame you spent so much time/were frustrated by ICE errors That’s great you got something better and with less complexity! I do think people push ‘you need UDP and BWE’ a little too zealously. If you have a homogeneous set of clients stuff like RTMP/Websockets seems to serve people well
- ErroneousBosh 9mo agoSo, they've invented MJPEG? Or is it intra-only H.264? I mean, none of this is especially new. It's an interesting trick though!
- Jakob 9mo agoYes, this is unfortunately still the way and was very common back when iOS Safari did not allow embedded video. For a fast start of the video, reverse the implementation: instead of downgrading from Websockets to polling when connection fails, you should upgrade from polling to Websockets when the network allows. Socket.io was one of the first libraries that did that switching and had it wrong first, too. Learned the enterprise network behaviour and they switched the implementation.
- karhuton 9mo agoI made this because I got tired of screensharing issues in corporate environments: https://bluescreen.live https://bluescreen.live (code via github). Screenshot once per second. Works everywhere. I’m still waiting for mobile screenshare api support, so I could quickly use it to show stuff from my phone to other phones with the QR link.
- jayd16 9mo agoSo they replaced a TCP connection with no congestion control with a sycnronous poll of an endpoint which is inherently congestion controlled. I wonder if they just tried restarting the stream at a lower bitrate once it got too delayed. The talk about how the images looks more crisp at a lower FPS is just tuning that I guess they didn't bother with.
- deleted 9mo ago[deleted]
- dotancohen 9mo agoThey're just streaming a video feed of an LLC running in a terminal? Why not stream the actual text? Or fetch it piecemeal over AJAX requests? They complain that corporate networks support only HTTPS and nothing else? Do they not understand what the first T stands for?
- TZubiri 9mo agoSuppose an LLM opens a browser, or opens a corporate .exe and GUI and starts typing in there and clicking buttons.
- worksonmine 9mo agoYou don't give it a browser or buttons to click.
- j-me 9mo agoI think we've passed the Rubicon when it comes to that
- eterm 9mo agoIndeed, live text streaming is well over 100 years old: https://en.wikipedia.org/wiki/Teleprinter https://en.wikipedia.org/wiki/Teleprinter
- wewewedxfgdf 9mo agowebp is smaller than jpeg https://developers.google.com/speed/webp/docs/webp_study https://developers.google.com/speed/webp/docs/webp_study ALSO - the blog author could simplify - you don't need any code at all at the web browser. The <img> tag automatically does motion jpeg streaming.
- F3nd0 9mo ago… and JPEG XL is smaller than WebP.
- wewewedxfgdf 9mo agoJPEG XL looks to have pretty poor support. https://caniuse.com/jpegxl https://caniuse.com/jpegxl
- F3nd0 9mo agoYes, though hopefully not for long; unfortunately not all codecs are given equal treatment... If having native support in a web browser is important, though, then yes, WebP is a better choice (as is JPEG).
- deleted 9mo ago[deleted]
- avsn 9mo agoWe did something similar in one of the places I've worked at. We sent xy coordinates and pointer events from our frontend app to our backend/3d renderer and received JPEG frames back. All of that wrapped in protobuf messages and sent via WS connection. Surpassingly it kinda worked, not "60fps worked" though obviously.
- adamjs 9mo agoThey might want to check out what VNC has been doing since 1998– keep the client-pull model, break the framebuffer up into tiles and, when client requests an update, perform a diff against last frame sent, composite the updated tiles client-side. (This is what VNC falls back to when it doesn’t have damage-tracking from the OS compositor) This would really cut down on the bandwidth of static coding terminals where 90% of screen is just cursor flashing or small bits of text moving. If they really wanted to be ambitious they could also detect scrolling and do an optimization client-side where it translates some of the existing areas (look up CopyRect command in VNC).
- djmips 9mo agoThe blog post did smell of inexperience. Glad to hear there is other approaches - is something like that open source?
- cogman10 9mo agoYup. Go look into tigervnc if you want to see the source. But also you can just search for "tigervnc h.264" and you'll see extensive discussions between the devs on h.264 and integrating it into tiger. This is something that people spent a LOT of brainpower on.
- tombert 9mo agoI'm not sure; sometimes being an experienced dev gravitates you towards the lazy solutions that are "good enough". Senior engineers are often expected to work at a rate that precludes solving interesting problems, and so the dumber solution will often win; at least that's been my experience, and what I tell myself to go to sleep at night when I get told for the millionth time that the company can't justify formal verification.
- djmips 9mo agoI understand what you're saying and certainly I've come up against that myself. I didn't intend my comment to be super pejorative.
- gametheory87 9mo agoIt’s always TCP_NODELAY seems relevant here: https://news.ycombinator.com/item?id=40310896 https://news.ycombinator.com/item?id=40310896
- MBCook 9mo agoSo it’s video of an AI typing text? Why not just send text? Why do you need video at all?
- bogwog 9mo agoWhy send anything at all if the AI isn't even good enough to solve their own problems? (Although the fact they decided to use Moonlight in an enterprise product makes me wonder if their product actually was vibe coded)
- TacticalCoder 9mo agoYou apparently need video for the 45 seconds window you then get before preventing catastrophic things to happen. From TFA: > You’re watching the AI type code from 45 seconds ago > > By the time you see a bug, the AI has already committed it to main > > Everything is terrible forever Is this satire? I mean: if the solution for things to not be terrible forever consists in catching what an AI is doing in 45 seconds (!) before the AI commits to trunk, I'm sorry but you should seriously re-evaluate your life plans.
- kimixa 9mo agoIf you can realistically notice and reason out a bug within ~45 seconds of seeing the diff, then they are really shallow "dumb" bugs. The sort that even a junior would be expected to avoid. And I wonder how many other massive issues are being committed to main, but would take longer to reason out, but you're already looking at the next 45-second shallow bug. This has to be a joke, right?
- laurencerowe 9mo agoIf you are ok with a second or so of latency then MPEG-DASH (standardized version of HTTP Live Streaming) is likely the best bet. You simply serve the video chunks over HTTP so it should be just as compatible as the JPEG solution used here but provide 60fps video rather than crappy jpegs. The standard supports adaptive bit rate playback so you can provide both low quality and high quality videos and players can switch depending on bandwidth available.
- sevensor 9mo agoNo mention of PNGs? I don’t usually go to jpegs first for screenshots of text. Did png have worse compression? Burn more cpu? I’m sure there are good reasons, but it seems like they’ve glossed over the obvious choice here. edit: Thanks for the answers! The consensus is that PNG en/de -coding is too expensive compared to jpeg.
- j45 9mo agoPNGs likely perform great, existing enterprise network filters, browser controls, etc, might not, even with how old PNGs are now.
- StilesCrisis 9mo agoPNGs are lossless so you can’t really dial up the compression. You can save space by reducing to 8-bit color (or grayscale!) but it’s basically the equivalent of raw pixels plus zlib.
- vikingerik 9mo agoPNG can be lossy. It can be done by first discarding some image detail, to make adjacent almost-matching pixel values actually match, to be more amenable to PNG's compression method. pngquant.org has a tool that does it. There are usage cases where you might want lossy PNG over other formats; one is for still captures of 2d animated cartoon content, where H.264 tended to blur the sharp edges and flat color areas and this approach can compensate for that.
- wewewedxfgdf 9mo agoPNG is VERY slow compared to other formats. Not suitable for this sort of thing.
- dimatura 9mo agoPNGs of screenshots would probably compress well, and the quality to size ratio would definitely be better than JPG, but the size would likely still be larger than a heavily compressed JPG. And PNG encoding/decoding is relatively slow compared to JPG.
- praveen9920 9mo agoThis reminds me of the time we built a big angular3 codebase for a content platform. When we had to launch, the search engines were expecting content to be part of page html while we are calling APIs to fetch the content ( angular3 didn’t have server side rendering at that point) So only plausible thing to do was pre-build html pages for content pages and let load angular’s JS take its time to load ( for ux functionality). It looked like page flickered when JS loads for the first time but we solved the search engine problem.
- kccqzy 9mo agoThere are so many things that I would have done differently. > We added a keyframes_only flag. We modified the video decoder to check FrameType::Idr. We set GOP to 60 (one keyframe per second at 60fps). We tested. Why muck around with P-frames and keyframes? Just make your video 1fps. > Now it’s 10Mbps of blocky garbage that’s still 30 seconds behind. 10 Mbps is way too much. I occasionally watch YouTube videos where someone writes code. I set my quality to 1080p to be comparable with the article and YouTube serves me the video at way less than 1Mbps. I did a quick napkin math for a random coding video and it was 0.6Mbps. It’s not blocky garbage at all.
- mdavid626 9mo agoSetting to 1 FPS might not be enough. GOP or P frame setting needs to be adjusted to make every frame keyframe.
- deleted 9mo ago[deleted]
- Dylan16807 9mo agoWhy would you do that? Nearly-static content is where you want even fewer keyframes than usual. In a situation like this you need them when the connection is interrupted and you reset things, and not much of anywhere else.
- mdavid626 9mo ago1 FPS with GOP 60 might just simply not play in some players.
- kccqzy 9mo agoYou wouldn’t use 1fps in conjunction with GOP 60. The original article wanted exactly one key frame every 60 frames and the server drops all frames other than keyframes. I was pointing out that this is a roundabout way of achieving 1 fps.
- j45 9mo agoOne thing this article does point to indirectly is sometimes, simple scales, and complex fails.
- willseth 9mo ago“We didn’t have the expertise to build the thing we were building, got in way over our heads, and built a basic POC using legacy technology, which is fine.”
- Tarean 9mo agoHaving pair programmed over some truly awful and locked down connections before, dropped frames are infinitely better than blurred frames which make text unreadable whenever the mouse is moved. But 40mbps seems an awful lot for 1080p 60fps. Temporal SVC (reduce framerate if bandwidth constrained) is pretty widely supported by now, right? Though maybe not for H.264, so it probably would have scaled nicely but only on Webrtc?
- keerthiko 9mo ago> The fix was embarrassingly simple: once you fall back to screenshots, stay there until the user explicitly clicks to retry. There is another recovery option: - increase the JPEG framerate every couple seconds until the bandwidth consumption approaches the H264 stream bandwidth estimate - keep track latency changes. If the client reports a stable latency range, and it is acceptable (<1s latency, <200ms variance?) and bandwidth use has reached 95% of H264 estimate, re-activate the stream Given that text/code is what is being viewed, lower res and adaptive streaming (HLS) are not really viable solutions since they become unreadable at lower res. If remote screen sharing is a core feature of the service, I think this is a reasonable next step for the product. That said, IMO at a higher level if you know what you're streaming is human-readable text, it's better to send application data pipes to the stream rather than encoding screenspace videos. That does however require building bespoke decoders and client viewing if real time collaboration network clients don't already exist for the tools (but SSH and RTC code editors exist)
- benterix 9mo ago> And the size! A 70% quality JPEG of a 1080p desktop is like 100-150KB. A single H.264 keyframe is 200-500KB. I believe the latter can be adjusted in codec settings.
- mdavid626 9mo agoOf course. But same quality h264 keyframe will not be much smaller than JPEG.
- mikepavone 9mo ago> When the network is bad, you get... fewer JPEGs. That’s it. The ones that arrive are perfect. This would make sense... if they were using UDP, but they are using TCP. All the JPEGs they send will get there eventually (unless the connection drops). JPEG does not fix your buffering and congestion control problems. What presumably happened here is the way they implemented their JPEG screenshots, they have some mechanism that minimizes the number of frames that are in-flight. This is not some inherent property of JPEG though. > And the size! A 70% quality JPEG of a 1080p desktop is like 100-150KB. A single H.264 keyframe is 200-500KB. We’re sending LESS data per frame AND getting better reliability. h.264 has better coding efficiency than JPEG. For a given target size, you should be able to get better quality from an h.264 IDR frame than a JPEG. There is no fixed size to an IDR frame. Ultimately, the problem here is a lack of bandwidth estimation (apart from the sort of binary "good network"/"cafe mode" thing they ultimately implemented). To be fair, this is difficult to do and being stuck with TCP makes it a bit more difficult. Still, you can do an initial bandwidth probe and then look for increasing transmission latency as a sign that the network is congested. Back off your bitrate (and if needed reduce frame rate to maintain sufficient quality) until transmission latency starts to decrease again. WebRTC will do this for you if you can use it, which actually suggests a different solution to this problem: use websockets for dumb corporate network firewall rules and just use WebRTC everything else
- eichin 9mo agoProbably either (1) they don't request another jpeg until they have the previous one on-screen (so everything is completely serialized and there are no frames "in-flight" ever) (2) they're doing a fresh GET for each and getting a new connection anyway (unless that kind of thing is pipelined these days? in which case it still falls back to (1) above.)
- 01HNNWZ0MV43FF 9mo agoYou can still get this backpressure properly even if you're doing it push-style. The TCP socket will eventually fill up its buffer and start blocking your writes. When that happens, you stop encoding new frames until the socket is able to send again. The trick is to not buffer frames on the sender.
- moralestapia 9mo ago>A single H.264 keyframe is 200-500KB. Hmm they must be doing something wrong, they're not usually that heavy.
- nico 9mo agoSuper interesting. Some time ago I wrote some code that breaks down a jpeg image into smaller frames of itself, then creates an h.264 video with the frames, outputting a smaller file than the original image You can then extract the frames from the video and reconstruct the original jpeg Additionally, instead of converting to video, you can use the smaller images of the original, to progressively load the bigger image, ie. when you get the first frame, you have a lower quality version of the whole image, then as you get more frames, the code progressively adds detail with the extra pixels contained in each frame It was a fun project, but the extra compression doesn’t work for all images, and I also discovered how amazing jpeg is - you can get amazing compression just by changing the quality/size ratio parameter when creating a file
- poly2it 9mo agoWhy is video streaming so difficult? We've been doing it for decades, why is there seemingly no FOSS library which let's me encode an arbitrary dynamic frame rate image stream in Rust and get HD data with delta encoding in a browser receiver? This is insanity.
- worksonmine 9mo agoI'm confused, do people actually watch their agents code like it was a screen share? Why does the AI even mess with that, just send a diff over text? Is it getting a keyboard next? This is the definition of over-engineering. I don't usually criticize ideas but this is so stupid my head hurts.
- krater23 9mo agoAnd working in this setup at all sounds horrible. Who wants that?
- any1 9mo agoI have some experience with pushing video frames over TCP. It appears that the writer has jumped to conclusions at every turn and it's usually the wrong one. The reason that the simple "poll for jpeg" method works is that polling is actually a very crude congestion control mechanism. The sender only sends the next frame when the receiver has received the last frame and asks for more. The downside of this is that network latency affects the frame rate. The frame rate issue with the polling method can be solved by sending multiple frame requests at a time, but only as many as will fit within one RTT, so the client needs to know the minimum RTT and the sender's maximum frame rate. The RFB (VNC) protocol does this, by the way. Well, the thing about rtt_min and frame rate isn't in the spec though. Now, I will not go though every wrong assumption, but as for this nonsense about P-frames and I-frames: With TCP, you only need one I-frame. The rest can be all P-frames. I don't understand how they came to the conclusion that sending only I-frames over TCP might help with their latency problem. Just turn off B-frames and you should be OK. The actual problem with the latency was that they had frames piling up in buffers between the sender and the receiver. If you're pushing video frames over TCP, you need feedback. The server needs to know how fast it can send. Otherwise, you get pile-up and a bunch of latency. That's all there is to it. The simplest, absolutely foolproof way to do this is to use TCP's own congestion control. Spin up a thread that does two things: encodes video frames and sends them out on the socket using a blocking send/write call. Set SO_SNDBUF on that socket to a value that's proportional to your maximum latency tolerance and the rough size of your video frames. One final bit of advice: use ffmpeg (libavcodec, libavformat, etc). It's much simpler to actually understand what you're doing with that than some convoluted gstreamer pipeline.
- andai 9mo agoI recognize this voice :) This is Claude.
- andai 9mo agoMany moons ago I was using this software which would screenshot every five seconds and give you a little time lapse and the end of the day. So you could see how you were spending your computer time. My hard disk ended up filling up with tens of gigabytes of screenshots. I lowered the quality. I lowered the resolution, but this only delayed the inevitable. One day I was looking through the folder and I noticed well almost all the image data on almost all of these screenshots is identical. What if I created some sort of algorithm which would allow me to preserve only the changes? I spent embarrassingly long thinking about this before realizing that I had begun to reinvent video compression! So I just wrote a ffmpeg one-liner and got like 98% disk usage reduction :)
- afiori 9mo agoYou could do better than video compression because you could use older keyframes or a combination of keyframes. I am pretty sure it might be np compete to find the best combination
- kccqzy 9mo agoI did something similar about fifteen years ago. A command line utility to take screenshots. And QuickTime to convert the image sequence to a video. This was before I had heard of ffmpeg so the last bit was done with the QuickTime UI. I remember also adding the screenshot timestamps as a subtitle track.
- dengolius 9mo agowhat about av1?
- krater23 9mo agoWhat's about configuring the codec correctly? Using mjpeg? Using VNC? Throwing all this shit into the trashcan and get just diff's in utf-8 from the coding agent? Or maybe self-write the code to not create this hell of bullshit code that lead to the issues the article writes about? Which you a Merry Christmas! :D
- breve 9mo agoWebP is well supported in browsers these days. Use WebP for the screenshots instead of JPEG and it will reduce the file size: https://developers.google.com/speed/webp/gallery1 https://developers.google.com/speed/webp/gallery1 https://caniuse.com/webp https://caniuse.com/webp
- STELLANOVA 9mo agoWe did something similar +12 years ago with `streaming` AWS running app inside the browser. Basically you can run 3d studio max on chromebook. App is actually running on AWS instance and it just sending jpegs to browser to `stream` it. We did a lot of QoS logic and other stuff but it was actually working pretty nice. Adobe used it for some time to allow user to run Photoshop in the browser. Good old days..
- ronyfadel 9mo agoWho’s “we” in this case? Amazon (AWS)?
- andrewstuart 9mo agoI wrote a motion jpeg server for precisely this use case. https://github.com/crowdwave/maryjane https://github.com/crowdwave/maryjane The secret to great user experience is you return the current video frame at time of request.
- dimatura 9mo agoAbout eight years ago I was trying to stream several videos of a drone over the internet for remote product demos. Since we were talking to customers while the demo happened, the latency needed to be less than a few seconds. I couldn't get that latency with the more standard streaming video options I tried, and at the time setting up something based on WebRTC seemed pretty daunting. I ended up doing something pretty much like JPEGs as well, via the jsmpeg library [1]. Worked great. [1] https://jsmpeg.com/ https://jsmpeg.com/ (tagline: "decode like it's 1999")
- mgaunard 9mo agoRTP is specifically designed for real-time video.
- K0nserv 9mo agoYou can do TURN using TLS/TCP over port 443. This can fool some firewalls, but will still fail for instances when an intercepting HTTP proxy is used. The neat thing about ICE is that you get automatic fallbacks and best path selection. So best case IPv6 UDP, worst case TCP/TLS One of the nice things about HTTP3 and QUIC will be that UDP port 443 will be more likely to be open in the future.
- HackerThemAll 9mo agoIt's going to take those conservative netadmins another 10 to 20 years to learn that HTTP/3 or QUIC works over UDP and that it needs to be enabled. So... happy buffering and watching spinners until then.
- Eduard 9mo ago> A JPEG screenshot is self-contained. It either arrives complete, or it doesn’t. There’s no “partial decode.” What about Progressive JPEG?
- julik 9mo agoHaving built an image sequence player using JPEGs back in the day - I can attest that it slappps.
- visiondude 9mo agoI very confused, couldn’t they have achieved much better outcome with existing hls tech with adaptive bitrate playlists? Seems they both created the problem and found a suboptimal solution.
- dicroce 9mo agoExactly my thoughts.
- mschuster91 9mo agoThey don't have ffmpeg in the video pipeline, making anything a true PITA. ffmpeg has long solved the task of outputting HLS, DASH or whatever else standard and it Just Works No Matter Where. But if you're not using ffmpeg... you're bound to learn all the mistakes the ffmpeg people had to learn, and there are so many hidden traps.
- elzbardico 9mo agoThere's no real reason other than bad configuration/coding for a H.264 1080p 30fps screen share stream to sustainably use 40mbps. You can watch an action move at the same frame rate but with 4k resolution while using less than half this bandwidth. The real solution is using WebRTC, like every single other fucking company that have to stream video is doing. Yes, enterprise consumers require additional configuration. Yes, sometimes you need to provide a "network requirements" sheet to your customer so they can open a ticket with their IT to configure an exception. Second problem, usually enterprise networks are not as bad as internet cafe networks, but then, internet café networks usually are not locked down, so, you should always try first the best case scenario with webrtc and turn servers on 3478. That will also be the best option for really bad networks, but usually those networks are not enterprise networks. Please configure your encoder, 40mbps bit rate for what you're doing is way way too much. Test if TURN is not acessible. try it first with UDP (the best option and will also work with internet cafe), if not try over tcp on port 443, not working? try over tls on port 443.
- qbow883 9mo agoSetting aside the various formatting problems and the LLM writing style, this just seems all kinds of wrong throughout. > “Just lower the bitrate,” you say. Great idea. Now it’s 10Mbps of blocky garbage that’s still 30 seconds behind. 10Mbps should be way more than enough for a mostly static image with some scrolling text. (And 40Mbps are ridiculous.) This is very likely to be caused by bad encoding settings and/or a bad encoder. > “What if we only send keyframes?” The post goes on to explain how this does not work because some other component needs to see P-frames. If that is the case, just configure your encoder to have very short keyframe intervals. > And the size! A 70% quality JPEG of a 1080p desktop is like 100-150KB. A single H.264 keyframe is 200-500KB. A single H.264 keyframe can be whatever size you want, *depending on how you configure your encoder*, which was apparently never seriously attempted. Why are we badly reinventing MJPEG instead of configuring the tools we already have? Lower the bitrate and keyint, use a better encoder for higher quality, lower the frame rate if you need to. (If 10 fps JPEGs are acceptable, surely you should try 10 fps H.264 too?) But all in all the main problem seems to be squeezing an entire video stream through a single TCP connection. There are plenty of existing solutions for this. For example, this article never mentions DASH, which is made for these exact purposes.
- mschuster91 9mo ago> For example, this article never mentions DASH, which is made for these exact purposes. DASH isn't supported on Apple AFAIK. HLS would be an idea, yes... But in either case: you need ffmpeg somewhere in your pipeline for that experience to be even remotely enjoyable. No ffmpeg? No luck, good luck implementing all of that shit yourself.
- rezonant 9mo agoOr Gstreamer, which the article says they were using. > DASH isn't supported on Apple AFAIK. HLS would be an idea, yes... They said they implemented a WebCodecs websocket custom implementation, surely they can use Dash.js here. Or rather, their LLM can since it's doubtful they are writing any actual code. They would need to use LL-DASH or HLS low latency but it's quite achievable.
- deleted 9mo ago
- mschuster91 9mo ago> We are professionals. We implement proper video codecs. We don’t spam HTTP requests for individual frames like it’s 2009. I distinctly 'member doing CGI stuff with HTTP multipart responses... although I bet that with the exception of Apache, server (and especially: reverse proxy) side support for that has gone down the drain.
- throwaway173738 9mo agoThis article reminds me so much of so many hardware providers I deal with at work who want to put equipment on-site and then spend the next year not understanding that our customers manage their own firewall. No, you can’t just add a new protocol or completely change where your stuff is deployed because then our support team has to contact hundreds of customers about thousands of sites.
- tylertyler 9mo agoI've found that WebM works much better because of the structure of the data in the container. I've also gone down similar routes using outdated tech and even inventing my own encoder and decoders trying to smooth things out but what I've currently found is the best current approach is using WebM because it is easier to lean on hardware encoder and decoders including across browsers with the new WebCodecs APIs. What I've been working on is a little different than what is in this post but but I'm pretty sure this logic still stands.
- nemothekid 9mo agoI'm very familiar with the stack and the pain of trying to livestream video to a browser. If JPEG screenshots work for your clients, then I would just stick with that. The problem with wolf, gstreamer, moonlight, $third party, is you need to be familiar with how the underlying stack handles backpressure and error propagation, or else things will just "not work" and you will have no idea why. I've worked on 3 projects in the last 3 years where I started with gstreamer, got up and running - and while things worked in the happy path, the unhappy path was incredibly brittle and painful to debug. All 3 times I opted to just use the lower level libraries myself. Given all of OPs requirements, I think something like NVIDIA Video Codec SDK to a websocket to MediaSource Extensions. However, given that even this post seems to be LLM generated, I don't think the author would care to learn about the actual internals. I don't think this is a solution that could be vibe coded.
- colechristensen 9mo agoThis is where LLMs shine, where you need to dip your toes into really complex systems but basically just to do one thing with pretty straightforward requirements.
- stefan_ 9mo agoThe peak of irony, because you know how these people arrived at their 40 Mbit bitrate H264 and their ineffective tinkering with the same in the first place is guaranteed to be some LLMs expert suggestions. As is often the case, because they had no understanding of the really complex system subject matter whatsoever, they were unable to guide the LLM and ended up with .. slop. Which then turned into a slop blog post. God knows what process led them to do video streaming for showing their AI agent work in the first place. Some fool must have put "I want to see video of the agent working" in.. and well, the LLM obliged!
- antisol 9mo ago> God knows what process led them to do video streaming for showing their AI agent work in the first place. This was my first thought, too.
- colechristensen 9mo agoH.264 can be used to encode a single frame as an effective image with better compression than JPEG.
- somehnguy 9mo ago40mbps for video of an LLM typing text didn't immediately fire off alarm bells in anyone's head that their approach was horribly wrong? That's an insane amount of bandwidth for what they're trying to do.
- giantrobot 9mo agoAnd they for some reason need a 60fps stream to...watch a computer type. No one stopped for a second and asked "maybe we don't know anything about the problem domain". They seem to have given a vague description to an LLM and assumed it knew what it was talking about.
- lomase 9mo agoThat is where LLM shine. It lets you know who is a fraud. 40mbps to stream a terminal? Are you kidding me?
- throw-12-16 9mo agoIf all you know is vibe coding and the llm didn’t tell you 40mbs is too much how would you know?
- somehnguy 9mo agoI'm afraid to see just how poorly we can utilize computing resources in the future due to cluelessness.
- bandamo 9mo agowould like to see what alternatives were looked at. RDP with a html client (guacamole) seams like a good match
- nrhrjrjrjtntbt 9mo agoThats fun. I take it JPEG (what settings lolz!) is compressing harder than a keyframe. But you are waching code. Why not send the code? Plus any css/html used to render it pretty. Or in other words why not a vscode tunnel?
- rekshaw 9mo agoI remember 12 years ago, while the Flash vs Html war was still raging on (pre-html5), I created a framework to create web video playback using CSS and JPEGs. It would expect a set of big JPEGs, each containing the frames of the video in a grid (a "reel"), and play it by changing the css background position (and swap out the background with the next jpeg once a "reel" was complete). It worked really well, and I also cloned the (at the time) Youtube player UI. Seeking, keyframes, flexible framerate, etc were all supported out of the box thanks to the simple underlying architecture. https://github.com/VAS/animite https://github.com/VAS/animite
- kalleboo 9mo agoI built a similar solution around the same time for semi-transparent PNG sprite animations. I remember the biggest issue was working around the GPU texture limitations on the early iPads which were exposed by mobile Safari.
- imiric 9mo ago> By the time you see a bug, the AI has already committed it to main If you have given your "AI" full control over your repo so that it can commit unreviewed code to the main branch, you have far greater problems than a 45 second video stream delay. Besides, you'd need superhuman abilities to spot a bug in hundreds of lines of generated code in under 45 seconds. I know this example is rhetorical and likely produced by an LLM, but this entire project seems misguided. They're streaming video of a graphical text editor to a web browser client, instead of streaming text itself, or using a web-based editor. These are solved problems. This shouldn't be so complicated...
- Anamon 9mo agoYeah, that was my main head-shaking moment in that entire piece as well. Tell me again about these grandiose efficiency gains from agentic coding assistants, which I'm apparently supposed to supervise in real time as they produce shittier code than I would've. And about what an excellent idea it is to have software developed this way by people who don't understand why an automated system being able to commit to a main branch might be problematic.
- rezonant 9mo agoI guess their LLM doesn't have much training data on how to do video engineering. The result? A "video" stack that looks like a junior engineer wrote it.
- toledocavani 9mo agoThis thread is great, truly the only way to get great answers on the HN is to post a wrong blog. But stupid wrong blogs are unlikely to get into HN front page, kudos for the writer for striking the right balance between easy to understand, working, interesting but faulty solution.
- kiririn7 9mo agoso true
- almog 9mo agoPosts like this on the front page make me miss N-Gate so bad...
- develatio 9mo agoI cried. Then I laughed. Then I cried again. I can feel all the pain of the entire thing (don't ask me why). Amazing. Bravo!!
- dicroce 9mo agoThey should have used HLS. Its still pulling, and the client controls the downshifts if required...
- didibus 9mo agoWhat I'm wondering is, why couldn't the AI generate this solution? And implement it all? Why did they need to spend human time and effort to experiment, arrive at this solution and implement it? I'm asking genuinely. I use GenAI a lot, every day, multiple times a day. It helps me write emails, documents, produce code, make configuration changes, create diagrams, research topics, etc. Still, it's all assisted, I never use its output as is, the asks from me to the AI are small, so small, I wouldn't ever assign someone else a task this small. We're not talking 1 story point, we're talking 0.1 story point. And even with those, I have to review, re-prompt, dissect, and often manually fix up or complete the work. Are there use-cases where this isn't true that I'm simply not tackling? Are there context engineering techniques that I simply fail to grasp? Are there agentic workflows that I don't have the patience to try? How then, do models score so high on some of those tests, are the prompts to each question they solve hand crafted, rewritten multiple times until they find a prompt that one-shot the problem? Do they not consider all that human babysitting work as the model not truly solving the problem? Do they run the models with a GPU budget 100x that they sell us?
- akersten 9mo ago> What I'm wondering is, why couldn't the AI generate this solution? And implement it all? My read of the blog post is that is exactly what happened, and the human time was mostly spent being confused why 40MB/s streams don't work well at a coffee shop.
- saagarjha 9mo agoI’m currently doing this in one of my side projects: https://github.com/saagarjha/Ensemble https://github.com/saagarjha/Ensemble. It works, kinda; it’s good enough for demos at least and I haven’t had much time to improve it. At some point you would really want to use an actual video encoder though because JPEGs are not cheap to encode and send even with hardware acceleration.
- inDigiNeous 9mo agoThat was a fun read. Kudos to the writer. This is software development life.
- dehrmann 9mo ago> What if we only send keyframes? I think the author reached this conclusion, but individual jpegs is essentially only keyframes. > We don’t spam HTTP requests for individual frames like it’s 2009. Uncompressed frames are huge, somewhere between 5 MB and 50 MB. The overhead of a request is negligible. It's also different when you're optimizing for latency and reliability where dropped frames is OK. Really, the lesson is they should have tried the easy thing first to see how good it was.
- plqbfbv 9mo agoI dabbled a bit with recoding/encoding videos in the past: 40mbps is basically blu-ray quality (1080p/4k depending on content), and it's being used to stream a mostly-static background with some text scrolling in front of it. A 3-minute chat with Claude suggests 30FPS should be plenty (perhaps minor cursor lag can be noticed if it's drawn), with a GOP of 2s (60 frames) for fast recovery, VBR 1mbps average with a max bitrate at 1.2mbps for crappy connections, and bframes to minimize bandwidth usage (because we have hw encoding). The crappiest of internet cafes should still be able to guarantee 1.2mbps (150kb/s). If they can do 5-10FPS with 150kb frames, they have 6-12mbps available. Worst case GOP can be reduced to 15 frames, so that there's 2x I-frames every second, and the latency is 500ms tops.
- dehrmann 9mo ago> We’re building Helix, an AI platform where autonomous coding agents work in cloud sandboxes. Users need to watch their AI assistants work. Think “screen share, but the thing being shared is a robot writing code.” This feels like a fast dead end. Agents will get much faster pretty quickly, so synchronous human supervision isn't going to scale. I'd focus on systems that make high-signal asks of humans asynchronously.
- socketcluster 9mo agoNext phase would be to do diffs between the JPEGs and if the diff is smaller than the next JPEG, only send the (gzipped) diff and reconstruct the next JPEG on the client side. TBH, the obsession with standards is kind of nutty. It's not that hard to implement custom solutions that are better adapted to specific problems. Standards make sense when you want maximum interoperability but not everything requires this degree of interoperability these days. It's not such hassle to just provide a lightweight client in those cases. For example, it's not ideal to use HTTP2 server push for realtime chat use cases. It was primarily intended for file push to avoid round-trip latency but HTTP is such a powerful and widespread protocol that people feel the need to use it for everything.
- boggyb 9mo agoYou can make webrtc work on enterprise networks by tunneling turn tcp traffic over websocket. The flow looks like this. client's webrtc app using turn (pointing to the same machine IP) <-> tcp server/ websocket client (runs on client machine) <-> websocket server (relays turn packets) <-> real turn server <-> host's webrtc app https://github.com/amitv87/turn_ws_proxy https://github.com/amitv87/turn_ws_proxy I implemented a similar technique for Browserstack more than a decade ago to bypass enterprise firewalls by tunneling turn packets over (websockets/sse/socket.io etc.) The `tcp server/ websocket/sse/scoket.io client` was hosted as part of a packaged chrome app / firefox extension. WebSocket and TURN servers were hosted on same machine to minimize the latency (could have been embedded in same process to reduce latency further).
- notpushkin 9mo agoConsidering you already have a WebSocket open, why not just send JPEGs over it?
- lewq 9mo agoHi, author of the post here. Just fixed up some formatting issues from when we copied it into substack, sorry about that. Yeah, I used Opus 4.5 to help me write it (and it actually made me laugh!). But the struggle was real. Something I didn't make clear enough in the post is that jpeg works because each screenshot is taken exactly when it's requested. Whereas streaming video is pushing a certain frame rate. The client driving the frame rate is exactly what makes it not queue frames. Yes, I wish we could UDP in enterprise networks too, but we can't. The problem actually isn't opening the UDP port, it's hosting UDP on their Kubernetes cluster. "You want to what?? We have ingress. For HTTPS" Join our discord for private beta in January! https://discord.gg/VJftd844GE https://discord.gg/VJftd844GE (This post written by human)
- Dylan16807 9mo ago> Something I didn't make clear enough in the post is that jpeg works because each screenshot is taken exactly when it's requested. Whereas streaming video is pushing a certain frame rate. The client driving the frame rate is exactly what makes it not queue frames. I understand that logic but I don't really agree with it. Very aggressive bitrate controls can do a lot to keep that buffer tiny while still looking better than JPEG, and if it bloats beyond 1-2 seconds you can reset. A reset like that wouldn't look notably worse than JPEG mode always looks. If you use a video encoder that gives you good insight into what it's doing you could guarantee that the buffer never gets bigger than 1-2 JPEGs by dynamically deciding when to add frames. That would give you the huge benefits of P-frames with no downside.
- kixelated 9mo agoHey lewq, 40Mbps is an absolutely ridiculous bitrate. For context, Twitch maxes out around 8.5Mb/s for 1440p60. Your encoder was poorly configured, that's it. Also, it sounds like your mostly static content would greatly benefit from VBR; you could get the bitrate down to 1Mb/s or something for screen sharing. And yeah, the usual approach is to adapt your bitrate to network conditions, but it's also common to modify the frame rate. There's actually no requirement for a fixed frame rate with video codecs. It also you could do the same "encode on demand" approach with a codec like H.264, provided you're okay with it being low FPS on high RTT connections (poor Australians). Overall, using keyframes only is a very bad idea. It's how the low quality animated GIFs used to work before they were secretly replaced with video files. Video codecs are extremely efficient because of delta encoding. But I totally agree with ditching WebRTC. WebSockets + WebCodecs is fine provided you have a plan for bufferbloat (ex. adaptive bitrate, ABR, GoP skipping).
- tcherasaro 9mo agoReminds me when I was working on the video system for a mast on a sub-marine 20 years ago. Customer had impossible set of latency, resolution, processing and storage requirements for their video. They also insisted we use this new H.264 standard that just came out though not a requirement. We quickly found MJPEG was superior for meeting their requirements in every way. It took a lot of convincing though. H.264 was and would still be a complete non-starter for them.
- Terretta 9mo agoHelix is a commercial multi-protocol streaming server: https://en.wikipedia.org/wiki/Helix_Universal_Server https://en.wikipedia.org/wiki/Helix_Universal_Server HTTP Live Streaming is already a thing: https://en.wikipedia.org/wiki/HTTP_Live_Streaming https://en.wikipedia.org/wiki/HTTP_Live_Streaming See also DASH, M-JPEG, progressive download, etc. > "Who knew?" Everyone in the streaming industry, and not so long ago that it's been forgotten.
- dinobones 9mo agoYou spent 3 months on this hacked together garbage when you probably could’ve just configured a pre-existing solution off the shelf with like 10 minutes of reading and understanding documentation. This blog post reeks of “you can just do things” type of engineering. This is the quality of engineering I would expect from “TPOT” (that part of Twitter) where people talk about working 12 hour days. It’s cause they’re working 12 hours on bullshit like this. Building some sweet custom codec or binary transportation algorithm was barely cute in like 1989. It definitely ain’t cute now. How many of these AI and “agentic” companies are just misled engineers thinking they are cracked and writing needlessly complex solutions to problems that dont even exist? Just burn it all down. Let it pop already.
- krater23 9mo agoThanks! Exactly what I think about their work and their idea to people watching AI agents to code.
- piyushpr134 9mo agohow about using mjpeg ?
- Animats 9mo agoThis is a screen-sharing system, correct? Sharing screens with text? JPEG compression of text is bad. JPEG is terrible at hard edges. PNG is fine with them, and good at uniform areas of color, like text.
- Dwedit 9mo ago"Helix" also happens to be the name of an open-source project created by RealPlayer.
- nicman23 9mo agoclose enough, welcome back mpeg
- josephernest 9mo agoRelated: for some hardware project, I have a backend server (either C++ or python) receiving frames from an industrial camera, uncompressed. And I need these frames displayed in a web browser client but on the same computer (instead of network trip like in this article). How would you do this ? I eventually did more or less like OP with uncompressed frames. My goal is to minimize CPU usage on the computer. Would h264 compression be a good thing here given source and destination are the same machine? Other ideas? NB: this camera cannot be directly accessed by the browser.
- antisol 9mo ago> How would you do this ? It depends. I have many questions. > My goal is to minimize CPU usage on the computer. Would h264 compression be a good thing here given source and destination are the same machine? No. > Other ideas? 1. Why does it need to be displayed in a web browser (as opposed to more appropriate / better performing software specifically built for video)? 2. via what interface/library is the camera connected to the machine? What format/codec is the uncompressed stream you're getting from the camera? 3. I am available at very reasonable consulting rates
- josephernest 9mo agoThanks. 1. It is part of a bigger web-browser dashboard/control interface and this camera display is just one component among many others. 2. Some of the (USB) cameras can have proprietary interfaces such as https://www.ximea.com/support/wiki/apis/python https://www.ximea.com/support/wiki/apis/python How would you do in this situation, to have the video stream in the browser, with as low CPU usage as possible? 3. Not for this project but for a future project, feel free to put a link to your portfolio or contact page (even if you remove the comment later)
- antisol 9mo ago1. fair enough 2. "How would you do in this situation, to have the video stream in the browser, with as low CPU usage as possible?" Since it's being consumed on (only) the local machine you've got an excellent situation where you can use any obscure codec you like, as long as the browser you're using supports it. Also you don't need to care at all about network bandwidth. If minimising CPU usage is the #1 priority then something fairly lightweight like mjpeg might do the trick. Alternatively you might get away with not compressing the video at all (but this might cause issues due to dealing with huge amounts of data). If I wanted to minimise CPU usage, I wouldn't be doing it in python. 3. You can find me if you look.
- CrossVR 9mo agoThis isn't a hack though, MJPEG (Motion JPEG) is an actual video format and has long been used for security camera footage.
- monus 9mo agoWell, we are serving latency sensitive remote control to <one of the biggest banks in US> via WebRTC which uses TLS over TURN so you get 443 HTTPS for the whole traffic. No NAT, no UDP, just pure TURN traffic over Cloudflare TURN with TLS.
- vincepaulushook 9mo agoHi, I would concur to some of the comments. A key frame in H264 is already encoded in a similar way as JPEG. Major differences are the "defaults": the flexibility of JPEG in terms of colors depth, color map, but that can be also addressed with a video codec, too. Then when using a video codec like H264, it will also contain differential frames which will only send differences. It depends on the content but these frames can be significantly smaller than a key frame, like 10x. So the math is that H264 can nearly only be better than JPEG, assuming proper parameters for the type of content, the targeted transmission challenges, the transmission type. Using JPEG is close to using only key frames from a compression stand point (not to say, it is exactly like that), which is close to older protocols like MPEG-1 (DVD), or close to intra-frames only codec (like used as intermediate formats, for editing or preservation). And the difference in size is a no-brainer, eventually this is the amount of data that needs to be sent to every user. In my opinion, the first consequence of using JPEG only is the cost per device, the number of concurrent streams from a server and what not. If the perception of quality is low with H264 compared to JPEG, some parameters need to be adjusted. And ultimately, H264 is already an old codec anyway, not the one I would recommend, newer ones can address visual perception and bandwidth in a much better way. the VP-8/9/AV1 family will reduce the "macro block" effect of the H.26x codecs. Using HDR will dramatically improve the quality and will crush any benefit from JPEG, benefits related to the number of bits per pixels and the poor 8bits color maps, with a much higher efficiency. Should the volume of users and the cost per user be of any consideration, a lossy video codec will prevail. Video projects are challenging in the details: wish you the best.
- bayindirh 9mo agoI love this: - It's 2025! We don't need to think like the savages of the yore. Use video at 60FPS. Computing is cheap, network is reliable. Why do we need to remember old ways like savages? it turns out that network is not reliable... - We will do as our ancestors did, and will send JPEGs, and that works?! Whoa, who guessed it! Come on. Everything is new but nothing has changed. Sometimes the older tech is vastly better, and saves our butts or lives or both. We shouldn't be ashamed of using things proven to work.
- zipy124 9mo agoThis is just poor engineering. H.264 streaming is obviously superior to JPEG streaming, else MJPEG (motion jpeg) would be standard for screen sharing. In addition if all you're sharing is a picture of text, and you have access to the text, you can just send the damn text instead and render it locally.
- abujazar 9mo agoThis reminds me of https://github.com/memvid/memvid https://github.com/memvid/memvid
- deleted 9mo ago[deleted]
- JohnCClarke 9mo ago+1 - I made the same technology choice back in 2014. Seems like nothing has changed. TL;DR: You can't keep things too simple.
- mxkyb 9mo agowhy not media over quic
- ErroneousBosh 9mo agoYou know what else I don't quite get? Why isn't "Your network is broken. Fix your network. Blocking UDP is idiotic. Get someone to set it up who has at least stood within hailing distance of a clue" an acceptable thing to say here?
- materialpoint 9mo agoThe fact that they considered transmitting only keyframes speaks volumes about how inept they are. It can be a cool baseline test, but celebrating trendy choices, like Rust, and not understanding that keyframes and efficient differentials are key to achieving high video compression makes me go completely numb.
- cwt137 9mo agoEveryone talks about Websockets for pushing real time data to the browser. This article highlights some of its drawbacks. I use Server Sent Events (SSE) instead. A lot of the problems the author of the article faced are solved with SSE. Also, SSE scales way better than polling all the time.
- kuon 9mo agoWait what? 40Mbps for a remote desktop? Event 10Mbps is insane. I remember deploying sunrays over dialup and the image wasn't that bad, yes it was low resolution and I think it was UDP, but the desktop was usable with a surprisingly low latency. To monitor an IA you can lower the bit depth considerably and not lose that much details on what is happening. If you control the web rendered, disable text anti aliasing, and there might be other optimization that can help. Tile & diff the image... But video encoders already does that so it might just work out of the box. Also if your single h264 image is larger that jpeg then you are doing something wrong, jpeg is a very poor encoding compared to what we have today. Look at how other remote desktop protocol does it, VNC, RDP... Managing streams over corporate network is well documented, many web frameworks will include a "longpoll" fallback (or SSE) for streaming to play nice even without web sockets. "Discovering" you cannot deploy whatever you want to an enterprise network is quite alarming. I really don't want to be the graybeard guy saying "young engineers are bad", as I am more on the side of believing on the new generations, but please, don't act like computers spawned into existence in 2020 and that nothing has been done before.
- throw-12-16 9mo agoI’ll say it. Young engineers are bad.
- bArray 9mo agoI've literally been here (many) years ago whilst trying to stream video from a potato Linux SBC via WiFi. As you walked further away, the H264 stream would just die and hang, no matter what you did. Stream JPEGs? Worked excellently and adjusted the number of JPEGs per second depending on connection (only requested the next frame after the current one arrived or a timeout occurred). This got me thinking about video calls, which have be notoriously bad on bad connections. Half the time I am just streaming a screen with static information on it, we're not watching videos together. And yet the streaming pipeline is optimised as this article suggests for the higher bandwidth modes - when we're never really using it at all. The most important part about a video call is rarely the video, is usually the audio. It's counter-intuitive but you are better off having your call without video than you are without sound, and yet when the video falls over it takes the audio with it. Insanity!
- kiririn7 9mo ago"By the time you see a bug, the AI has already committed it to main" does anybody actually actively watch the code their agent is writing? i am watching movie recaps on my 2nd monitor. this seems like a problem that they assume exists because they dont actually use their product
- krater23 9mo ago"By the time you see a bug, the AI has already committed it to main" Beside of that the Author has no plan at all about encoding, mjpeg, vnc,.... Really, THIS is the product that they sell?! This sounds like a horrible work. Observing a coding agent that does my job, but faster and crappier than me and stopping it when it does totally bullshit to prevent it from commiting to main?
- rasz 9mo agoI can totally see some middle managers swallowing "You get used to it, I don't even see the code, All I see is blond, brunette, redhead" sales pitch.
- liampulles 9mo agoI appreciate the honesty in this article, hacking a solution together that works is ultimately what counts. Having said that, why H264? If I understand correctly, the clients of the video stream are web browsers and perhaps mobile devices, and the servers are Helix's. Would SVT-AV1 with low-latency mode not be an option?
- xnx 9mo agoYou see a company that is bad at video streaming. I see a smart application of Cunningham's Law https://meta.wikimedia.org/wiki/Cunningham%27s_Law https://meta.wikimedia.org/wiki/Cunningham%27s_Law
- yanngagnon 9mo agoIf you don't need sound, or don't need to present the sound to the user in sync with the content, the still image solution is obvious.
- tracker1 9mo agoMy only real curiosity is if .png or .webp are supported and how much slower and/or faster they are in practice over jpeg given the quality level needed to not artifact.