Video stream processing method and device, storage medium, and electronic device
By receiving and parsing the video playback request of the terminal device, matching and pushing the appropriate video stream or transcoding, the problem in the existing technology of being unable to push the video stream according to the bandwidth and resolution of the terminal device is solved, and the user experience is improved.
Patent Information
- Application Number
- CN202210886340.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-07-26
AI Technical Summary
The existing technology cannot push appropriate video streams according to the bandwidth and resolution of the terminal device, resulting in delayed display or freezing problems.
By receiving the video playback request from the terminal device, parsing its screen resolution and network bandwidth, and matching the corresponding target service handle in the preset same-origin stream dictionary, obtain and push the target video stream. If no match is found, the video stream is Transcoded to match.
It realizes video stream push matching according to the screen resolution and network bandwidth of the terminal device, avoiding delayed display and freezing, and improving the user's viewing experience.
Smart Images

Figure CN115243074B
Abstract
Description
Background Art
[0002] In the existing methods, it is impossible to push the corresponding video stream to the terminal device according to the bandwidth and resolution of the terminal device itself.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the present disclosure is to provide a method for processing a video stream, a device for processing a video stream, a computer-readable storage medium, and an electronic device, thereby overcoming, at least to a certain extent, the problem of being unable to push a corresponding video stream to a terminal device according to the bandwidth and resolution of the terminal device itself due to the limitations and defects of the relevant technology.
[0005] According to one aspect of the present disclosure, a method for processing a video stream is provided, comprising:
[0006] Receiving a video playback request sent by a first terminal, and parsing the video playback request to obtain a screen resolution, a network bandwidth, and an identifier of a stream to be played of the first terminal;
[0007] Matching a source service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and matching a target service handle matching the screen resolution and / or network bandwidth in the source service handle;
[0008] Obtain a target video stream corresponding to the target service handle, and push the target video stream to the first terminal.
[0009] In an exemplary embodiment of the present disclosure, obtaining a target video stream corresponding to the target service handle includes:
[0010] If a target service handle matching the screen resolution and / or network bandwidth is matched in the source service handle, a target video stream corresponding to the target service handle is obtained;
[0011] If a target service handle that matches the screen resolution and / or network bandwidth is not found in the source service handle, the source video stream corresponding to the stream identifier to be played is transcoded to obtain a transcoded video stream, and the transcoded video stream is used as the target video stream.
[0012] In an exemplary embodiment of the present disclosure, the source code service handle is stored in a key-value pair format;
[0013] The key of the source service handle is the mainstream identifier of the source video stream;
[0014] The value of the source code service handle is the original resolution and / or original bit rate of the source video stream.
[0015] In an exemplary embodiment of the present disclosure, the value of the source code service handle further includes one or more transcoding service handles;
[0016] The key of the transcoding service handle is the transcoding identifier of the source video stream, and the value of the transcoding service handle is the transcoding resolution and / or transcoding bit rate of the transcoded video after the transcoding.
[0017] In an exemplary embodiment of the present disclosure, transcoding a source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream includes:
[0018] Acquire a source picture group included in a source video stream corresponding to the stream identifier to be played, and acquire a source key frame included in the source picture group;
[0019] Acquire an immediately refreshed image IDR frame in the source key frame, and parse the IDR frame to obtain a sequence parameter set and an image parameter set included in the IDR frame;
[0020] The preset transcoding function is initialized based on the sequence parameter set and the image parameter set, and the source video stream is transcoded based on the initialized transcoding function to obtain a transcoded video stream.
[0021] In an exemplary embodiment of the present disclosure, the source video stream is transcoded based on the initialized transcoding function to obtain a transcoded video stream, including:
[0022] Decoding the source video stream based on the initialized transcoding function to obtain encapsulation format data, and decapsulating the encapsulation format data to obtain audio compression data and video compression data;
[0023] Performing audio decoding and video decoding on the audio compression data and the video compression data to obtain original audio data and original video data, and transcoding the original audio data and the original video data to obtain transcoded audio data and transcoded video data;
[0024] The transcoded audio data and the transcoded video data are packaged to obtain the transcoded video stream.
[0025] In an exemplary embodiment of the present disclosure, the method for processing the video stream further includes:
[0026] Generate a flow redirection identifier corresponding to the transcoded video stream, and generate a transcoding service handle to be added for the transcoded video stream according to the flow redirection identifier, the transcoding resolution and the transcoding bit rate of the transcoded audio data and the transcoded video data;
[0027] The source code service handle of the source video stream is updated using the transcoding service handle to be added.
[0028] In an exemplary embodiment of the present disclosure, the transcoded picture group of each transcoded video stream having different transcoding resolutions and transcoding bit rates and the source key frames and transcoded key frames included in the source picture group are the same.
[0029] In an exemplary embodiment of the present disclosure, before transcoding the source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream and pushing the transcoded video stream to the first terminal, the video stream processing method further includes:
[0030] Reading the transcoded picture group or the source picture group, and placing the transcoded picture group or the source picture group into a preset cache channel;
[0031] Based on the placement order of the transcoded picture groups or the source picture groups in the cache channel, the transcoded picture groups or the source picture groups are pushed to the first terminal.
[0032] In an exemplary embodiment of the present disclosure, reading the transcoded picture group or the source picture group includes:
[0033] Obtaining the source code rate, source code resolution and / or one or more transcoding rates and / or one or more transcoding resolutions included in the source code service handle;
[0034] Calculating the difference between the source code rate and / or the transcoding code rate and the network bandwidth to obtain a first difference calculation result, and calculating the difference between the source code resolution and / or the transcoding resolution and the screen resolution to obtain a second difference calculation result;
[0035] Based on the first difference calculation result and the second difference calculation result, a target service handle is determined, and a transcoded picture group or a source picture group corresponding to a target stream identifier included in the target service handle is read.
[0036] In an exemplary embodiment of the present disclosure, the transcoded picture group or the source picture group includes a current key frame, a first predicted frame obtained by predicting the current key frame, and a second predicted frame obtained by predicting the current key frame and the first predicted frame;
[0037] The video stream processing method further includes:
[0038] The source video stream is calculated based on a preset image recognition model to obtain the current key frame; wherein the image recognition model includes any one or more of a convolutional neural network model, a recurrent neural network model, and a deep neural network model.
[0039] In an exemplary embodiment of the present disclosure, the method for processing the video stream further includes:
[0040] Receiving a source video stream sent by a second terminal, and configuring a mainstream identifier for the source video stream;
[0041] Generate a source code service handle of the source video stream according to the mainstream identifier, the original resolution and the original bit rate of the source video stream;
[0042] The preset homologous flow dictionary is constructed according to the source code service handle.
[0043] In an exemplary embodiment of the present disclosure, the method for processing the video stream further includes:
[0044] Sending a heartbeat detection message to the first terminal at intervals of a first preset time period, and detecting whether the first terminal has sent a heartbeat response message corresponding to the heartbeat detection message within a second preset time period;
[0045] If the first terminal does not send the heartbeat response message within the preset time period, obtaining the transcoding service handle to be deleted of the first terminal corresponding to the first terminal that does not send the heartbeat response message;
[0046] The source code service handle to which the transcoding service handle to be deleted belongs is determined according to the transcoding stream identifier included in the transcoding service handle to be deleted, and the transcoding service handle to be deleted is deleted from the source code service handle.
[0047] According to one aspect of the present disclosure, a video stream processing device is provided, comprising:
[0048] A video play request parsing module, used for receiving a video play request sent by a first terminal, and parsing the video play request to obtain a screen resolution, a network bandwidth and a stream identifier to be played of the first terminal;
[0049] A source service handle matching module, used to match a source service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and to match a target service handle matching the screen resolution and / or network bandwidth in the source service handle;
[0050] The target video stream pushing module is used to obtain the target video stream corresponding to the target service handle and push the target video stream to the first terminal.
[0051] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the video stream processing method described in any one of the above is implemented.
[0052] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0053] Processor; and
[0054] A memory, configured to store executable instructions of the processor;
[0055] The processor is configured to execute any one of the above-mentioned methods for processing a video stream by executing the executable instructions.
[0056] A method for processing a video stream provided by an embodiment of the present disclosure comprises the following steps: on the one hand, receiving a video playback request sent by a first terminal and parsing the video playback request to obtain the screen resolution, network bandwidth and stream identifier to be played of the first terminal; matching a source code service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and matching a target service handle matching the screen resolution and / or network bandwidth in the source code service handle; finally, obtaining a target video stream corresponding to the target service handle, and pushing the target video stream to the first terminal, thereby matching the target video stream corresponding to the first terminal according to the screen resolution and network bandwidth of the first terminal, and solving the problem in the prior art that the corresponding video stream cannot be pushed to the terminal device according to the bandwidth and resolution of the terminal device itself; on the other hand, since the target video stream is matched according to the screen resolution and network bandwidth of the first terminal, the problem of delayed display caused by bandwidth mismatch or the problem of freeze caused by screen resolution mismatch can be avoided, thereby improving the user's viewing experience.
[0057] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0059] Figure 1 The following is a flowchart schematically showing a method for processing a video stream according to an exemplary embodiment of the present disclosure.
[0060] Figure 2 An example diagram schematically illustrates a specific implementation scenario of a method for processing a video stream according to an example embodiment of the present disclosure.
[0061] Figure 3 The following schematically shows a structural example of a server according to an exemplary embodiment of the present disclosure.
[0062] Figure 4 An example diagram of a scenario of server-based transcoding according to an example embodiment of the present disclosure is schematically shown.
[0063] Figure 5 A flowchart schematically illustrates a method for constructing a homologous flow dictionary according to an exemplary embodiment of the present disclosure.
[0064] Figure 6 The following schematically shows an example structure diagram of a homologous flow dictionary according to an example embodiment of the present disclosure.
[0065] Figure 7 A flowchart of a method for transcoding a source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream according to an exemplary embodiment of the present disclosure is schematically shown.
[0066] Figure 8 The following schematically shows an example structure of a source group of pictures (GOP) according to an exemplary embodiment of the present disclosure.
[0067] Fig. 9 A diagram schematically shows an example scenario of transcoding a source video stream according to an example embodiment of the present disclosure.
[0068] Fig.10 A flowchart of a method for deleting a transcoding service handle according to an exemplary embodiment of the present disclosure is schematically shown.
[0069] Fig.11 An example diagram schematically illustrates a scenario of calling an interface of a transcoding service and issuing a transcoding task according to an example embodiment of the present disclosure.
[0070] Fig.12 A diagram schematically illustrates an example scenario of performing asynchronous operation on a transcoding service according to an example embodiment of the present disclosure.
[0071] Fig.13 The block diagram schematically shows a device for processing a video stream according to an exemplary embodiment of the present disclosure.
[0072] Fig.14 An electronic device for implementing the above-mentioned video stream processing method according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0073] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0074] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0075] In the development of streaming media, it is often necessary to have different resolutions or bit rates for the same video stream. For example, a 1280P real-time stream is pushed up through RTSP (Real Time Streaming Protocol) or RTMP (Real Time Messaging Protocol), but in fact the network rate at the playback end is low or unstable. If you want to ensure that users can play the stream without lag, you may need to convert the resolution or bit rate of the real-time stream.
[0076] In some technical solutions, the live streams pushed by RTSP and RTMP are audio and video streams with specified resolutions or bit rates. In fact, the network of the push link is often unstable. In actual applications, in order to ensure a good user experience, no video freezes, or when playing through a web page or a specified terminal, additional requirements for the stream (such as resolution or bit rate) are required; however, given that the live stream requires real-time performance, in order to minimize the user's delay experience, the usual practice is to push a low bit rate or resolution stream from the same video source to the media server (such as the camera has a primary and secondary stream). However, since the camera needs to encode the primary and secondary streams at the same time, the burden on the camera is heavy, and there will be a problem of delayed push, which will cause delays in the anchor user end and the user end watching the live broadcast; and the need to push the primary and secondary streams at the same time will cause a large-scale occupation of network bandwidth; in addition, there will be demands other than the primary and secondary streams that cannot be met.
[0077] Based on this, this exemplary embodiment first provides a method for processing a video stream, which can be run on a server, a server cluster, or a cloud server, etc. Of course, those skilled in the art can also run the method disclosed in this disclosure on other platforms as required, and this exemplary embodiment does not specifically limit this. Figure 1 As shown, the video stream processing method may include the following steps:
[0078] Step S110: receiving a video playback request sent by the first terminal, and parsing the video playback request to obtain the screen resolution, network bandwidth and stream identifier to be played of the first terminal;
[0079] Step S120. Match the source service handle corresponding to the stream identifier to be played in the preset homologous stream dictionary, and match the target service handle matching the screen resolution and / or network bandwidth in the source service handle;
[0080] Step S130: Obtain a target video stream corresponding to the target service handle, and push the target video stream to the first terminal.
[0081] In the above-mentioned video stream processing method, on the one hand, by receiving a video playback request sent by a first terminal and parsing the video playback request, the screen resolution, network bandwidth and stream identifier to be played of the first terminal are obtained; and the source code service handle corresponding to the stream identifier to be played is matched in the preset homologous stream dictionary, and the target service handle matching the screen resolution and / or network bandwidth is matched in the source code service handle; finally, the target video stream corresponding to the target service handle is obtained, and the target video stream is pushed to the first terminal, so that the target video stream corresponding to the first terminal is matched according to the screen resolution and network bandwidth of the first terminal, and the problem of being unable to push the corresponding video stream to the terminal device according to the bandwidth and resolution of the terminal device itself in the prior art is solved; on the other hand, since the target video stream is matched according to the screen resolution and network bandwidth of the first terminal, the problem of delayed display caused by bandwidth mismatch or the problem of freeze caused by screen resolution mismatch can be avoided, thereby improving the user's viewing experience.
[0082] Hereinafter, the method for processing a video stream according to an exemplary embodiment of the present disclosure will be explained and illustrated in detail with reference to the accompanying drawings.
[0083] First, the purpose of the invention of the example embodiment of the present disclosure is explained and illustrated. Specifically, the method for processing the video stream recorded in the example embodiment of the present disclosure re-encodes and decodes the pushed source video stream to generate a new stream of specified resolution and bit rate without affecting the source video stream, thereby achieving the purpose of dynamically adjusting the resolution and bit rate to more flexibly meet the actual live streaming needs of the user side (different bit rates and resolutions), without having to push multiple streams of the same video source to the media service, thereby achieving the purpose of meeting the actual live streaming needs of the user side while reducing the bandwidth occupancy rate and the burden of the camera. In the specific application process, the example embodiment of the present disclosure adopts the basic codec library of FFMPEG to perform secondary encoding on the source video stream; at the same time, in order to avoid large delays, the system will cache a certain number (GOP length) of frames for data initialization operations when switching encoding; at the same time, the method for processing the video stream recorded in the example embodiment of the present disclosure can also establish a mapping for the mainstream and the converted stream, thereby facilitating rapid retrieval when the playback end pulls the stream.
[0084] Secondly, the specific implementation scenario of the video stream processing method recorded in the exemplary embodiment of the present disclosure is explained and illustrated.
[0085] Specifically, the video stream processing method described in the exemplary embodiments of the present disclosure can be used in scenarios where a low-resolution and low-bitrate video source is required when a high-definition live broadcast is played synchronously through a web terminal, a video wall, a mobile terminal, a specific low-profile terminal, etc. Figure 2As shown, the application scenario involved in the video stream processing method recorded in the example embodiment of the present disclosure may include a first terminal 210, a server 220 and a second terminal 230; wherein the second terminal may be a terminal including a camera component, for shooting a source video stream; the first terminal may be a terminal for watching live video, which may be used to play the video stream, and the server may be used to implement the video stream processing method recorded in the example embodiment of the present disclosure; at the same time, the first terminal and the second terminal may be connected to the server via a wired network or a wireless network.
[0086] Specifically, the first terminal recorded in this example embodiment can be a set-top box, a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a wireless terminal in industrial control (Industrial Control), a wireless terminal in self-driving (Self Driving), a wireless terminal in remote medical (Remote Medical), a wireless terminal in smart grid (Smart Grid), a wireless terminal in transportation safety (Transportation Safety), a wireless terminal in a smart city (Smart City), a wireless terminal in a smart home (Smart Home), etc. This example does not impose any special restrictions on this.
[0087] For further reference, Figure 3 As shown, the server may include a streaming end 301, a transcoding service module 302, a frame 303 for caching GOP length, a transcoding service handle dictionary 304, a transcoding management service module 305, a transcoding notification service module 306, a homologous stream dictionary 307, an update notification service module 308, and a playback management service module 309. Among them:
[0088] The streaming end 301 refers to the access service of the RTMP / RTSP stream, and is responsible for receiving the video and audio streams; the transcoding service module 302 provides independent transcoding capabilities, which can be referenced as a module or enabled as an independent service; the parameters and structure included in the transcoding service module 302 can be as follows:
[0089] Cache GOP-length frames: This refers to caching the original frame data of a certain video stream; Transcoding service handle dictionary: refers to the transcoding service requested by the business side (stream ID, transcoding resolution, bit rate and other parameters need to be set). The system will eventually generate a transcoding service handle, and form a dictionary corresponding to the transcoded stream ID (for easy management); Transcoding management service: responsible for receiving business side requests, creating and closing transcoding handles, etc.; Transcoding notification service module: Each business side request should correspond to a notification service, and the object of this service notification is the stream pulling service; Same-source stream dictionary: The dictionary includes the Key as the mainstream ID (the mainstream is also the source video stream, or it can be called the untranscoded stream), the Value as the dictionary (Key is the transcoding stream ID, and the Value is the object (the object includes at least resolution and bit rate)), and the dictionary is mainly used for customer management services; Update notification service module: Receive the notification of the transcoding service and update the same-source stream dictionary accordingly; Playback management service: Waiting to receive the playback request from the playback end, and request the corresponding stream from the same-source stream dictionary for push according to the playback parameters (bit rate or resolution). Among them, the specific transcoding service scenario example diagram can be referred to Figure 4 shown.
[0090] It should be noted here that the video stream processing method recorded in the example embodiment of the present disclosure ultimately aims to convert the source video stream pushed up according to the actual needs of the user (i.e., the first terminal) so as to meet the dynamically changing network environment, designated terminal and seamless playback of the playback end; at the same time, by calling the underlying transcoding library of the FFMPEG tool, the bit rate and resolution conversion of RTSP or RTMP is realized through business-level adjustments to meet the business needs and good experience of the streaming side.
[0091] Further, the source video stream recorded in the exemplary embodiment of the present disclosure is explained and illustrated. Specifically, the source video stream recorded in the exemplary embodiment of the present disclosure can be a Real Time Streaming Protocol (RTSP) stream or an RTMP (Real Time Messaging Protocol) stream, or other streams, and this example does not impose any special restrictions on this. Specifically, RTSP is an application layer protocol in the Transmission Control Protocol / Internet Protocol (TCP / IP) system, and the packaging format in the RTSP stream can be multiple, exemplarily, it can be a Transport Stream (TS) format, it can be an Elementary Stream (ES) format, and it can also be a bare stream format.
[0092] In an exemplary embodiment, the raw code stream can be encoded as an ES stream, and the ES stream can be packaged as a TS stream. The raw code stream is an unencoded data stream, and the raw code stream contains both audio data and video data. The ES stream is a data stream containing only one content, and is composed of several ES packets, such as an ES stream containing only video data or an ES stream containing only audio data. When encoding the raw code stream, the video data and the audio data can be first divided, and the raw code stream can be encoded into an ES stream containing only video data and an ES stream containing only audio data. The ES packets in the ES stream can be further encapsulated into TS packets to form a TS stream, and the TS packets can be independently encoded or decoded. In an exemplary embodiment, the above-mentioned source video stream also includes a protocol header, and in the process of transcoding the source video stream, the protocol needs to be decoded first. Exemplarily, if the source video stream is an RTSP stream, then the source video stream includes an RTSP header accordingly; if the source video stream is an RTMP stream, then the source video stream includes an RTMP header accordingly.
[0093] The following, combined Figure 5 The construction process of the homologous flow dictionary involved in the exemplary embodiment of the present disclosure is explained and illustrated. Figure 5 As shown, the following steps may be included:
[0094] Step S510, receiving a source video stream sent by a second terminal, and configuring a mainstream identifier for the source video stream;
[0095] Step S520, generating a source code service handle of the source video stream according to the mainstream identifier, the original resolution and the original bit rate of the source video stream;
[0096] Step S530: construct the preset homologous flow dictionary according to the source code service handle.
[0097] Steps S510 to S530 will be explained and illustrated below. Specifically, first, the source video stream sent by the second terminal can be received by the streaming end in the service; wherein, in a high-definition live broadcast scenario, the second terminal can be a terminal including a camera component, which shoots the source video stream in the high-definition live broadcast scenario through the camera component, and transmits it to the terminal and then transmits it to the streaming end through the terminal; further, in the live broadcast scenario, the second terminal can be the terminal where the anchor user is located; after the streaming end receives the source video stream, it can configure a mainstream identifier for the source video stream, and then generate a source code service handle of the source video stream according to the mainstream identifier, the original resolution and the original bit rate of the source video stream, and then build a preset homologous stream dictionary according to the source code service handle; wherein, the example diagram of the homologous stream dictionary obtained can refer to Figure 6 shown.
[0098] It should be noted here that the mainstream identification recorded here, in the live broadcast scenario, can depend on the user identification of the anchor user, or on the identification of the live broadcast room where the anchor user is located. This example does not impose any special restrictions on this.
[0099] It is necessary to further explain here that the source code service handle is stored in the form of a key-value pair; the key of the source code service handle is the mainstream identifier of the source video stream; the value of the source code service handle is the original resolution and / or original bit rate of the source video stream. Furthermore, the value of the source code service handle also includes one or more transcoding service handles; the key of the transcoding service handle is the transcoding identifier of the source video stream, and the value of the transcoding service handle is the transcoding resolution and / or transcoding bit rate of the transcoded video after the transcoding. That is to say, in the obtained preset homologous stream dictionary, the mainstream identifier (mainstream ID) of the source video stream can be used as the unique Key to facilitate quick retrieval, and the Value corresponding to the Key can include the original resolution and original bit rate of the source video stream, and can also include the transcoding identifier of the transcoded video stream corresponding to the source video stream, the transcoding resolution and transcoding bit rate of the transcoded video stream.
[0100] The following will be combined Figure 2 as well as Figure 6 right Figure 1 The video stream processing method shown in is explained and illustrated in detail. Specifically:
[0101] In step S110, a video play request sent by a first terminal is received, and the video play request is parsed to obtain a screen resolution, a network bandwidth, and an identifier of a stream to be played of the first terminal.
[0102] In this example embodiment, first, a video playback request sent by a first terminal is received; wherein, taking a set-top box as the first terminal, a video playback request sent by the set-top box can be received, and the video playback request may include the screen resolution and network bandwidth of a video display device (such as a TV or a projector, etc.) connected to the set-top box, and the requested stream identifier to be played; wherein the stream identifier to be played recorded here is consistent with the mainstream identifier of the source video stream.
[0103] Secondly, after receiving the video playback request, the transcoding management service module on the server side can parse the video playback request to obtain the corresponding screen resolution, network bandwidth, and the requested stream identifier to be played.
[0104] In step S120, a source service handle corresponding to the stream identifier to be played is matched in a preset homologous stream dictionary, and a target service handle matching the screen resolution and / or network bandwidth is matched in the source service handle.
[0105] In this example embodiment, after obtaining the screen resolution, network bandwidth, and the requested stream identifier to be played, first, the source code service handle corresponding to the stream identifier to be played can be matched in the preset homologous stream dictionary; wherein, in the process of matching the source code service handle, the mainstream identifier included in the source code service handle can be matched based on the stream identifier to be played, and after matching the corresponding mainstream identifier, the source code service handle associated with the mainstream identifier is the source code service handle corresponding to the stream identifier to be played; secondly, after obtaining the source code service handle corresponding to the stream identifier to be played, the target service handle corresponding to the screen resolution and network bandwidth can be matched among the original resolution, original bit rate, and transcoding resolution, transcoding bit rate included in the source code service handle.
[0106] It should be noted here that, in the specific application process, the matching efficiency can be improved by first querying the corresponding source code service handle, and then matching the target service handle corresponding to the screen resolution and network bandwidth in the source code service handle; and, since the source code service handle includes all the transcoding service handles corresponding to the mainstream identifier, the accuracy of the matching results can also be improved; at the same time, in some application scenarios, the screen resolution can be matched separately or the network bandwidth can be matched separately, and this example does not impose any special restrictions on this.
[0107] In step S130, a target video stream corresponding to the target service handle is obtained, and the target video stream is pushed to the first terminal.
[0108] In this example embodiment, first, the target video stream corresponding to the target service handle is obtained. Specifically, it can be implemented in the following manner: if a target service handle matching the screen resolution and / or network bandwidth is matched in the source code service handle, the target video stream corresponding to the target service handle is obtained; if a target service handle matching the screen resolution and / or network bandwidth is not matched in the source code service handle, the source video stream corresponding to the stream identifier to be played is transcoded to obtain a transcoded video stream, and the transcoded video stream is used as the target video stream.
[0109] That is, in a specific application process, if there is a target service handle that matches the screen resolution and the network bandwidth, the target video stream corresponding to the target service handle is pushed to the first terminal; if there is no target service handle that satisfies both the screen resolution and the network bandwidth, it can be determined whether there is a target service handle that satisfies the network bandwidth; if there is no target service handle that satisfies the network bandwidth, it is determined whether there is a target service handle that satisfies the screen resolution; if none of the conditions are met, the source video stream can be transcoded; in some possible example embodiments, if there is a target service handle that satisfies the network bandwidth but does not satisfy the screen resolution, screen resolution transcoding can be performed or it can be directly pushed, and this example does not impose any special restrictions on this; in some possible example embodiments, if there is a target service handle that satisfies the screen resolution but does not satisfy the network bandwidth, network bandwidth transcoding can be performed or it can be directly pushed, and this example does not impose any special restrictions on this.
[0110] Figure 7 A flowchart of a method for transcoding a source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream according to an exemplary embodiment of the present disclosure is schematically shown. Figure 7 As shown, the following steps may be included:
[0111] Step S710, obtaining a source picture group included in a source video stream corresponding to the stream identifier to be played, and obtaining a source key frame included in the source picture group;
[0112] Step S720, obtaining an immediately refreshed image IDR frame in the source key frame, and parsing the IDR frame to obtain a sequence parameter set and an image parameter set included in the IDR frame;
[0113] Step S730: Initialize a preset transcoding function based on the sequence parameter set and the image parameter set, and transcode the source video stream based on the initialized transcoding function to obtain a transcoded video stream.
[0114] In an exemplary embodiment, the source video stream is transcoded based on the transcoding function after initialization to obtain a transcoded video stream, which can be achieved in the following manner: first, the source video stream is de-protocoled based on the transcoding function after initialization to obtain encapsulation format data, and the encapsulation format data is decapsulated to obtain audio compression data and video compression data; secondly, the audio compression data and the video compression data are audio decoded and the video compression data are video decoded to obtain audio original data and video original data, and the audio original data and the video original data are transcoded to obtain transcoded audio data and transcoded video data; finally, the transcoded audio data and the transcoded video data are packetized to obtain the transcoded video stream.
[0115] In the following, steps S710 to S730 will be explained and illustrated. Specifically, in the specific process of bit rate conversion, after the transcoding service receives the stream, it performs necessary initialization operations; the specific initialization process may include initializing the dictionary of cached transcoding handles and the latest frame data of cached GOP length, which is generally the length of two key frame intervals. After the initialization is completed, the source picture group (GOP, Group Of Picture) can be obtained; wherein, reference Figure 8 As shown, a GOP is a group of continuous pictures; the GOP structure generally has two numbers, one of which is the length of the GOP (i.e., the number of B frames and P frames between two I frames), and the other number is the interval between I frames and P frames (i.e., the number of B frames); within a GOP, I frame decoding does not depend on any other frames, P frame decoding depends on the previous I frame or P frame, and B frame decoding depends on the previous I frame or P frame and the nearest P frame thereafter; at the same time, the I frames in a GOP can be divided into ordinary I frames and IDR frames, and the IDR (Instantaneous Decoding Refresh) frame is the first I frame of the GOP, and this distinction is regarded as the process of controlling the encoding and decoding for edge sealing; at the same time, an IDR frame must be an I frame, but an I frame is not necessarily an IDR frame; and, because an IDR frame is accompanied by an SPS (Sequence Parameter Set) and a PPS (Picture Parameter Set) Set) and other information, so that when the decoder receives the IDR frame, what it needs to do is: update all PPS and SPS parameters; that is, the role of the IDR frame is to let the decoder scientifically refresh the relevant data information to avoid large decoding errors; further, the IDR frame mechanism is introduced for decoding resynchronization. When the decoder decodes to the IDR frame, it understands that the reference frame queue is emptied, all decoded data is output or discarded, the parameter set is re-searched, and a new sequence is started; in this way, if an error occurs in the previous sequence, a chance to resynchronize can be obtained here; the frame after the IDR frame will never be decoded using the data before the IDR frame.
[0116] Under the premise of the above-mentioned contents, after the source picture group is obtained, the source IDR frame in the source picture group can be obtained, and then the preset transcoding function is initialized according to the sequence parameter set and the image parameter set included in the source IDR frame, and then transcoding is performed based on the initialized transcoding function to obtain a transcoded video stream; wherein, the transcoding function recorded here can be an FFMpeg function. It should be noted here that before the preset transcoding function is initialized by the sequence parameter set and the image parameter set, it is also necessary to determine whether the sequence parameter set and the image parameter set are complete. If not, it is necessary to parse the complete sequence parameter set and the image parameter set from other received frames, and complete the incomplete sequence parameter set and the image parameter set with the complete sequence parameter set and the image parameter set before performing the corresponding transcoding.
[0117] Furthermore, in the specific process of transcoding the source video stream through FFMpeg, the process of protocol decompression, decapsulation, decoding and data synchronization involved can be specifically shown as follows:
[0118] First, the protocol decoding process can parse the data of the streaming media protocol into standard corresponding encapsulation format data; specifically, when the streaming end receives the source video stream, it adopts various streaming media protocols (such as RTMP or RTSP, etc.); these protocols transmit some signaling data while transmitting audio and video data; these signaling data include playback control (play, pause, stop), or description of network status, etc.; among them, the signaling data will be removed during the protocol decoding process and only the audio and video data will be retained; for example, data transmitted using the RTMP protocol will be output as data in FLV format after the protocol decoding operation.
[0119] Secondly, decapsulation processing can separate the input encapsulation format data into audio stream compressed coded data and video stream compressed coded data; there are many types of encapsulation formats, such as MP4, MKV, RMVB, TS, FLV and AVI, etc. Its function is to put the compressed and coded video data and audio data together in a certain format; for example, FLV format data, after decapsulation operation, outputs H.264 encoded video stream and AAC encoded audio stream;
[0120] Further, the decoding process can decode the video / audio compression encoding data into uncompressed video / audio original data; wherein the audio compression encoding standards include AAC, MP3, AC-3, etc.; the video compression encoding standards include H.264, MPEG2, VC-1, etc.; through decoding, the compressed encoded video data output is converted into uncompressed color data, such as YUV420P, RGB, etc.; the compressed encoded audio data output is converted into uncompressed audio sampling data, such as PCM data;
[0121] Finally, the packet processing can synchronize the decoded video and audio data according to the parameter information obtained during the decapsulation process, and send the video and audio data to the system's graphics card and sound card for playback; the specific conversion scene example diagram can be referred to Fig. 9 shown.
[0122] In an exemplary embodiment, after obtaining a transcoded video stream, the method for processing the video stream may further include: generating a transcoding identifier corresponding to the transcoded video stream, and generating a transcoding service handle to be added for the transcoded video stream based on the transcoding identifier, the transcoding resolution and the transcoding bit rate of the transcoded audio data and the transcoded video data; updating the source code service handle of the source video stream using the transcoding service handle to be added; wherein the transcoded picture group of each transcoded video stream with different transcoding resolutions and transcoding bit rates and the source code key frames and transcoding key frames included in the source code picture group are the same.
[0123] Specifically, the diversion identifier recorded here can be associated with or independently set with the mainstream identifier recorded above, as long as the key-value relationship between the diversion identifier and the mainstream identifier is ensured; the transcoding service handle recorded here can also exist in the form of a key value or in other forms, and this example does not impose any special restrictions on this; at the same time, the reason why the transcoded picture group of each transcoded video stream with different transcoding resolutions and transcoding bit rates and the source key frames and transcoding key frames included in the source picture group are restricted to be the same is to ensure that the live pictures of the same live broadcast room received by each first terminal with different network bandwidth and screen resolution are the same, thereby achieving data consistency. Through this method, the user's viewing experience can be further improved.
[0124] In an example embodiment, the video stream processing method further includes: reading the transcoded picture group or source picture group, and placing the transcoded picture group or source picture group into a preset cache channel; based on the placement order of the transcoded picture group or source picture group in the cache channel, pushing the transcoded picture group or source picture group to the first terminal. Wherein, the frame cache is a cache channel, and the playback point needs to consume frame data from the channel in sequence, and synchronously send the frame data of the channel to all playback terminals accessing the stream (ensuring the consistency of the playback terminal data); through this method, the delay of the first terminal when requesting the video to be played can be reduced, thereby improving the user's viewing experience.
[0125] In an exemplary embodiment, reading the transcoded picture group or the source picture group can be achieved in the following manner: first, obtaining the source code rate, source code resolution and / or one or more transcoding code rates and / or one or more transcoding resolutions included in the source code service handle; secondly, calculating the difference between the source code rate and / or the transcoding code rate and the network bandwidth to obtain a first difference calculation result, and calculating the difference between the source code resolution and / or the transcoding resolution and the screen resolution to obtain a second difference calculation result; then, based on the first difference calculation result and the second difference calculation result, determining the target service handle, and reading the transcoded picture group or source picture group corresponding to the target stream identifier included in the target service handle. That is, in the specific application process, in order to further reduce the delay and not affect the display of the video stream by the first terminal, when the target service handle corresponding to the screen resolution and the network bandwidth is not matched, a target service handle with a similar screen resolution and / or network bandwidth can be selected, and the picture group corresponding to the target service handle can be pushed to the first terminal, and after transcoding is completed, the target video stream corresponding to the screen resolution and the network bandwidth of the first terminal can be pushed to the first terminal; through this method, seamless connection of the video stream can be achieved, thereby achieving the purpose of improving the user's viewing experience.
[0126] In an example embodiment, the above transcoded picture group or source picture group includes a current key frame (i.e., an I frame), a first predicted frame (P frame) obtained by predicting the current key frame, and a second predicted frame (B frame) obtained by predicting the current key frame and the first predicted frame; wherein, the video stream processing method further includes: calculating the source video stream based on a preset image recognition model to obtain the current key frame; wherein, the image recognition model includes any one or more of a convolutional neural network model, a recurrent neural network model, and a deep neural network model. It should be noted here that in actual application, the specific confirmation process of the current key frame (or any key frame) can be extracted not only by the models listed above, but also by other models, and this example does not impose any special restrictions on this; the above models can be embedded in the server in the form of a chip, or remotely called through the corresponding interface, etc., and this example does not impose any special restrictions on this.
[0127] Fig.10 The following schematically illustrates a method flow for deleting a transcoding service handle according to an exemplary embodiment of the present disclosure. Fig.10 As shown, the following steps may be included:
[0128] Step S1010, sending a heartbeat detection message to the first terminal at intervals of a first preset time period, and detecting whether the first terminal has sent a heartbeat response message corresponding to the heartbeat detection message within a second preset time period;
[0129] Step S1020: if the first terminal does not send the heartbeat response message within the preset time period, obtaining a transcoding service handle to be deleted that is owned by the first terminal corresponding to the first terminal that did not send the heartbeat response message;
[0130] Step S1030: determining the source service handle to which the transcoding service handle to be deleted belongs according to the transcoding stream identifier included in the transcoding service handle to be deleted, and deleting the transcoding service handle to be deleted from the source service handle.
[0131] Below, step S1010-step S1030 will be explained and illustrated. Specifically, in order to avoid the problem of heavy burden on the server due to too many idle transcoding service handles, the transcoding service handle can be deleted on time. It should be noted here that in the specific deletion process, the transcoding stream ID to be deleted can be retrieved from the transcoding handle dictionary. If it exists, the handle is deleted and closed; at the same time, since the new stream (transcoding stream) generated by transcoding is based on the source video stream, and there is only one source video stream, the data itself is highly synchronized.
[0132] The following further explains and illustrates the video stream processing method described in the exemplary embodiment of the present disclosure in combination with specific application scenarios. Specifically, taking a traffic omni-media platform of a certain place as an example, in the traffic omni-media platform, the specific implementation process can be as follows:
[0133] First, build a streaming service, transcoding service, and streaming service, and use them to form a real-time streaming media service. The streaming service, transcoding service, and streaming service can be started on the same physical machine in the form of Docker. At the same time, before starting the physical machine, you also need to check the logs to ensure that there are no abnormal alarms in the started services.
[0134] Then, the second terminal pushes a video and audio stream (source video stream) 1 with a resolution of 1920P and a bit rate of 8M to the push streaming service; the streaming service runs normally, and the user at the pull streaming end can play the stream 1 normally through the player (the first terminal);
[0135] Furthermore, on the business side (the upper-layer business of the integrated streaming media service), the transcoding service interface is called to issue the transcoding task (for details, please refer to Fig.11 As shown); the transcoding task mainly includes the mainstream ID, length, width and bit rate. After the task is successfully issued, a transcoding handle will be created in the forwarding service. The handle is responsible for copying a mainstream frame and pushing the frame to the FFMPEG transcoding interface, and then generating new frame data output; at this time, the transcoded stream pushes the stream data to the stream pulling end according to the mainstream rules;
[0136] Furthermore, the transcoding task is an asynchronous operation, and multiple issuances do not affect each other. At the same time, the business side can also close unnecessary transcoding services according to actual usage (the sid here is the new stream ID after transcoding). For details, please refer to Fig.12 shown.
[0137] In a specific application scenario, the traffic omnimedia project requires that stream 1 (source video stream) can be viewed in real time on the Web and IPAD terminals. At this time, a transcoding task (480*320, 1M) will be issued to generate a new stream 2 (transcoded video stream); under this premise, a transcoding service notification can be issued; and after the transcoding task is successful, a notification will be issued to the stream pulling service. The purpose of this notification is to inform the stream pulling end that a new stream has been generated and that the stream pulling end needs to do something; after necessary initialization, the new stream will be pulled from the transcoding service; then, the notification of the new stream 2 is sent to the stream pulling end, and the stream pulling end successfully pulls the real-time frame data of stream 2 from the transcoding service. At this point, the mainstream and transcoded streams can be queried and played on the stream pulling end.
[0138] It should be noted here that the source video stream and transcoded video stream recorded above are independent streams, and their independent playback does not affect each other. The business side can view the existing streams in the relevant interface; at the same time, the business side can choose to pull the stream ID from the stream pulling end according to the terminal type. As for the stream selection during network jitter and the consistency problem of multi-terminal streaming, in order to save bandwidth, the playback end will create multiple transcoded streams (with lower resolution and bit rate than the source video stream) on the business side. The playback end needs to bring parameters according to its own network status (resolution or bit rate requirements, these parameters change dynamically under certain conditions), and then request real-time playback on the streaming end; further, since there is only one transcoded stream of each type and there is a data cache at the transcoding service to eliminate inconsistencies, the playback end will uniformly fetch frames from the frame cache of the streaming end when pulling the stream, and the data consistency problem can be eliminated; of course, the streaming end can subscribe to stream 2 and cache a certain number of frames, and the playback end management service will fetch frames from the cache and throw them to the player; however, this method will still have a delay in sending packets to the player, so a concurrent packet sending mechanism can be considered; among them, the concurrent packet sending mechanism can be implemented by preparing a thread pool in advance, that is, each thread is responsible for a certain number of playback ends, which can reduce delays.
[0139] At this point, the video stream processing method recorded in this example embodiment has been completed. Based on the above-mentioned content, it can be known that the video stream processing method recorded in the example embodiment of the present disclosure has at least the following advantages: on the one hand, multiple new streams with different resolutions and bit rates can be converted through one mainstream; at the same time, the streams of the same source are managed, and the frame data of the specified stream can be quickly found according to the playback end parameters, and its time complexity is O(1); on the other hand, the GOP length cache realizes the synchronization of transcoding service data and achieves seamless connection; and, if the system resources are sufficient, it can be infinitely converted; further, it can also realize the RTSP or RTMP protocol to switch streams with different bit rates according to the user's network status, and realize the user's dynamic resolution and bit rate adjustment, so as to be used in different scenarios; in specific applications, it can also transcode a certain stream pushed by RTMP or RTSP to form multiple streams with different resolutions or bit rates, and the stream pulling end can then seamlessly connect the streams and push them to the playback side, thereby improving the user's viewing experience.
[0140] The exemplary embodiment of the present disclosure also provides a video stream processing device. Specifically, refer to Fig.13 As shown, the video stream processing device may include a video playback request parsing module 1310, a source code service handle matching module 1320, and a target video stream pushing module 1330. Among them:
[0141] The video play request parsing module 1310 may be configured to receive a video play request sent by a first terminal, and parse the video play request to obtain a screen resolution, a network bandwidth, and a stream identifier to be played of the first terminal;
[0142] The source service handle matching module 1320 may be used to match the source service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and match the target service handle matching the screen resolution and / or network bandwidth in the source service handle;
[0143] The target video stream pushing module 1330 may be configured to obtain a target video stream corresponding to the target service handle, and push the target video stream to the first terminal.
[0144] In the above-mentioned video stream processing device, on the one hand, by receiving a video playback request sent by a first terminal and parsing the video playback request, the screen resolution, network bandwidth and stream identifier to be played of the first terminal are obtained; and the source code service handle corresponding to the stream identifier to be played is matched in the preset homologous stream dictionary, and the target service handle matching the screen resolution and / or network bandwidth is matched in the source code service handle; finally, the target video stream corresponding to the target service handle is obtained, and the target video stream is pushed to the first terminal, so that the target video stream corresponding to the first terminal is matched according to the screen resolution and network bandwidth of the first terminal, and the problem of being unable to push the corresponding video stream to the terminal device according to the bandwidth and resolution of the terminal device itself in the prior art is solved; on the other hand, because the target video stream is matched according to the screen resolution and network bandwidth of the first terminal, the problem of delayed display caused by bandwidth mismatch or the problem of freeze caused by screen resolution mismatch can be avoided, thereby improving the user's viewing experience.
[0145] In an exemplary embodiment of the present disclosure, obtaining a target video stream corresponding to the target service handle includes:
[0146] If a target service handle matching the screen resolution and / or network bandwidth is matched in the source service handle, a target video stream corresponding to the target service handle is obtained;
[0147] If a target service handle that matches the screen resolution and / or network bandwidth is not found in the source service handle, the source video stream corresponding to the stream identifier to be played is transcoded to obtain a transcoded video stream, and the transcoded video stream is used as the target video stream.
[0148] In an exemplary embodiment of the present disclosure, the source code service handle is stored in the form of a key-value pair; the key of the source code service handle is the mainstream identifier of the source video stream; the value of the source code service handle is the original resolution and / or original bit rate of the source video stream.
[0149] In an exemplary embodiment of the present disclosure, the value of the source code service handle also includes one or more transcoding service handles; the key of the transcoding service handle is the transcoding identifier of the source video stream, and the value of the transcoding service handle is the transcoding resolution and / or transcoding bit rate of the transcoded video after the transcoding.
[0150] In an exemplary embodiment of the present disclosure, transcoding a source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream includes:
[0151] Acquire a source picture group included in a source video stream corresponding to the stream identifier to be played, and acquire a source key frame included in the source picture group;
[0152] Acquire an immediately refreshed image IDR frame in the source key frame, and parse the IDR frame to obtain a sequence parameter set and an image parameter set included in the IDR frame;
[0153] The preset transcoding function is initialized based on the sequence parameter set and the image parameter set, and the source video stream is transcoded based on the initialized transcoding function to obtain a transcoded video stream.
[0154] In an exemplary embodiment of the present disclosure, the source video stream is transcoded based on the initialized transcoding function to obtain a transcoded video stream, including:
[0155] Decoding the source video stream based on the initialized transcoding function to obtain encapsulation format data, and decapsulating the encapsulation format data to obtain audio compression data and video compression data;
[0156] Performing audio decoding and video decoding on the audio compression data and the video compression data to obtain original audio data and original video data, and transcoding the original audio data and the original video data to obtain transcoded audio data and transcoded video data;
[0157] The transcoded audio data and the transcoded video data are packaged to obtain the transcoded video stream.
[0158] In an exemplary embodiment of the present disclosure, the video stream processing device may further include:
[0159] The transcoding service handle generation module can be used to generate a flow transfer identifier corresponding to the transcoded video stream, and generate a transcoding service handle to be added to the transcoded video stream according to the flow transfer identifier, the transcoding resolution and the transcoding bit rate of the transcoded audio data and the transcoded video data;
[0160] The source code service handle updating module can be used to update the source code service handle of the source video stream using the transcoding service handle to be added.
[0161] In an exemplary embodiment of the present disclosure, the transcoded picture group of each transcoded video stream having different transcoding resolutions and transcoding bit rates and the source key frames and transcoded key frames included in the source picture group are the same.
[0162] In an exemplary embodiment of the present disclosure, before transcoding the source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream and pushing the transcoded video stream to the first terminal, the video stream processing method further includes:
[0163] Reading the transcoded picture group or the source picture group, and placing the transcoded picture group or the source picture group into a preset cache channel;
[0164] Based on the placement order of the transcoded picture groups or the source picture groups in the cache channel, the transcoded picture groups or the source picture groups are pushed to the first terminal.
[0165] In an exemplary embodiment of the present disclosure, reading the transcoded picture group or the source picture group includes:
[0166] Obtaining the source code rate, source code resolution and / or one or more transcoding rates and / or one or more transcoding resolutions included in the source code service handle;
[0167] Calculating the difference between the source code rate and / or the transcoding code rate and the network bandwidth to obtain a first difference calculation result, and calculating the difference between the source code resolution and / or the transcoding resolution and the screen resolution to obtain a second difference calculation result;
[0168] Based on the first difference calculation result and the second difference calculation result, a target service handle is determined, and a transcoded picture group or a source picture group corresponding to a target stream identifier included in the target service handle is read.
[0169] In an exemplary embodiment of the present disclosure, the transcoded picture group or the source picture group includes a current key frame, a first predicted frame obtained by predicting the current key frame, and a second predicted frame obtained by predicting the current key frame and the first predicted frame;
[0170] Wherein, the video stream processing device further includes:
[0171] The current key frame calculation module can be used to calculate the source video stream based on a preset image recognition model to obtain the current key frame; wherein the image recognition model includes any one or more of a convolutional neural network model, a recurrent neural network model, and a deep neural network model.
[0172] In an exemplary embodiment of the present disclosure, the video stream processing device may further include:
[0173] A mainstream identification configuration module may be used to receive a source video stream sent by a second terminal and configure a mainstream identification for the source video stream;
[0174] A source code service handle generation module can be used to generate a source code service handle of the source video stream according to the mainstream identifier, the original resolution and the original bit rate of the source video stream;
[0175] The homologous flow dictionary construction module can be used to construct the preset homologous flow dictionary according to the source code service handle.
[0176] In an exemplary embodiment of the present disclosure, the video stream processing device further includes:
[0177] A heartbeat response message detection module, which can be used to send a heartbeat detection message to the first terminal at intervals of a first preset time period, and detect whether the first terminal has sent a heartbeat response message corresponding to the heartbeat detection message within a second preset time period;
[0178] The transcoding service handle acquisition module to be deleted can be used to acquire the transcoding service handle to be deleted of the first terminal corresponding to the first terminal that did not send the heartbeat response message if the first terminal did not send the heartbeat response message within the preset time period;
[0179] The module for deleting the transcoding service handle to be deleted can be used to determine the source service handle to which the transcoding service handle to be deleted belongs according to the transcoding stream identifier included in the transcoding service handle to be deleted, and delete the transcoding service handle to be deleted from the source service handle.
[0180] The specific details of each module in the above-mentioned video stream processing device have been described in detail in the corresponding video stream processing method, so they will not be repeated here.
[0181] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0182] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0183] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0184] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0185] Refer to the following Fig.14 1400 according to this embodiment of the present disclosure is described. Fig.14 The electronic device 1400 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0186] like Fig.14 As shown, the electronic device 1400 is in the form of a general computing device. The components of the electronic device 1400 may include, but are not limited to: the at least one processing unit 1410, the at least one storage unit 1420, a bus 1430 connecting different system components (including the storage unit 1420 and the processing unit 1410), and a display unit 1440.
[0187] The storage unit stores program codes, which can be executed by the processing unit 1410, so that the processing unit 1410 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 1410 can perform the following steps: Figure 1Step S110 shown in: receiving a video playback request sent by a first terminal, and parsing the video playback request to obtain the screen resolution, network bandwidth and stream identifier to be played of the first terminal; step S120: matching the source code service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and matching the target service handle matching the screen resolution and / or network bandwidth in the source code service handle; step S130: obtaining a target video stream corresponding to the target service handle, and pushing the target video stream to the first terminal.
[0188] The storage unit 1420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 14201 and / or a cache storage unit 14202 , and may further include a read-only storage unit (ROM) 14203 .
[0189] The storage unit 1420 may also include a program / utility 14204 having a set (at least one) of program modules 14205, such program modules 14205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0190] Bus 1430 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0191] The electronic device 1400 may also communicate with one or more external devices 1500 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1400, and / or communicate with any device that enables the electronic device 1400 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1450. Furthermore, the electronic device 1400 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1460. As shown, the network adapter 1460 communicates with other modules of the electronic device 1400 via a bus 1430. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0192] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0193] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of the present specification.
[0194] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0195] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0196] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0197] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0198] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0199] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0200] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the inventions invented herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not invented by the present disclosure. The specification and examples are to be considered merely exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A method for processing a video stream, characterized in that: include: Receiving a video playback request sent by a first terminal, and parsing the video playback request to obtain a screen resolution, a network bandwidth, and a stream identifier to be played of the first terminal; Matching a source service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and matching a target service handle matching the screen resolution and / or network bandwidth in the source service handle; Acquire a target video stream corresponding to the target service handle, and push the target video stream to the first terminal; Wherein, if a target service handle matching the screen resolution and / or network bandwidth is not matched in the source service handle, the source video stream corresponding to the stream identifier to be played is transcoded to obtain a transcoded video stream, and the transcoded video stream is used as the target video stream; The step of transcoding the source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream includes: Acquire a source picture group included in a source video stream corresponding to the stream identifier to be played, and acquire a source key frame included in the source picture group; Acquire an immediately refreshed image IDR frame in the source key frame, and parse the IDR frame to obtain a sequence parameter set and an image parameter set included in the IDR frame; Initializing a preset transcoding function based on the sequence parameter set and the image parameter set, decompressing the source video stream based on the initialized transcoding function to obtain encapsulation format data, and decompressing the encapsulation format data to obtain audio compression data and video compression data; Performing audio decoding and video decoding on the audio compression data and the video compression data to obtain original audio data and original video data, and transcoding the original audio data and the original video data to obtain transcoded audio data and transcoded video data; The transcoded audio data and the transcoded video data are packaged to obtain the transcoded video stream.
2. The method for processing a video stream according to claim 1, characterized in that: The source code service handle is stored in the form of key-value pairs; The key of the source service handle is the mainstream identifier of the source video stream; The value of the source code service handle is the original resolution and / or original bit rate of the source video stream.
3. The method for processing a video stream according to any one of claims 1 to 2, characterized in that: The value of the source code service handle also includes one or more transcoding service handles; The key of the transcoding service handle is the transcoding identifier of the source video stream, and the value of the transcoding service handle is the transcoding resolution and / or transcoding bit rate of the transcoded video after the transcoding.
4. The method for processing a video stream according to claim 1, characterized in that: The video stream processing method further includes: Generate a flow redirection identifier corresponding to the transcoded video stream, and generate a transcoding service handle to be added for the transcoded video stream according to the flow redirection identifier, the transcoding resolution and the transcoding bit rate of the transcoded audio data and the transcoded video data; The source code service handle of the source video stream is updated using the transcoding service handle to be added.
5. The method for processing a video stream according to claim 1, characterized in that: The transcoded picture group of each transcoded video stream with different transcoding resolutions and transcoding bit rates and the source key frames and transcoded key frames included in the source picture group are the same.
6. The method for processing a video stream according to claim 5, characterized in that: Before transcoding the source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream and pushing the transcoded video stream to the first terminal, the video stream processing method further includes: Reading the transcoded picture group or the source picture group, and placing the transcoded picture group or the source picture group into a preset cache channel; Based on the placement order of the transcoded picture groups or the source picture groups in the cache channel, the transcoded picture groups or the source picture groups are pushed to the first terminal.
7. The method for processing a video stream according to claim 6, characterized in that: Reading the transcoded picture group or the source picture group includes: Obtaining the source code rate, source code resolution and / or one or more transcoding rates and / or one or more transcoding resolutions included in the source code service handle; Calculating the difference between the source code rate and / or the transcoding code rate and the network bandwidth to obtain a first difference calculation result, and calculating the difference between the source code resolution and / or the transcoding resolution and the screen resolution to obtain a second difference calculation result; Based on the first difference calculation result and the second difference calculation result, a target service handle is determined, and a transcoded picture group or a source picture group corresponding to a target stream identifier included in the target service handle is read.
8. The method for processing a video stream according to claim 5, characterized in that: The transcoded picture group or the source picture group includes a current key frame, a first predicted frame obtained by predicting the current key frame, and a second predicted frame obtained by predicting the current key frame and the first predicted frame; The video stream processing method further includes: The source video stream is calculated based on a preset image recognition model to obtain the current key frame; wherein the image recognition model includes any one or more of a convolutional neural network model, a recurrent neural network model, and a deep neural network model.
9. The method for processing a video stream according to claim 1, characterized in that: The video stream processing method further includes: Receiving a source video stream sent by a second terminal, and configuring a mainstream identifier for the source video stream; Generate a source code service handle of the source video stream according to the mainstream identifier, the original resolution and the original bit rate of the source video stream; The preset homologous flow dictionary is constructed according to the source code service handle.
10. The method for processing a video stream according to claim 1, characterized in that: The video stream processing method further includes: Sending a heartbeat detection message to the first terminal at intervals of a first preset time period, and detecting whether the first terminal has sent a heartbeat response message corresponding to the heartbeat detection message within a second preset time period; If the first terminal does not send the heartbeat response message within the preset time period, obtaining the transcoding service handle to be deleted of the first terminal corresponding to the first terminal that does not send the heartbeat response message; The source code service handle to which the transcoding service handle to be deleted belongs is determined according to the transcoding stream identifier included in the transcoding service handle to be deleted, and the transcoding service handle to be deleted is deleted from the source code service handle.
11. A video stream processing device, characterized in that: include: A video play request parsing module, used for receiving a video play request sent by a first terminal, and parsing the video play request to obtain a screen resolution, a network bandwidth and a stream identifier to be played of the first terminal; A source service handle matching module, used to match a source service handle corresponding to the stream identifier to be played in a preset homologous stream dictionary, and to match a target service handle matching the screen resolution and / or network bandwidth in the source service handle; A target video stream pushing module, used for acquiring a target video stream corresponding to the target service handle, and pushing the target video stream to the first terminal; Wherein, if a target service handle matching the screen resolution and / or network bandwidth is not matched in the source service handle, the source video stream corresponding to the stream identifier to be played is transcoded to obtain a transcoded video stream, and the transcoded video stream is used as the target video stream; The step of transcoding the source video stream corresponding to the stream identifier to be played to obtain a transcoded video stream includes: Acquire a source picture group included in a source video stream corresponding to the stream identifier to be played, and acquire a source key frame included in the source picture group; Acquire an immediately refreshed image IDR frame in the source key frame, and parse the IDR frame to obtain a sequence parameter set and an image parameter set included in the IDR frame; Initializing a preset transcoding function based on the sequence parameter set and the image parameter set, decompressing the source video stream based on the initialized transcoding function to obtain encapsulation format data, and decompressing the encapsulation format data to obtain audio compression data and video compression data; Performing audio decoding and video decoding on the audio compression data and the video compression data to obtain original audio data and original video data, and transcoding the original audio data and the original video data to obtain transcoded audio data and transcoded video data; The transcoded audio data and the transcoded video data are packaged to obtain the transcoded video stream.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for processing a video stream according to any one of claims 1 to 10 is implemented.
13. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the video stream processing method according to any one of claims 1 to 10 by executing the executable instructions.
Citation Information
Patent Citations
System, method and service node for providing video contents
CN103179433A
Video processing method and apparatus, mobile terminal and system
CN103379363A
Video display method and device of network studio, control method and related equipment
CN106412621A
A video stream data transmission method and device
CN109788314A
Transcoding duration estimation method and device, terminal and storage medium
CN110113660A
