In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to play video streams with OBS and WebSockets". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to play video streams with OBS and WebSockets".
OBS is one of the mainstream of live video broadcasting nowadays. It is the software of choice for live streaming to Twitch, and Twitch is one of the most popular live video sites these days. There are some very good add-ons that allow streaming people to control from their mobile phone or another screen without affecting the running video. It turns out that using Node-RED and obs-websockets plug-ins to build your own control panel is really easy.
My OBS control dashboard
I know what many of you are thinking-"he mentioned WebSockets and simplicity in the same sentence?" Many people have difficulty setting up and using WebSockets, and WebSockets allows two-way communication over a single connection to the Web server. Node-RED 's built-in support for WebSockets is one of the things that makes this easy, at least compared to writing your own client / server.
Before you begin, make sure that you have installed and configured OBS. First download and install the latest stable version of the obs-websockets plug-in. For this article, the default setting is fine, but I strongly recommend that you follow the instructions later to secure obs-websockets.
Next, download and install Node-RED, either on the same system or on different systems (such as raspberry pie). Again, the default installation is sufficient for our article, but it is best to follow the instructions on their website for a secure installation.
Now is the interesting part. Launch Node-RED, open the web interface (default in http://localhost:1880), and you have a blank canvas. Open the "hamburger" menu on the right and choose "manage flavors Manage Palate". Then click the "install" tab to search for node-red-contrib-dashboard and node-red-contrib-rbe modules.
After installing these modules, click the list on the right and drag the following modules onto the canvas.
1 Websocket Out
1 Websocket In
1 Debug
1 Inject
1 Switch
1 Change
2 JSON
1 Catch
Connect them in the following order:
Inject- > Button- > Change- > JSON- > Websocket Out Websocket In- > JSON- > Switch- > RBE- > Debug Catch- > Debug
Basic process
When "Button" is pressed (or the "Inject" node sends a timestamp), the payload is sent through the "change" node, converted from the JSON object to a string, and then sent to the "WebSocket Out" node. When the "WebSocket In" node receives the message, it converts it into a JSON object, and if it is not duplicated, it is sent to the "Debug" node for output. The "Catch" node catches any errors and places them in the "Debug" panel.
What's in the payload? Let's set everything up and find out.
First, double-click "Button" to open the settings dialog box. First use the drop-down menu to change the payload to "JSON". In this field, add the following:
{"request-type": "GetVersion"}
Enable the "If msg arrives on input, emulate a button click" check box, and then click "Done" to close the "Button" configuration. When a message comes from the "Inject" node, or the "Button" in the UI is pressed, it sends the JSON payload to the next node.
Set "Button"
Now open the "Change" node. We want to set msg.payload.message-id to msg._msgid by changing the first field from payload to payload.message-id, then using the drop-down menu of the second field to change the type from String to msg., and then we put _ msgid into that field. This copies the unique message ID to the payload of the JSON object so that each request has a unique ID to track.
It is then sent to the "JSON" node so that the JSON object is converted to a string and then passed to the "Websocket Out" node. Open the "Websocket Out" node and configure the connection to OBS. First, change Type to Connect to, and then click the pencil icon to create a new connection URL. Set it to ws://OBSMachine:4444/, and close the dialog box to save. OBSMachine is the name of the machine on which OBS and obs-websocket are running. For example, ws://localhost:4444 if Node-RED is running on the same machine, or ws://luxuria.local:4444 if it is on a machine named luxuria.local. Close and update the Websocket Out node. This sends a payload text string to WebSocket in OBS.
"Websocket Out" node configuration
Enter the WebSocket In process! Open the "WebSocket In" node and set the Type to Connect to and the URL of the connection we defined earlier (which should be automatically populated). Next comes the second "JSON" node, which we can ignore. It accepts the output of OBS and converts it into a payload object.
Next, we will filter out regular heartbeats and status updates. Open "Switch" and set the Property value to payload ["update-type"]. Now select Is Not Null from the drop-down menu below it. Click + to add a second option and select otherwise from the drop-down menu.
"Switch" node configuration
Connect the new output on "Switch" directly to the input of "Debug" node.
The RBE node will filter out the duplicates and need to tell it what fields to observe. This is important because it should connect to the output of "Switch" and it only sends status updates, because obs-websocket sends updates every few seconds. By default, RBE compares the entire payload object, which is constantly changing. Open the RBE node and change Property from payload to payload.streaming. If the streaming value of the payload changes, the message is passed, otherwise it is discarded.
The final step is to change the output of the "Debug" node from msg.payload to the full msg object. This allows us to see the entire object, and sometimes useful information outside of payload.
Now, click Deploy to activate the change. Hopefully, there will be a green Connected message under the WebSocket node. If they are red or yellow, the connection URL may be incorrect, need to be updated, or the connection may be blocked. Make sure that port 4444 on the remote machine is open, available, and that OBS is running!
Without the RBE node's filtering of streaming values, the debug panel (click the "bug" icon on the right side of the canvas) will now be filled with heartbeat messages. Click the button to the left of the "Inject" node to send a signal that the analog button is clicked. If all goes well, you should see an object arrive with a list of all the things obs-websocket can do.
Response to "GetVersion"
Now open http://localhost:1880/ui in another tab or window. It should display a single button. Press it! The debug panel should display the same information as before.
Congratulations! You have sent your first (and hopefully not the last) WebSocket message!
This is just the beginning of what you can do with obs-websockets and Node-RED. The complete documentation supported is recorded in the protocol.md file in obs-websockets 's GitHub repository. With a little experiment, you can create a full-featured control panel to start and stop streaming, change scenes, and more. If you are like me, you can set up various controls before you realize it.
The above is all the content of the article "how to play a video stream with OBS and WebSockets". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.