Home > PHP Framework > Swoole > body text

How swoole implements live broadcast

藏色散人
Release: 2020-04-10 10:04:44
Original
5428 people have browsed it

How swoole implements live broadcast

swooleHow to implement live broadcast?

The specific steps for swoole to do live broadcast: (laptop with camera)

1. Swoole creates 2 monitors and a WebSocket monitoring service (for video streaming). A local [Unix Socket file descriptor] (used for accepting and forwarding the video stream transcoded by ffmpeg to the WebSocket client.)

2. The browser uses the jsmpeg project to connect to the WebSocket service provided by Swoole to obtain Video streaming.

3. Use ffmpeg to transcode the live video stream into mpeg video stream format and send it to the local Swoole listening [Unix Socket] file descriptor, such as: $serv->addlistener("/var/run/ myserv.sock", 0, SWOOLE_UNIX_STREAM); File descriptor: /var/run/myserv.sock

4. The onReceive event of the file descriptor monitored by Swoole will receive the ffmpeg transcoded video stream. Send the video stream to the client connected to the WebSocket service through Swoole's WebSocket method push.

The above is the detailed content of How swoole implements live broadcast. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!