3

I have a video stream using the UDP protocol, accessible through either rtp://ipadd:port or udp://@:port. I have absolutely no control over the server, so I can't change it to serve the stream over a WebSocket or transcode it to a compatible format on-the-fly.

I want to display the stream in an Electron app, however the sources I have found from a Google search all tell me that what I wish to accomplish requires me to put together an undesirably hacky solution using something like webchimera.js, for example.

I have tried dropping the URL in a <video> tag as per this answer, but Electron says that the udp and rtp URL schemes are not recognized. I have also tried require('child_process').exec with a static build of ffplay, which works, but it displays the stream on a whole separate window, which is not what I want. ActiveX, NPAPI, and other plugin solutions are not an option because Electron does not support them.

Am I out of luck, or is there a solution that I haven't come upon yet?

Community
  • 1
  • 1
dantis
  • 205
  • 2
  • 10

1 Answers1

5

Figured it out by looking at pages and pages of other people's code.

Apparently my initial understanding of WebSockets was incorrect - I would not need a server-side change to use WebSockets in my situation.

I had to transcode the stream into MPEG2 from within Electron using an ffmpeg Node.js wrapper, which sends the video to an Express server instance, which then serves the video within a static Web page rendered by jsmpeg. The static Web page is then displayed as an IFrame within the main Electron app page.

The resulting stream has considerably more visual artifacts than what one would see when playing the raw UDP stream with ffplay, and this approach probably introduces a lot of latency, but it works well enough for my needs.

dantis
  • 205
  • 2
  • 10
  • Hey, dantis, do you mind to share the code that you used to implement the solution? I'm working on an Electron app with these requirements. – Erik Martín Jordán Jan 11 '21 at 11:41
  • @ErikMartínJordán Hi Erik! I believe [this commit](https://github.com/jareddantis/shuttr/commit/69497713b8aed73d43d9beca6fb8a95e4e1f90fe) is what you want. I'm afraid I can't be of further help - it's been a while since I abandoned the project :( – dantis Jan 12 '21 at 15:39
  • Thanks, man! I’ll take a look. I’m struggling a lot with this problem. Cheers! – Erik Martín Jordán Jan 12 '21 at 16:32