CN109862403B - Adaptive code rate switching method and device, electronic equipment and storage medium - Google Patents
Adaptive code rate switching method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN109862403B CN109862403B CN201910125263.8A CN201910125263A CN109862403B CN 109862403 B CN109862403 B CN 109862403B CN 201910125263 A CN201910125263 A CN 201910125263A CN 109862403 B CN109862403 B CN 109862403B
- Authority
- CN
- China
- Prior art keywords
- current
- code rate
- video
- capacity
- capacity value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
The invention provides a self-adaptive code rate switching method, a self-adaptive code rate switching device, electronic equipment and a storage medium, wherein the method comprises the following steps: determining that the size relationship between the current network bandwidth and the current code rate of the current playing video meets a first switching condition; acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video; judging whether the difference value of the first capacity value and the second capacity value meets a second switching condition or not; if so, switching to the target code rate matched with the current network bandwidth to play the currently played video. And determining whether to perform code rate switching by judging whether the difference value between the first capacity value and the second capacity value meets a second switching condition, so that the smooth playing of the video is ensured while the bandwidth is fully utilized.
Description
Technical Field
The invention relates to the field of data processing, in particular to a self-adaptive code rate switching method, a self-adaptive code rate switching device, electronic equipment and a storage medium.
Background
The following problems exist when the video is played according to the network adaptive code rate technology at present:
due to the instability of the network state, the code rate is automatically switched under the condition of network jitter, so that the playing is not smooth, the screen is blacked, and the user experience is poor.
Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide an adaptive bitrate switching method, an adaptive bitrate switching device, an electronic device, and a storage medium, which ensure smooth playing of a video while achieving adaptive bitrate switching.
In a first aspect, an embodiment of the present invention provides a method for switching an adaptive code rate, where the method includes: determining that the current network bandwidth and the current code rate of the current playing video meet a first switching condition; acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video; judging whether the difference value of the first capacity value and the second capacity value meets a second switching condition or not; if so, switching the current code rate to a target code rate matched with the current network bandwidth to play the current playing video. When the current network bandwidth and the current code rate of a currently played video are determined to meet a first switching condition, judging whether a difference value of a first capacity value and a second capacity value meets a second switching condition, if so, switching to a target code rate matched with the current network bandwidth to play the currently played video, guaranteeing smooth playing of the video under the condition of network jitter, determining whether to switch the code rate by judging whether the difference value of the first capacity value and the second capacity value meets the second switching condition, and guaranteeing smooth playing of the video while effectively utilizing the bandwidth.
Based on the first aspect, in one possible design, the currently playing video includes a plurality of time slices, each time slice includes a plurality of frames, and switching the current bitrate to a target bitrate that matches the current network bandwidth to play the currently playing video includes: judging whether the latest frame of the currently played video downloaded based on the target code rate is a key frame or not, and acquiring a first judgment result; and when the first judgment result is yes, switching the current code rate to the target code rate at the latest frame to play the currently played video. The switching strategy based on switching at the key frame is convenient for decoding and ensures smooth video playing.
Based on the first aspect, in a possible design, before determining whether a latest frame of the currently played video downloaded based on the target bitrate is a key frame and obtaining a first determination result, the method further includes: acquiring a current time slice of the currently played video played based on the current code rate; and downloading the currently played video from the first frame of the current time slice based on the target code rate. And downloading the currently played video from the first frame of the current time slice based on the target code rate, and ensuring that the currently played video is switched to the code rate matched with the current network bandwidth in time under the condition of smooth playing.
Based on the first aspect, in a possible design, determining whether a latest frame of the currently playing video downloaded based on a target bitrate is a key frame includes: acquiring a current frame of the currently played video played based on the current code rate; judging whether the latest frame of the currently played video downloaded based on the target code rate is a frame after the current frame or not, and acquiring a second judgment result; and when the second judgment result is yes, judging whether the latest frame is a key frame. The switching strategy based on switching at the key frame is convenient for decoding and ensures smooth video playing.
Based on the first aspect, in one possible design, determining whether the difference between the first capacity value and the second capacity value satisfies a second switching condition includes: subtracting the second capacity value from the first capacity value to obtain a capacity difference value; if the difference between the current network bandwidth and the current code rate is larger than a first preset difference, judging whether the capacity difference is larger than a first preset value, and when the capacity difference is larger than the first preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition. By the method, smooth playing of the video can be guaranteed under the condition of network jitter.
Based on the first aspect, in a possible design, after subtracting the second capacity value from the first capacity value to obtain a capacity difference value, the method further includes: if the difference between the target code rate and the current network bandwidth is larger than a second preset difference, judging whether the capacity difference is smaller than a second preset value, and when the capacity difference is smaller than the second preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition. By the method, smooth playing of the video can be guaranteed under the condition of network jitter.
In a second aspect, an embodiment of the present invention provides an apparatus for switching an adaptive code rate, where the apparatus includes: the determining unit is used for determining that the current network bandwidth and the current code rate of the current playing video meet a first switching condition; the capacity acquisition unit is used for acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video; a capacity judgment unit configured to judge whether a difference between the first capacity value and the second capacity value satisfies a second switching condition; and the switching unit is used for switching to the target code rate matched with the current network bandwidth to play the current playing video if the current playing video is the video.
Based on the second aspect, in one possible design, the currently playing video includes a plurality of time slices, each time slice includes a plurality of frames, and the switching unit includes: a key frame judging unit, configured to judge whether a latest frame of the currently played video downloaded based on the target bitrate is a key frame, and obtain a first judgment result; and the switching subunit is configured to switch to the target bitrate at the latest frame to play the currently played video when the first determination result is yes.
Based on the second aspect, in one possible design, the apparatus further includes: a time slice obtaining unit, configured to obtain a current time slice of the currently playing video played based on the current code rate; and the downloading unit is used for downloading the currently played video from the first frame of the current time slice based on the target code rate.
Based on the second aspect, in a possible design, the key frame determining unit is further configured to obtain a current frame of the currently played video that is played based on the current bitrate; judging whether the latest frame of the currently played video downloaded based on the target code rate is a frame behind the current frame or not, and acquiring a second judgment result; and when the second judgment result is yes, judging whether the latest frame is a key frame.
Based on the second aspect, in a possible design, the capacity determining unit is further configured to subtract the second capacity value from the first capacity value to obtain a capacity difference value; and if the difference between the current network bandwidth and the current code rate is larger than a first preset difference, judging whether the capacity difference is larger than a first preset value, and when the capacity difference is larger than the first preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition.
Based on the second aspect, in one possible design, the apparatus further includes: and the capacity judging subunit is used for judging whether the capacity difference value is smaller than a second preset value or not if the difference between the target code rate and the current network bandwidth is larger than the second preset difference value, and representing that the difference value between the first capacity value and the second capacity value meets the second switching condition when the capacity difference value is smaller than the second preset value.
In a third aspect, an embodiment of the present invention provides a storage medium, where a computer program is stored, and when the computer program runs on a computer, the computer is caused to execute the method according to the first aspect.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating an adaptive code rate switching method according to a first embodiment of the present invention;
fig. 3 is a schematic structural diagram of an adaptive bitrate switching device according to a second embodiment of the present invention.
Icon: 100-an electronic device; 110-a memory; 120-a memory controller; 130-a processor; 140-peripheral interfaces; 150-input-output unit; 160-an audio unit; 170-a display unit; 410-a determination unit; 420-an acquisition unit; 430-capacity judging unit; 440-switching unit.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
An embodiment of the present invention provides a schematic structural diagram of an electronic device 100, where the electronic device 100 may be a Personal Computer (PC), a tablet PC, a smart phone, a Personal Digital Assistant (PDA), or the like.
As shown in fig. 1, the electronic device 100 may include: an adaptive bitrate switching device, a memory 110, a memory controller 120, a processor 130, a peripheral interface 140, an input-output unit 150, an audio unit 160, and a display unit 170.
The memory 110, the memory controller 120, the processor 130, the peripheral interface 140, the input/output unit 150, the audio unit 160, and the display unit 170 are electrically connected to each other directly or indirectly, so as to implement data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The display device of the quality detection result includes at least one software functional module which can be stored in the memory 110 in the form of software or firmware (firmware) or solidified in an operating device (OS) of the client device. The processor 130 is used to execute executable modules stored in the memory 110, such as software functional modules or computer programs included in the adaptive code rate switching device.
The Memory 110 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 110 is configured to store a program, and the processor 130 executes the program after receiving an execution instruction, and the method executed by the electronic device 100 defined by the flow disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 130, or implemented by the processor 130.
The processor 130 may be an integrated circuit chip having signal processing capabilities. The Processor 130 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The peripheral interface 140 couples various input/output devices to the processor 130 and to the memory 110. In some embodiments, peripheral interface 140, processor 130, and memory controller 120 may be implemented in a single chip. In other examples, they may be implemented separately from the individual chips.
The input and output unit 150 is used for providing input data to the user to realize the interaction of the user with the electronic device 100. The input/output unit 150 may be, but is not limited to, a mouse, a keyboard, and the like.
The display unit 170 provides an interactive interface (e.g., a user operation interface) between the electronic device 100 and a user or is used to display image data to a user reference. In this embodiment, the display unit 170 may be a liquid crystal display or a touch display. In the case of a touch display, the display can be a capacitive touch screen or a resistive touch screen, which supports single-point and multi-point touch operations. Supporting single-point and multi-point touch operations means that the touch display can sense touch operations from one or more locations on the touch display at the same time, and the sensed touch operations are sent to the processor 130 for calculation and processing.
First embodiment
Referring to fig. 2, fig. 2 is a flowchart of a method for adaptive code rate switching according to a first embodiment of the present invention, the method is applied to the electronic device 100 shown in fig. 1, and the flowchart shown in fig. 2 will be described in detail below, where the method includes:
s100: and determining that the current network bandwidth and the current code rate of the current playing video meet a first switching condition.
The bit rate is also called bit rate, and indicates how many bits are needed for each second of video data after compression encoding, that is, the data amount after compressing the image displayed per second, and the unit adopted is generally kbps, namely kilobits per second. The higher the code rate, the less the loss of picture quality and the closer the resulting picture is to the original picture.
Network bandwidth refers to the amount of data that can be transmitted in a unit of time (typically referred to as 1 second). The network is similar to a highway, and the larger the bandwidth is, the more lanes are similar to the highway, and the higher the traffic capacity is. Network bandwidth is an important indicator for measuring network characteristics.
It can be understood that the higher the current bitrate, the higher the required network bandwidth, and if the current network bandwidth cannot support the current bitrate, the video pictures may be delayed or lost.
Therefore, when a video is played on a video website, in order to achieve adaptive switching of code rates and ensure smooth playing of the video, it is necessary to obtain a current network bandwidth and a current code rate of the currently played video in real time and determine whether the current network bandwidth is matched with the current code rate. The preset difference may be 10, 20, 25, 80, 100, and the like, and in this embodiment, the preset difference is 25. In the embodiment, it is determined whether the current network bandwidth is equal to the current bitrate, and when it is determined that the current network bandwidth is not equal to the current bitrate, it is determined that the current network bandwidth and the current bitrate satisfy a first handover condition. Determining that the current network bandwidth and the current code rate do not satisfy a first handover condition when it is determined that the current network bandwidth is equal to the current code rate.
For example, in example 1, at a current network bandwidth of 1024kbps, a current bitrate is 720kbps, and therefore, the current network bandwidth is not matched with the current bitrate, it is determined that the current network bandwidth and the current bitrate satisfy a first switching condition, and the current bitrate needs to be switched to a bitrate higher than the current bitrate, that is, a bitrate matched with the current network bandwidth; example 2, when the current network bandwidth is 780kbps, the current code rate is 1028kbps, and therefore the current network bandwidth is not matched with the current code rate, it is determined that the current network bandwidth and the current code rate satisfy the first switching condition, and the current code rate needs to be switched to a code rate lower than the current code rate, that is, a code rate matched with the current network bandwidth. Example 3, at a current network bandwidth of 1024kbps, a current code rate is 1024kbps, and therefore, the current network bandwidth is matched with the current code rate, and it is determined that the current network bandwidth and the current code rate do not satisfy a first switching condition, and no code rate switching is performed. As a value, when the first switching condition is satisfied, the rate switching is not performed immediately, but S200 is continuously performed.
S200: and acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video.
When the current network bandwidth and the current code rate of the current playing video are determined to meet a first switching condition, and the current playing video is an A video, a first capacity value representing the cache progress of the A video and a second capacity value representing the playing progress of the A video are obtained. In this embodiment, the first capacity value and the second capacity value may be expressed by time, for example, the total duration of the a video is 30 minutes, at the current time, the a video has been buffered for 10 minutes, and the a video has been played for 5 minutes, so that the first capacity value is 10 minutes and the second capacity value is 5 minutes, in other embodiments, the first capacity value and the second capacity value may be expressed by a time ratio, that is, the first capacity value is 1/3 and the second capacity value is 1/6.
S300: and judging whether the difference value of the first capacity value and the second capacity value meets a second switching strip.
As an embodiment, S300 includes:
and subtracting the second capacity value from the first capacity value to obtain a capacity difference value.
For example, when the first capacity value is 10 minutes and the second capacity value is 5 minutes, the capacity difference is 5 minutes by subtracting the second capacity value from the first capacity value.
If the difference between the current network bandwidth and the current code rate is larger than a first preset difference, judging whether the capacity difference is larger than the first preset value, and when the capacity difference is larger than the first preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition.
By the method, the code rate can be prevented from being switched at will under the condition of network jitter, smooth playing of the video is guaranteed, and waste of network bandwidth is avoided.
Wherein the first preset difference may be 0, 10, 20, 100, 200, etc., in this embodiment, the first preset difference is 100, for example, when the current network bandwidth is 1024kbps, when the current code rate is 724kbps, the difference between the current network bandwidth and the current code rate is 1024kbps-724 kbps-300, since 300 is greater than a first preset difference value, it is determined that the difference between the current network bandwidth and the current code rate is greater than the first preset difference value, it is determined whether the capacity difference value is greater than the first preset value, wherein the first preset value can be 2 minutes, 3 minutes, 5 minutes, 6 minutes, etc., in this embodiment, the first preset value is 3 minutes, since the capacity difference is 5 minutes, the capacity difference (5 minutes) is greater than a first preset value (3 minutes), indicating that the difference between the first capacity value and the second capacity value satisfies the second switching condition. As an implementation manner, when the capacity difference is less than or equal to a first preset value, it is characterized that the difference between the first capacity value and the second capacity value does not satisfy the second switching condition, and no code rate switching is performed.
As an embodiment, after subtracting the second capacity value from the first capacity value to obtain a capacity difference value, the method further includes:
if the difference between the current code rate and the current network bandwidth is larger than a second preset difference, judging whether the capacity difference is smaller than a second preset value, and representing that the difference between the first capacity value and the second capacity value meets the second switching condition when the capacity difference is smaller than the second preset value.
By the method, the code rate can be prevented from being switched at will under the condition of network jitter, smooth playing of the video is guaranteed, and waste of network bandwidth is avoided.
Wherein the second preset difference may be 0, 10, 20, 100, 200, etc., where the second preset difference may be equal to the first preset difference, and the second preset difference may also be different from the first preset difference, in this embodiment, the second preset difference is 100, for example, when the current network bandwidth is 800kbps and the current code rate is 1028kbps, the difference between the current code rate and the current network bandwidth is 1028kbps-800 kbps-228 kbps, and since 228kbps is greater than the second preset difference 100, it is determined that the difference between the current code rate and the current network bandwidth is greater than the second preset difference, and whether the capacity difference is smaller than a second preset value is determined, where the second preset value may be 1 minute, 2 minutes, 3 minutes, 5 minutes, etc., in this embodiment, the second preset value is 1 minute, if the capacity difference is 1 minute, and therefore, the capacity difference (1 minute) is smaller than a second preset value (2 minutes), it is characterized that the difference between the first capacity value and the second capacity value satisfies the second switching condition. As an implementation manner, when the capacity difference is greater than or equal to a second preset value, it is characterized that the difference between the first capacity value and the second capacity value does not satisfy the second switching condition, and no code rate switching is performed.
S400: if so, switching to the target code rate matched with the current network bandwidth to play the currently played video.
Wherein the currently played video includes a plurality of time slices, each time slice includes a plurality of frames, for example, the total duration of the a video is 20 minutes, the a video is divided into 20 time slices, each time slice is 1 minute, each time slice includes 20 frames, where the division manner of the time slices is not limited, and the number of frames included in each time slice is not limited, S400 includes:
s410: and acquiring the current time slice of the current playing video played based on the current code rate.
For example, when the current bitrate is 720kbps and the currently played video is the a video, the a video has been played to the 5 th frame of the 10 th minute at the current time, and the current time slice is the 10 th time slice. At the current time, when the a video has been played to the 4 th frame of the 15 th minute, the current time slice is the 15 th time slice.
As an implementation manner, a current frame of a current time slice of the currently playing video played based on the current bitrate is obtained. For example, when a video has been played to the 4 th frame of the 15 th minute at the current time, the current frame of the current time slice is the 4 th frame of the 15 th time slice.
S420: and downloading the currently played video from the first frame of the current time slice based on the target code rate.
And when the current bitrate is 720kbps and the target bitrate is 1080kbps and the current time slice is the 10 th time slice, downloading the video A from the first frame of the 10 th time slice based on the target bitrate of 1080 kbps.
By the method, the code rate matched with the current network bandwidth can be timely switched to under the condition of smooth playing.
As an embodiment, based on the target bitrate, the currently playing video is downloaded from the current frame of the current time slice.
When the current bitrate is 720kbps and the target bitrate is 1080kbps, the current frame of the current time slice is the 4 th frame of the 15 th time slice, and the video a is downloaded from the fourth frame of the 15 th time slice based on the target bitrate of 1080 kbps.
S430: and judging whether the latest frame of the currently played video downloaded based on the target code rate is a key frame or not, and acquiring a first judgment result.
For example, the video a is downloaded based on the target bitrate, and when the video a is downloaded to the 10 th frame of the 15 th time slice at the current time, the latest frame is the 10 th frame of the 15 th time slice, and whether the 10 th frame is a key frame is determined, so as to obtain a first determination result.
As an embodiment, S430 includes:
and acquiring the current frame of the currently played video played based on the current code rate.
For example, when the current bitrate is 720kbps at the current time and a video has been played to the 4 th frame of the 15 th minute, the current frame is the 4 th frame of the 15 th time slice.
And judging whether the latest frame of the currently played video downloaded based on the target code rate is a frame after the current frame or not, and acquiring a second judgment result.
And when the second judgment result represents that the latest frame is a frame after the current frame, judging whether the latest frame is a key frame.
In an embodiment, when the second determination result is negative, it is characterized that the latest frame is not a frame after the current frame, and therefore, rate switching is not performed.
In example 1, since the current frame is the 12 th frame of the 15 th time slice and the latest frame is the 10 th frame of the 15 th time slice, the latest frame is not a frame subsequent to the current frame and rate switching is not performed.
Example 2, when the current frame is the 13 th frame of the 15 th time slice, the latest frame is the 14 th frame of the 15 th time slice, and thus the latest frame is a frame subsequent to the current frame.
S440: and when the first judgment result is yes, switching to the target code rate at the latest frame to play the currently played video.
When the latest frame is a frame after the current frame and the latest frame is a key frame, switching the current bitrate to the target bitrate at the latest frame to play the currently played video.
In one embodiment, when the first determination result is negative, no rate switching is performed.
The switching strategy based on switching at the key frame ensures normal decoding, and then ensures that the code rate matched with the current network bandwidth can be switched in time under the condition of smooth video playing, and the random switching of the code rate under the condition of network jitter can be avoided.
For example, when the current frame is the 13 th frame of the 15 th time slice, the latest frame is the 15 th frame of the 15 th time slice, and therefore, the latest frame is the frame after the current frame, and the 15 th frame is the key frame, and therefore, the current bitrate is switched to the target bitrate at the 15 th frame to play the currently played video, it can be understood that, after the 15 th frame and the 15 th frame, the currently played video is played with the video data downloaded based on the target bitrate.
As an embodiment, when the second determination result indicates that the latest frame is a frame after the current frame, the current bitrate is switched to a target bitrate matched with the current network bandwidth to play the currently played video.
By the mode, the code rate can be prevented from being switched at will under the condition of network jitter, smooth playing of the video is guaranteed, and waste of network bandwidth is avoided.
When adaptive code rate switching is realized based on a real-time Streaming media protocol (HTTP Live Streaming, HLS), in order to ensure smooth playing, switching to an appropriate code rate can be performed as quickly as possible, and therefore, a switching strategy based on a key frame is adopted. The HLS protocol requires that each time slice starts with a key frame, and requires that the decoder be able to reinitialize the decoder through the metadata information carried by the I frame, and decode at the key frame, so as to ensure the normal decoding of the subsequent frame.
Configuration of MediaC13odec decoder
After the buffer data of the HyperText Transfer protocol (HTTP) download module reaches a threshold, the audio unit 160 and the video unit 170 start playing the video. The decoding and playing mainly comprises the following three steps:
1. when decoding the video in the buffer, the electronic device 100 reads the file header of the time slice of the downloaded video, obtains format information (encoding format, resolution, code rate) of the video, and initializes a corresponding decoder according to the format information.
2. The electronic device 100 extracts the video data from the buffer and transmits the video data to a decoder for decoding.
3. Finally, the decoded content is transmitted to the display unit 170 of the electronic device 100, and the video picture is displayed through the display unit 170. The audio playing thread in the audio unit 160 is independent of the video playing thread, but the video timestamp and the audio frame timestamp need to be synchronized to achieve the effect of audio and video synchronization.
Second embodiment
Referring to fig. 3, fig. 3 is a block diagram illustrating an adaptive bitrate switching device according to a second embodiment of the present invention. The apparatus is stored in the electronic device 100 shown in fig. 1, and the block diagram shown in fig. 3 is described below, and the apparatus includes:
a determining unit 410, configured to determine that a current network bandwidth and a current bitrate of a currently played video satisfy a first switching condition;
a capacity obtaining unit 420, configured to obtain a first capacity value representing a cache progress of the currently playing video and a second capacity value representing a playing progress of the currently playing video;
a capacity judging unit 430, configured to judge whether a difference between the first capacity value and the second capacity value satisfies a second switching condition;
and if yes, switching to the target code rate matched with the current network bandwidth to play the currently played video.
As an embodiment, the currently playing video includes a plurality of time slices, each time slice includes a plurality of frames, and the switching unit 440 includes: a key frame judging unit, configured to judge whether a latest frame of the currently played video downloaded based on the target bitrate is a key frame, and obtain a first judgment result; and the switching subunit is configured to switch to the target bitrate at the latest frame to play the currently played video when the first determination result is yes.
As an embodiment, the apparatus further comprises: a time slice obtaining unit, configured to obtain a current time slice of the currently playing video played based on the current code rate; and the downloading unit is used for downloading the currently played video from the first frame of the current time slice based on the target code rate.
As an implementation manner, the key frame determining unit is further configured to obtain a current frame of the currently playing video that is played based on the current code rate; judging whether the latest frame of the currently played video downloaded based on the target code rate is a frame behind the current frame or not, and acquiring a second judgment result; and when the second judgment result is yes, judging whether the latest frame is a key frame.
In an embodiment, the capacity determining unit 430 is further configured to subtract the second capacity value from the first capacity value to obtain a capacity difference value; and if the difference between the current network bandwidth and the current code rate is larger than a first preset difference, judging whether the capacity difference is larger than a first preset value, and when the capacity difference is larger than the first preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition.
As an embodiment, the apparatus further comprises: and the capacity judging subunit is used for judging whether the capacity difference value is smaller than a second preset value or not if the difference between the target code rate and the current network bandwidth is larger than the second preset difference value, and representing that the difference value between the first capacity value and the second capacity value meets the second switching condition when the capacity difference value is smaller than the second preset value.
In this embodiment, please refer to the content described in the embodiment shown in fig. 2 for the process of implementing each function of each functional unit of the adaptive bitrate switching device, which is not described herein again.
In addition, an embodiment of the present invention further provides a storage medium, where a computer program is stored in the storage medium, and when the computer program runs on a computer, the computer is caused to execute the adaptive code rate switching method provided in any embodiment of the present invention.
In summary, the adaptive code rate switching method, apparatus, electronic device and storage medium provided in the embodiments of the present invention include: determining that the current network bandwidth and the current code rate of the current playing video meet a first switching condition; acquiring a first capacity value representing the current playing video cache progress and a second capacity value representing the current playing video playing progress; judging whether the difference value of the first capacity value and the second capacity value meets a second switching condition or not; if so, switching the current code rate to a target code rate matched with the current network bandwidth to play the current playing video. When the current network bandwidth and the current code rate of the currently played video are determined to meet a first switching condition, judging whether the difference value of the first capacity value and the second capacity value meets a second switching condition, if so, switching the current code rate to a target code rate matched with the current network bandwidth to play the currently played video, and if not, not switching the code rate, so that the random code rate switching under the condition of network jitter can be avoided, the smooth playing of the video is ensured, and the waste of the network bandwidth is avoided.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based devices that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
Claims (7)
1. A method for adaptive code rate switching, the method comprising:
determining that the size relationship between the current network bandwidth and the current code rate of the current playing video meets a first switching condition;
acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video;
judging whether the difference value of the first capacity value and the second capacity value meets a second switching condition or not;
if yes, switching to a target code rate matched with the current network bandwidth to play the current playing video;
the currently playing video comprises a plurality of time slices, each time slice comprises a plurality of frames, and the currently playing video is switched to the target code rate matched with the current network bandwidth to play, wherein the method comprises the following steps: judging whether the latest frame of the currently played video downloaded based on the target code rate is a key frame or not, and acquiring a first judgment result; when the first judgment result is yes, switching to the target code rate at the latest frame to play the currently played video;
before determining whether the latest frame of the currently played video downloaded based on the target bitrate is a key frame and obtaining a first determination result, the method further includes: acquiring a current time slice of the currently played video played based on the current code rate; and downloading the currently played video from the first frame of the current time slice based on the target code rate.
2. The method of claim 1, wherein determining whether a latest frame of the currently playing video downloaded based on the target bitrate is a key frame comprises:
acquiring a current frame of the currently played video played based on the current code rate;
judging whether the latest frame of the currently played video downloaded based on the target code rate is a frame after the current frame or not, and acquiring a second judgment result;
and when the second judgment result is yes, judging whether the latest frame is a key frame.
3. The method of claim 1, wherein determining whether a difference between the first capacity value and the second capacity value satisfies a second handover condition comprises:
subtracting the second capacity value from the first capacity value to obtain a capacity difference value;
if the difference between the current network bandwidth and the current code rate is larger than a first preset difference, judging whether the capacity difference is larger than a first preset value, and when the capacity difference is larger than the first preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition.
4. The method of claim 1, wherein after subtracting the second capacity value from the first capacity value to obtain a capacity difference value, the method further comprises:
if the difference between the target code rate and the current network bandwidth is larger than a second preset difference, judging whether the capacity difference is smaller than a second preset value, and when the capacity difference is smaller than the second preset value, representing that the difference between the first capacity value and the second capacity value meets the second switching condition.
5. An adaptive bitrate switching apparatus, the apparatus comprising:
the determining unit is used for determining that the current network bandwidth and the current code rate of the current playing video meet a first switching condition;
the capacity acquisition unit is used for acquiring a first capacity value representing the cache progress of the currently played video and a second capacity value representing the play progress of the currently played video;
a capacity judgment unit configured to judge whether a difference between the first capacity value and the second capacity value satisfies a second switching condition;
the switching unit is used for switching to a target code rate matched with the current network bandwidth to play the current playing video if the current playing video is the video;
the currently playing video includes a plurality of time slices, each time slice including a plurality of frames, the switching unit includes: a key frame judging unit, configured to judge whether a latest frame of the currently played video downloaded based on the target bitrate is a key frame, and obtain a first judgment result; a switching subunit, configured to switch to the target bitrate at the latest frame to play the currently played video when the first determination result is yes;
the device further comprises: a time slice obtaining unit, configured to obtain a current time slice of the currently playing video played based on the current code rate; and the downloading unit is used for downloading the currently played video from the first frame of the current time slice based on the target code rate.
6. An electronic device, comprising a processor and a memory coupled to the processor, the memory storing a computer program that, when executed by the processor, causes the electronic device to perform the method of any of claims 1-4.
7. A storage medium, in which a computer program is stored which, when run on a computer, causes the computer to carry out the method according to any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910125263.8A CN109862403B (en) | 2019-02-19 | 2019-02-19 | Adaptive code rate switching method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910125263.8A CN109862403B (en) | 2019-02-19 | 2019-02-19 | Adaptive code rate switching method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109862403A CN109862403A (en) | 2019-06-07 |
CN109862403B true CN109862403B (en) | 2021-07-27 |
Family
ID=66898311
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910125263.8A Active CN109862403B (en) | 2019-02-19 | 2019-02-19 | Adaptive code rate switching method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109862403B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110267100B (en) * | 2019-07-12 | 2022-01-25 | 北京达佳互联信息技术有限公司 | Code rate switching method and device for FLV (flash video), electronic equipment and storage medium |
CN110430453B (en) * | 2019-08-28 | 2022-03-25 | 咪咕视讯科技有限公司 | Video multi-code-rate switching processing method and device, electronic equipment and storage medium |
CN110636346B (en) * | 2019-09-19 | 2021-08-03 | 北京达佳互联信息技术有限公司 | Code rate self-adaptive switching method and device, electronic equipment and storage medium |
CN110933517B (en) * | 2019-11-30 | 2022-04-29 | 咪咕视讯科技有限公司 | Code rate switching method, client and computer readable storage medium |
CN112087646B (en) * | 2020-08-26 | 2023-01-17 | 深圳市雅阅科技有限公司 | Video playing method and device, computer equipment and storage medium |
CN112822521B (en) * | 2020-12-30 | 2023-04-25 | 百果园技术(新加坡)有限公司 | Code rate control method, device, equipment and storage medium for audio and video transmission |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP2046044A1 (en) * | 2007-10-01 | 2009-04-08 | Cabot Communications Ltd | A method and apparatus for streaming digital media content and a communication system |
CN101771492A (en) * | 2008-12-29 | 2010-07-07 | 华为技术有限公司 | Method and device for adjusting streaming media bit rate |
CN103002272A (en) * | 2011-09-15 | 2013-03-27 | 上海聚力传媒技术有限公司 | Method, device and equipment for switching code rate of audio and video information |
CN103561283A (en) * | 2013-10-30 | 2014-02-05 | 乐视致新电子科技(天津)有限公司 | Method and device for code rate switch of smart television |
CN108055250A (en) * | 2017-12-01 | 2018-05-18 | 暴风集团股份有限公司 | Video play device, method and terminal |
CN108924667A (en) * | 2018-08-03 | 2018-11-30 | 阳雨哲 | A kind of maximized available bandwidth adaptive video fragment request method of support QoE |
-
2019
- 2019-02-19 CN CN201910125263.8A patent/CN109862403B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP2046044A1 (en) * | 2007-10-01 | 2009-04-08 | Cabot Communications Ltd | A method and apparatus for streaming digital media content and a communication system |
CN101771492A (en) * | 2008-12-29 | 2010-07-07 | 华为技术有限公司 | Method and device for adjusting streaming media bit rate |
CN103002272A (en) * | 2011-09-15 | 2013-03-27 | 上海聚力传媒技术有限公司 | Method, device and equipment for switching code rate of audio and video information |
CN103561283A (en) * | 2013-10-30 | 2014-02-05 | 乐视致新电子科技(天津)有限公司 | Method and device for code rate switch of smart television |
CN108055250A (en) * | 2017-12-01 | 2018-05-18 | 暴风集团股份有限公司 | Video play device, method and terminal |
CN108924667A (en) * | 2018-08-03 | 2018-11-30 | 阳雨哲 | A kind of maximized available bandwidth adaptive video fragment request method of support QoE |
Also Published As
Publication number | Publication date |
---|---|
CN109862403A (en) | 2019-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109862403B (en) | Adaptive code rate switching method and device, electronic equipment and storage medium | |
ES2624910T3 (en) | Client side sequence switching | |
CN110636346B (en) | Code rate self-adaptive switching method and device, electronic equipment and storage medium | |
CN110121100B (en) | Method, device, terminal and computer readable storage medium for downloading media file | |
EP3148199A1 (en) | Online video intelligent playing method, system, player and mobile terminal | |
WO2021031850A1 (en) | Image processing method and apparatus, electronic device and storage medium | |
CN105163134A (en) | Video coding parameter setting method, device and video coding device for live video | |
US20240173631A1 (en) | Dynamic allocation of compute resources for highlight generation in cloud gaming systems | |
MXPA04006412A (en) | Sparse caching for streaming media. | |
US20150081924A1 (en) | Streaming Media | |
CN106415520B (en) | The system and method for the predictive delivering of high code rate content for playback | |
EP3135019B1 (en) | Method and system for bandwidth-dependent file transfer | |
US20140281994A1 (en) | Interactive method, terminal device and system for communicating multimedia information | |
US20140297883A1 (en) | Method and apparatus for altering bandwidth consumption | |
CN112399123A (en) | Video definition adjusting method and device, electronic equipment and storage medium | |
CN111510770A (en) | Method and device for switching definition, computer equipment and readable storage medium | |
US20140362291A1 (en) | Method and apparatus for processing a video signal | |
JP2024528388A (en) | System and method for providing optimized time scales and accurate presentation time stamps - Patents.com | |
JP7162019B2 (en) | DATA STREAMING METHOD, DATA STREAMING DEVICE, AND COMPUTER PROGRAM | |
US20040083488A1 (en) | Receiving apparatus, data communication system, and method for data communication | |
CN105471850A (en) | Video uploading method and video uploading device | |
CN112911390B (en) | Video data playing method and terminal equipment | |
CN114244843A (en) | Streaming media downloading method, electronic equipment and storage medium | |
CN115190359A (en) | Automatic conversion method and system for video playing format | |
CN113473248B (en) | Streaming media transmission method, device and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |