CN112437319A - Method for switching multiple video streams based on webrtc - Google Patents
Method for switching multiple video streams based on webrtc Download PDFInfo
- Publication number
- CN112437319A CN112437319A CN202011244672.9A CN202011244672A CN112437319A CN 112437319 A CN112437319 A CN 112437319A CN 202011244672 A CN202011244672 A CN 202011244672A CN 112437319 A CN112437319 A CN 112437319A
- Authority
- CN
- China
- Prior art keywords
- video stream
- webpage
- server
- video
- packet loss
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/21—Server components or server architectures
- H04N21/218—Source of audio or video content, e.g. local disk arrays
- H04N21/2187—Live feed
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/239—Interfacing the upstream path of the transmission network, e.g. prioritizing client content requests
- H04N21/2393—Interfacing the upstream path of the transmission network, e.g. prioritizing client content requests involving handling client requests
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/60—Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client
- H04N21/63—Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
- H04N21/647—Control signaling between network components and server or clients; Network processes for video distribution between server and clients, e.g. controlling the quality of the video stream, by dropping packets, protecting content from unauthorised alteration within the network, monitoring of network load, bridging between two different networks, e.g. between IP and wireless
- H04N21/64784—Data processing by the network
- H04N21/64792—Controlling the complexity of the content stream, e.g. by dropping packets
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/60—Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client
- H04N21/65—Transmission of management data between client and server
- H04N21/658—Transmission by the client directed to the server
Abstract
The invention discloses a webrtc-based method for switching multiple video streams, wherein a server encodes the same video into versions with 4 different GOP values, and divides the video streams with different versions into a video stream 1, a video stream 2, a video stream 3 and a video stream 4 according to the GOP values from large to small; when the webpage side requests the video stream for the first time, the server side sends the video stream 4 to the webpage side and then waits for the request of the client side; when the webpage end receives a first video stream data packet, the packet loss rate is calculated, the webpage end sends the packet loss rate to the server end through the webrtc, and the server end adjusts the video stream sent to the webpage end according to the packet loss rate after receiving the packet loss rate sent by the webpage end. The method and the device can control the GOP value of the video stream received by the webpage end in real time according to the specific network condition so as to adjust the video stream sent by the server end to the webpage end, and avoid video blockage or black screen caused by network condition change.
Description
Technical Field
The invention relates to the field of network communication, in particular to a method for switching multiple video streams based on webrtc.
Background
With the development of internet technology, the application of video live broadcast technology in production and life is more and more extensive, such as video monitoring, video conference, and video live broadcast. When different users watch a live video at the same time, the network conditions of each user are different, and the network conditions of the same user fluctuate. At this time, if the video streams sent to each user by the server are the same, different user experiences are different, the video definition is high, the video seen by the user with poor network is blocked, the video is blacked, the video definition is low, and the user with good network can feel that the video is not clear enough. Users of different network states should be provided with different definition video.
Disclosure of Invention
In order to solve the technical problems and realize the automatic switching of the definition of the webpage video stream, the invention provides the following technical scheme:
a method for switching multiple video streams based on webrtc comprises the following steps:
s1, the server side encodes the same video into versions with 4 different GOP values, the I frame time interval of the video stream is ensured to be 0.25 second, 0.5 second, 1 second and 2 seconds, and the calculation mode of the GOP values is the video frame rate I frame time interval; dividing video streams of different versions into a video stream 1, a video stream 2, a video stream 3 and a video stream 4 from large to small according to GOP values; the server cannot directly know the network condition between the server and the webpage, so that the webpage requests the server for the matched GOP value video stream through webrtc; when the webpage side requests the video stream for the first time, the server side sends the video stream 4 to the webpage side and then waits for the request of the client side;
s2, when the webpage end receives the first video stream data packet, recording the sequence number a, and starting to count the number of the received video stream data packets; recording the sequence number b of the current video stream after 1 second, wherein the total number of the received video stream data packets is n; because the sequence number of the video stream data packets sent by the server is continuously increased, the number of the video stream data packets sent by the server in 1 second is b-a +1 which is equal to N, the number of the packets lost in the transmission process is m which is equal to N-N, and the packet loss rate is m/N;
s3, the webpage side sends the packet loss rate to the server side through webrtc;
s4, after receiving the packet loss rate sent by the webpage end, the server end adjusts the video stream sent to the webpage end according to the packet loss rate; if the packet loss ratio is 2%, video stream 1 is transmitted, if 2% < packet loss ratio is 5%, video stream 2 is transmitted, if 5% < packet loss ratio is 10%, video stream 3 is transmitted, and if 10% < packet loss ratio, video stream 4 is transmitted.
The invention has the beneficial effects that: the GOP value of the video stream received by the webpage end can be controlled in real time according to the specific network condition, so that the video stream sent to the webpage end by the server end is adjusted, and video blocking or black screen caused by network condition change is avoided.
Detailed Description
The following examples are illustrative and are not to be construed as limiting the invention.
In a video coding sequence, a GOP, i.e. a Group of pictures, refers to the distance between two I-frames. In a video coding sequence, there are mainly three types of coded frames: i frame, P frame, B frame. I-frame, i.e. Intra-coded picture frame, does not refer to other image frames, and only uses the information of the frame to perform coding; a P frame (Predictive-coded image frame) is used for inter-frame Predictive coding by adopting a motion prediction mode by utilizing the previous I frame or P frame; the B frame, i.e. bidirectional predictive coded picture, provides the highest compression ratio, and requires both the previous image frame (I frame or P frame) and the subsequent image frame (P frame), and performs inter-frame bidirectional predictive coding by using motion prediction. The byte number occupied by one I frame is larger than that of one P frame, and the byte number occupied by one P frame is larger than that of one B frame, so that on the premise of unchanged code rate, the GOP value is larger, the number of P, B frames is larger, and the byte number occupied by each I, P, B frame is larger on average, so that better image quality is easier to obtain.
Generally, video stream data is sent by means of UDP, which may cause packet loss, especially, a network is not good, if an I frame is lost, subsequent P frames and B frames cannot be analyzed, and if a GOP value is 1 second, the network page end within the 1 second may be stuck or blank. Therefore, for different network conditions, the server needs to provide video streams with different GOP value versions for the same video; if the network condition between a certain webpage end and a server end is good and the problem of packet loss hardly occurs, the GOP value of the video stream sent to the webpage end by the server end can be larger to ensure the definition of the video; if the network condition between a certain webpage end and the server end is not good, the GOP value of the video stream sent by the server end to the webpage end can be a little smaller, so that the video definition is reduced, but the long-time blocking or black screen can be avoided.
Webrtc is an API that supports web browsers for real-time voice conversations or video conversations. Webrtc enables a Web developer to easily and quickly develop rich real-time multimedia applications based on a browser without downloading and installing any plug-in, and the Web developer does not need to pay attention to the digital signal processing process of multimedia and can realize the real-time multimedia applications only by writing a simple Javascript program.
A method for switching multiple video streams based on webrtc comprises the following steps:
s1, the server side encodes the same video into versions with 4 different GOP values, the I frame time interval of the video stream is ensured to be 0.25 second, 0.5 second, 1 second and 2 seconds, and the calculation mode of the GOP values is the video frame rate I frame time interval; dividing video streams of different versions into a video stream 1, a video stream 2, a video stream 3 and a video stream 4 from large to small according to GOP values; the server cannot directly know the network condition between the server and the webpage, so that the webpage requests the server for the matched GOP value video stream through webrtc; when the webpage side requests the video stream for the first time, the server side sends the video stream 4 to the webpage side and then waits for the request of the client side;
s2, when the webpage end receives the first video stream data packet, recording the sequence number a, and starting to count the number of the received video stream data packets; recording the sequence number b of the current video stream after 1 second, wherein the total number of the received video stream data packets is n; because the sequence number of the video stream data packets sent by the server is continuously increased, the number of the video stream data packets sent by the server in 1 second is b-a +1 which is equal to N, the number of the packets lost in the transmission process is m which is equal to N-N, and the packet loss rate is m/N;
s3, the webpage side sends the packet loss rate to the server side through webrtc;
s4, after receiving the packet loss rate sent by the webpage end, the server end adjusts the video stream sent to the webpage end according to the packet loss rate; if the packet loss ratio is 2%, video stream 1 is transmitted, if 2% < packet loss ratio is 5%, video stream 2 is transmitted, if 5% < packet loss ratio is 10%, video stream 3 is transmitted, and if 10% < packet loss ratio, video stream 4 is transmitted.
Claims (1)
1. A method for switching multiple video streams based on webrtc, comprising the steps of:
s1, the server side encodes the same video into versions with 4 different GOP values, the I frame time interval of the video stream is ensured to be 0.25 second, 0.5 second, 1 second and 2 seconds, and the calculation mode of the GOP values is the video frame rate I frame time interval; dividing video streams of different versions into a video stream 1, a video stream 2, a video stream 3 and a video stream 4 from large to small according to GOP values; the server cannot directly know the network condition between the server and the webpage, so that the webpage requests the server for the matched GOP value video stream through webrtc; when the webpage terminal requests the video stream for the first time, the server terminal sends the GOP value video stream 4 to the webpage terminal, and then waits for the request of the client terminal;
s2, when the webpage end receives the first video stream data packet, recording the sequence number a, and starting to count the number of the received video stream data packets; recording the sequence number b of the current video stream after 1 second, wherein the total number of the received video stream data packets is n; because the sequence number of the video stream data packets sent by the server is continuously increased, the number of the video stream data packets sent by the server in 1 second is b-a +1 which is equal to N, the number of the packets lost in the transmission process is m which is equal to N-N, and the packet loss rate is m/N;
s3, the webpage side sends the packet loss rate to the server side through webrtc;
s4, after receiving the packet loss rate sent by the webpage end, the server end adjusts the video stream sent to the webpage end according to the packet loss rate; if the packet loss ratio is 2%, video stream 1 is transmitted, if 2% < packet loss ratio is 5%, video stream 2 is transmitted, if 5% < packet loss ratio is 10%, video stream 3 is transmitted, and if 10% < packet loss ratio, video stream 4 is transmitted.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011244672.9A CN112437319A (en) | 2020-11-10 | 2020-11-10 | Method for switching multiple video streams based on webrtc |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011244672.9A CN112437319A (en) | 2020-11-10 | 2020-11-10 | Method for switching multiple video streams based on webrtc |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112437319A true CN112437319A (en) | 2021-03-02 |
Family
ID=74700727
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011244672.9A Pending CN112437319A (en) | 2020-11-10 | 2020-11-10 | Method for switching multiple video streams based on webrtc |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112437319A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115174942A (en) * | 2022-07-08 | 2022-10-11 | 叠境数字科技(上海)有限公司 | Free visual angle switching method and interactive free visual angle playing system |
CN116016458A (en) * | 2023-03-28 | 2023-04-25 | 四川蜀通信息科技有限公司 | Method and device for realizing audio and video interaction of webpage end based on webrtc |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104010232A (en) * | 2014-05-23 | 2014-08-27 | 惠州Tcl移动通信有限公司 | Method and system for intelligently playing online videos, player and mobile terminal |
CN104580985A (en) * | 2015-01-30 | 2015-04-29 | 深圳市云之讯网络技术有限公司 | Video bitrate self-adaption method and system |
CN105791260A (en) * | 2015-11-30 | 2016-07-20 | 武汉斗鱼网络科技有限公司 | Network self-adaptive stream media service quality control method and device |
US20180338166A1 (en) * | 2017-05-22 | 2018-11-22 | Symantec Corporation | Remotely validating a webpage video stream |
CN108966008A (en) * | 2018-08-02 | 2018-12-07 | 腾讯科技(深圳)有限公司 | Live video back method and device |
CN110290402A (en) * | 2019-07-31 | 2019-09-27 | 腾讯科技(深圳)有限公司 | A kind of video code rate method of adjustment, device, server and storage medium |
CN111669619A (en) * | 2020-06-04 | 2020-09-15 | 北京奇艺世纪科技有限公司 | Video stream data switching method, device, terminal and readable storage medium |
-
2020
- 2020-11-10 CN CN202011244672.9A patent/CN112437319A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104010232A (en) * | 2014-05-23 | 2014-08-27 | 惠州Tcl移动通信有限公司 | Method and system for intelligently playing online videos, player and mobile terminal |
CN104580985A (en) * | 2015-01-30 | 2015-04-29 | 深圳市云之讯网络技术有限公司 | Video bitrate self-adaption method and system |
CN105791260A (en) * | 2015-11-30 | 2016-07-20 | 武汉斗鱼网络科技有限公司 | Network self-adaptive stream media service quality control method and device |
US20180338166A1 (en) * | 2017-05-22 | 2018-11-22 | Symantec Corporation | Remotely validating a webpage video stream |
CN108966008A (en) * | 2018-08-02 | 2018-12-07 | 腾讯科技(深圳)有限公司 | Live video back method and device |
CN110290402A (en) * | 2019-07-31 | 2019-09-27 | 腾讯科技(深圳)有限公司 | A kind of video code rate method of adjustment, device, server and storage medium |
CN111669619A (en) * | 2020-06-04 | 2020-09-15 | 北京奇艺世纪科技有限公司 | Video stream data switching method, device, terminal and readable storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115174942A (en) * | 2022-07-08 | 2022-10-11 | 叠境数字科技(上海)有限公司 | Free visual angle switching method and interactive free visual angle playing system |
CN116016458A (en) * | 2023-03-28 | 2023-04-25 | 四川蜀通信息科技有限公司 | Method and device for realizing audio and video interaction of webpage end based on webrtc |
CN116016458B (en) * | 2023-03-28 | 2023-06-23 | 四川蜀通信息科技有限公司 | Method and device for realizing audio and video interaction of webpage end based on webrtc |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3788260B2 (en) | Distribution system, distribution method thereof, and distribution program | |
US8711929B2 (en) | Network-based dynamic encoding | |
US7881335B2 (en) | Client-side bandwidth allocation for continuous and discrete media | |
JP5356652B2 (en) | Classified media experience quality | |
US10944973B2 (en) | Estimation of video quality of experience on media servers | |
US20080100694A1 (en) | Distributed caching for multimedia conference calls | |
US20140348224A1 (en) | Adaptive video processing of an interactive environment | |
KR101229370B1 (en) | Video data receiving and sending systems for videophone and video data processing method thereof | |
WO2010009637A1 (en) | Method, system and equipment for evaluating video quality | |
US10862940B1 (en) | Low latency live video on a communication session | |
CN111741248B (en) | Data transmission method, device, terminal equipment and storage medium | |
US20170142029A1 (en) | Method for data rate adaption in online media services, electronic device, and non-transitory computer-readable storage medium | |
CN112437319A (en) | Method for switching multiple video streams based on webrtc | |
CN111641804A (en) | Video data processing method and device, terminal, camera and video conference system | |
CN113676404A (en) | Data transmission method, device, apparatus, storage medium, and program | |
KR19980081099A (en) | Image transfer device and image transfer method | |
US20140321556A1 (en) | Reducing amount of data in video encoding | |
KR100792025B1 (en) | Method of transmitting video data in case of channel change in iptv system | |
WO2011029369A1 (en) | Video encoding and decoding method, system and video monitoring system | |
CN112929667B (en) | Encoding and decoding method, device, equipment and readable storage medium | |
CN112565670B (en) | Method for rapidly and smoothly drawing multi-layer video of cloud conference | |
CN105306970B (en) | A kind of control method and device of live streaming media transmission speed | |
CN113596112A (en) | Transmission method for video monitoring | |
CN114189742A (en) | System and method for adaptively projecting frame rate to computer terminal during mobile phone interconnection | |
CN114339445A (en) | Real-time video stream self-adaptive coordination system and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210302 |