Home  >  Article  >  PHP Framework  >  How swoole implements live broadcast

How swoole implements live broadcast

藏色散人
藏色散人Original
2020-04-10 10:04:445322browse

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!

Statement:
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