-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow pushing stream data into JSMpeg #338
Comments
You can create a new I.e. something like this should work (untested): var SocketSource = function(url, options) {
this.streaming = true;
this.established = false;
this.completed = false;
this.progress = 0;
options.socket.on('video', this.onMessage.bind(this));
};
SocketSource.prototype.connect = function(destination) {
this.destination = destination;
};
SocketSource.prototype.onMessage = function(data) {
// Pass the data to the destination - i.e. JSMpeg's demuxer.
this.destination.write(data);
};
// Create the player instance with your SocketSource class. The options
// object gets passed through to your constructor
var player = new JSMpeg.Player("url-ignored", {
source: SocketSource,
socket: yourSocketInstance
}); |
Hi @phoboslab ! Thanks, that's looks very promising! I am not that familiar with the WebSocket API. I will try to adapt your solution into my project! If it works, you are a genius 😂 |
How about for this setup:
So not really MPEG-TS streaming as per spec but emitting 1 sec MPEG-1 encoded audio+video and transmitting over websocket how would jsmpeg handle such? |
Hey @phoboslab I have adapted the method you suggested and it works. The only thing I was stuck on, I had to set I am however still having a few new minor issues. For example strangely I have to force disable webGL with |
I am trying to work this library into one of my project and at the moment, I have once singular issue making it coexist with my current setup. I am already using websockets for sending data back and fourth between the client and server.
My setup:
The messages are in JSON and contain a channel field which I use to route them in the receive-event-listener to their corresponding sections of the application - chat, telemetry, control data etc...
I was thinking of creating a new channel for the video data, which I would push then push into the JSMpeg library somehow in order to display it.
However I can not find any way to achieve this. I can only provide a URL to my server which would however also push all the other messages to the JSMpeg.
Basically I am looking into some way to support channels, or pubsub broker. I have a my custom one, but there are multiple approaches out there: https://socket.io/ https://github.com/O3Labs/neo-ws-pub-sub... In order to use any of these methods, there has to be some way to 'push' data into the JSMpeg library.
I envision something along the lines of a
player.pushData(data);
method which can be called from anywhere like this:Or when using something like socket.io:
I have looked at the #194 issue, and it looks like it might be related. However still not resolved.
I hope you can provide some advise and help. Thanks
The text was updated successfully, but these errors were encountered: