Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
The embodiment of the invention mainly aims at the problems that the downloading code rate of each segmented video is continuously changed along with the network bandwidth due to the fact that the change of the network bandwidth cannot be judged, so that the smoothness of video playing is low, and playing is easy to block.
Fig. 1 is a scene architecture diagram of an application scene to which a video downloading and playing method according to an embodiment of the present invention is applied. Specifically, referring to fig. 1, the application scenario may include aclient 10 and aresource server 20.
Theclient 10 is configured with various video software for downloading and playing videos, such as a player application program supporting live broadcast or video-on-demand, and the user requests theresource server 20 to download a corresponding video by executing a corresponding operation of live broadcast participation or video-on-demand on theclient 10; theresource server 20 is any file server which stores the video data uploaded by each user in a segmented manner by adopting an HTTP protocol, theresource server 20 segments the video data uploaded by any user according to a preset duration, sets a downloading sequence of different segmented videos, and transcodes and encodes each segmented video after segmentation by adopting multiple code rates, so that each segmented video corresponds to multiple code rates for a client to select downloading.
Specifically, theclient 10 requests theresource server 20 to download the corresponding video in segments according to the downloading or playing operation performed on the video by the user, at this time, theresource server 20 first sends the segmentation order of the corresponding video and the playing state information of each segmented video to theclient 10 to initialize the player state in theclient 10, at this time, when the client downloads the current segmented video and requests to download the next segmented video, the client adaptively selects the downloading bitrate most suitable for the current network state in the bitrate gear corresponding to the next segmented video according to the remaining cache length in the player state and the segmented playing duration of the next segmented video in the video playing process, and further requests theresource server 20 to download the next segmented video at the downloading bitrate; theresource server 20 then finds out the next video segment at the downloading code rate and sends the next video segment to theclient 10; theclient 10 subsequently and directly plays each segmented video at different download code rates after downloading, ensures the download definition of the segmented video on the basis of fully utilizing the network state, realizes the self-adaptive segmented downloading of the video at different code rates, and improves the fluency of video playing.
The specific operations of theclient 10 to download and play the video according to the embodiment of the present invention can be explained in detail in the following methods for downloading and playing the video, and are not specifically described herein.
Example one
Fig. 2A is a flowchart of a video downloading method according to an embodiment of the present invention, where the embodiment is applicable to a case where live webcasting or video-on-demand playing is performed through any player. The method for downloading a video provided by this embodiment may be executed by the apparatus for downloading a video provided by the embodiment of the present invention, the apparatus may be implemented in a software and/or hardware manner, and is integrated into a device for executing the method, the device may be a client configured with any video application for live network broadcast or video on demand, and the client may be any intelligent terminal such as a mobile phone, a tablet computer, or a notebook computer.
Specifically, referring to fig. 2A, the method may include the steps of:
s210, determining the residual cache length after the current segmented video is downloaded and the segmented playing time length of the next segmented video to be downloaded.
Specifically, in this embodiment, mainly aiming at the problem that when the code rate corresponding to the current network bandwidth is selected to download each segmented video, the code rates of different segmented videos are caused to change continuously along with the network bandwidth, so that the fluency of video playing is low and playing is blocked, firstly, any video uploaded by a user is stored in a resource server in a segmented manner in the resource server, for example, the user broadcasts the uploaded video in a live manner, records and shares small videos or various movie and video works and the like to other users, the resource server segments each video according to a preset duration, and re-encodes each segmented video by adopting various preset code rates, and at this time, each segmented video in any video has various code rate gears for the client to select to download.
In this embodiment, when a client plays any video, the client first requests the resource server to download the video, and since the resource server stores the video in segments, in order to ensure the downloading integrity of the video, the resource server first issues metadata corresponding to the video to the client, where the metadata may include the sequence of the segments in the video and the playing attribute information of each segment of the video, such as the segment playing duration, the segment playing start-stop timestamp, and the like of each segment of the video; at this time, the client may initialize a player configured by itself according to the metadata of the video, that is, the position of each segmented video included in the video requested to be downloaded and played this time is set in the player in advance according to the segmentation order and the segmented playing time length of each segmented video, so as to update the player state in the video playing process in real time.
In addition, since the client caches the downloaded segmented video through the preset cache region, the remaining cache length of the cache region also affects the downloading efficiency of the next segmented video, so that the remaining cache length of the cache region after the currently downloaded segmented video is stored is correspondingly recorded every time a segmented video is downloaded, thereby updating the player state in the video playing process.
Optionally, in order to ensure the downloading efficiency of the segmented video, in this embodiment, when the current segmented video is downloaded and the next segmented video needs to be downloaded, the current player state is firstly queried, that is, the remaining cache length for storing the next segmented video in the cache region after the current segmented video is downloaded and the segmented playing time of the next segmented video to be downloaded are determined, so that the current downloading network environment can be fully utilized in the following process.
And S220, adaptively selecting the downloading code rate which best meets the current network state in the code rate gear corresponding to the next segmented video according to the residual cache length and the segmented playing time length.
Specifically, the current network state is a network transmission state at the current moment corresponding to the time when the client terminal finishes downloading the current segmented video and requests to download the next segmented video, so that the current network transmission environment is fully utilized when the next segmented video is downloaded, and the playing pause caused by overlong downloading time is prevented; when the resource server side stores the uploaded videos in a segmented mode, the resource server side encodes each segmented video again by adopting multiple preset code rates, each segmented video has multiple code rate gears for the client side to select downloading, when the segmented video is requested to be downloaded, the resource server side issues the multiple code rate gears corresponding to each segmented video to the client side in advance, and the client side selects and downloads the segmented video under the corresponding code rate gears.
Optionally, after determining the corresponding remaining buffer length and the corresponding segment playing time length when downloading the next segment video, the remaining buffer length and the segment playing time length of the buffer area may also have a certain influence on the video downloading efficiency, for example, when the remaining buffer length is small, the video downloading may be slow due to the excessively large stored capacity; at the moment, the current network state of the current moment when the next segmented video needs to be downloaded is considered, and meanwhile, the influence of the residual cache length and the segmented playing time length on the downloading efficiency is additionally considered, so that the downloading code rate which is most suitable for the current network state is selected in a plurality of code rate gears corresponding to the next segmented video in a self-adaptive mode, and the downloading efficiency of the next segmented video can reach the highest; if the residual cache length is large, the video can be rapidly downloaded, at this time, a download code rate which is properly higher than that in the current network state can be selected from multiple code rate gears of the next segmented video to serve as the code rate of the next segmented video, and at this time, the download code rate can ensure the definition of the next segmented video to the greatest extent on the basis of fully utilizing the current network transmission environment.
For example, in this embodiment, in order to improve the efficiency of network transmission, the current network state of downloading the next segment of video needs to be accurately analyzed, and at this time, on the basis of considering the network bandwidth, the influence of network delay needs to be further considered, so the network state in this embodiment may include two types, namely network bandwidth and network delay; at this time, as shown in fig. 2B, before adaptively selecting the download bitrate most suitable for the current network state in the bitrate gear corresponding to the next segmented video according to the remaining buffer length and the segmented playing time, this embodiment may further include: and determining the next bandwidth parameter and the next delay parameter in the current network state corresponding to the next segmented video when downloading according to the network bandwidth and the network delay of the current segmented video when downloading.
Specifically, when the current segmented video is downloaded and the next segmented video is requested to be downloaded, in order to be able to adaptively select the download code rate most conforming to the current network state, the network state at the current time needs to be judged first, at this time, after the current segmented video is downloaded, the estimated download network state and the actual download network state corresponding to the current segmented video can be obtained when the current segmented video is downloaded, and further, according to the estimated download network state and the actual download network state corresponding to the current segmented video, that is, the network bandwidth and the network delay of the current segmented video during downloading, the next bandwidth parameter and the next delay parameter in the current network state corresponding to the next segmented video during downloading are estimated, so that the network transmission condition of the next segmented video during downloading can be accurately judged by comprehensively analyzing the next bandwidth parameter and the next delay parameter, therefore, on the basis of the current network transmission condition of the next segmented video, plus the positive or negative influence of the segmented playing time length and the residual cache length, the downloading code rate which is most suitable for the current network state in the next segmented video is determined, and at the moment, on the basis of fully utilizing the network transmission, the downloading definition of the next segmented video is improved as much as possible.
And S230, downloading the next segmented video according to the determined downloading code rate.
Optionally, after determining the download code rate of the next segmented video, directly requesting the resource server for the next segmented video which is included in the next segmented video at multiple code rates and is re-encoded by the download code rate, so that the client downloads the next segmented video at the download code rate in the resource server.
For example, as shown in fig. 2B, in this embodiment, downloading the next segment of video according to the determined download code rate may specifically include: sending a downloading request for the next segmented video to a resource server; and receiving the next section of video at the downloading code rate, which is transmitted by the resource server.
Wherein, the downloading request carries the downloading code rate of the next segmented video; specifically, after determining the download code rate of the next segmented video, the client generates a download request for the next segmented video according to the download code rate, and sends the download request to the resource server, the resource server selects the next segmented video with the download code rate in multiple code rate gears corresponding to the next segmented video and sends the next segmented video to the client, and the client receives the next segmented video with the download code rate sent by the resource server and completes the download of the next segmented video.
The technical solution provided in this embodiment is to determine the remaining buffer length after downloading the current segmented video and the segmented playing time of the next segmented video, and then adaptively select the downloading bitrate most suitable for the current network state in the bitrate gear corresponding to the next segmented video according to the remaining buffer length and the segmented playing time, download the next segmented video according to the downloading bitrate, and at this time, consider the playing states of the segments and the real-time downloading network state at the same time, ensure the segmented downloading of different segmented videos at the adaptive bitrate, avoid the problem that the downloading bitrate of the next segmented video is determined only according to the network bandwidth of the historical segmented video in the prior art, so that the bitrate of each segmented video is changed continuously, and the playing is blocked, and the scheme can select the appropriate downloading bitrate for the next segmented video by better utilizing the real-time downloading network state according to the remaining buffer length and the segmented playing time in the player state, on the basis of fully utilizing the current network state, the downloading definition of the segmented video is improved.
Example two
Fig. 3A is a flowchart of a video downloading method according to a second embodiment of the present invention, and fig. 3B is a schematic diagram of a video downloading process according to the second embodiment of the present invention. The present embodiment is optimized based on the above embodiments, and the present embodiment mainly explains a specific determination process of the download code rate of the next segment of video in detail.
Optionally, as shown in fig. 3A, this embodiment may include the following steps:
s310, determining the residual cache length after the current segmented video is downloaded and the segmented playing time length of the next segmented video to be downloaded.
S320, according to the network bandwidth and the network delay of the current segmented video during downloading, determining the next bandwidth parameter and the next delay parameter in the current network state corresponding to the next segmented video during downloading.
And S330, determining a code rate reference gear meeting the preset conditions in the code rate gear corresponding to the next segmented video according to the next bandwidth parameter, the next delay parameter and the segmented playing time length.
Optionally, when the videos are stored in segments in the resource server, multiple code rates are adopted in advance to re-encode each segmented video, so that each segmented video corresponds to multiple code rate gears. At this time, when the current segmented video is downloaded and the next segmented video needs to be downloaded, in order to ensure accurate downloading of the next segmented video, the preset condition in this embodiment is set to be that the actual downloading bandwidth in the multiple-bitrate gears is less than or equal to the network bandwidth of the next segmented video, so as to ensure the bitrate gear for fast downloading of the next segmented video, at this time, first, according to the next bandwidth parameter, the next delay parameter and the segmented playing time length of the next segmented video, the relationship between the next bandwidth parameter and the actual downloading bandwidth corresponding to the multiple-bitrate gears is judged, and then, the bitrate reference gear of the next segmented video meeting the preset condition is determined in the multiple-bitrate gears, so that the downloading bitrate most suitable for current network transmission is continuously determined in the bitrate reference gear subsequently.
For example, as shown in fig. 3B, in this embodiment, determining, according to the next bandwidth parameter, the next delay parameter, and the segment playing time, a bitrate reference gear at which the next segment video meets the preset condition may specifically include: according to the next delay parameter and the segmented playing time length, calculating a bandwidth lower limit parameter under each preset code rate gear corresponding to the next segmented video; and if the bandwidth lower limit parameter is less than or equal to the next bandwidth parameter, taking the preset code rate gear corresponding to the bandwidth lower limit parameter as the code rate reference gear of the next sectional video.
Specifically, the preset bitrate gear is multiple bitrates adopted for re-encoding the next segmented video, and in this embodiment, the actual download bandwidth of the next segmented video in each preset bitrate gear, that is, the bandwidth lower limit parameter in this embodiment, may be calculated according to each preset bitrate gear, the next delay parameter, and the segmented playing time of the next segmented video; if the bandwidth lower limit parameter is less than or equal to the next bandwidth parameter, determining that the preset code rate gear corresponding to the bandwidth lower limit parameter meets the preset condition, taking the preset code rate gear corresponding to the bandwidth lower limit parameter as the code rate reference gear of the next section of video, and judging the bandwidth lower limit parameter of each preset code rate gear according to the steps to obtain all code rate reference gears of the next section of video meeting the preset condition. Illustratively, the preset condition of the embodiment is

Wherein,
for the next bandwidth parameter of the next segmented video,
is the next delay parameter, R, of the next segmented video
iFor each preset code rate gear, d, corresponding to the next video segment
iFor the segment playing time of the next segment video, the formula is used
Calculating the bandwidth lower limit parameter corresponding to each preset code rate gear, and if the bandwidth lower limit parameter is less than or equal toAt the next bandwidth parameter
Then the preset code rate gear R corresponding to the bandwidth lower limit parameter is set
iAnd the initial code rate judgment result is obtained by using the code rate reference gear of the next section of video.
S340, judging whether the residual cache length is greater than or equal to a first length threshold value and less than or equal to a second length threshold value, if so, executing S360; if not, go to S350.
Optionally, in order to accurately analyze the influence of the remaining buffer length on the download rate, as shown in fig. 3B, in this embodiment, the remaining buffer length in the buffer area is divided into three intervals by the preset first length threshold and the preset second length threshold, and as the segmented video is downloaded, the remaining buffer length in the buffer area is continuously decreased, and at this time, the download code rate of the next segmented video is determined in each interval in a different manner; at the moment, the first length threshold is an anti-blocking threshold set when the remaining buffer length is smaller, and in the interval when the remaining buffer length is smaller than the first length threshold, the downloading of the segmented video is slower, so that blocking is easily caused during playing; the second length threshold is an anti-jitter threshold set when the residual cache length is larger, and in the interval of which the residual cache length is larger than the second length threshold, the fast downloading of the segmented video can be ensured due to the larger residual space of the cache region; at this time, different download code rate determination modes can be adopted to determine the download code rate of the next segmented video aiming at different residual cache lengths of the cache region when the next segmented video is downloaded, so that the download definition of the next segmented video is ensured on the basis of fully utilizing network transmission. At this time, in this embodiment, the buffer area is divided into a corresponding anti-stutter area, a normal area and an anti-jitter area according to the first length threshold and the second length threshold, and different areas use different code rate determination methods, so as to avoid stutter and jitter of the next segment of video during playing.
And S350, determining the downloading code rate of the next segmented video according to the code rate reference gear and the downloading code rate of the current segmented video.
Specifically, if the remaining buffer length is not greater than or equal to the first length threshold and is less than or equal to the second length threshold, the remaining buffer length is smaller than the first length threshold, or the remaining buffer length is greater than the second length threshold, the remaining buffer length in the buffer area is within the upper limit interval or the lower limit interval, at this time, on the basis of the code rate reference gear, the download code rate of the downloaded current segmented video needs to be considered, and the corresponding code rate is selected from the download code rates corresponding to the code rate reference gear and the current segmented video in different intervals as the download code rate of the next segmented video.
For example, in this embodiment, two cases that the remaining cache length is smaller than the first length threshold or the remaining cache length is larger than the second length threshold are respectively analyzed:
1) when the residual cache length is smaller than a first length threshold, if the code rate reference gears are all smaller than or equal to the downloading code rate of the current segmented video, selecting the maximum code rate in the code rate reference gears as the downloading code rate of the next segmented video; and otherwise, taking the downloading code rate of the current segmented video as the downloading code rate of the next segmented video.
Specifically, when the remaining cache length is smaller than a first length threshold, it is indicated that the remaining cache length in the cache region is too small at this time, so that the segmented video is downloaded slowly and is easy to cause stutter during playing, and therefore, the current segmented video is not supported on the download code rate, a next segmented video is continuously downloaded with a higher code rate, at this time, it is determined whether the code rate reference gear meeting the preset condition is initially determined to be smaller than or equal to the download code rate of the current segmented video, and if so, the maximum code rate in the code rate reference gear is directly selected as the download code rate of the next segmented video; if not, the code rate reference gear has a code rate gear which exceeds the downloading code rate of the current segmented video, but the downloading code rate of the next segmented video is not supported to be higher than that of the current segmented video, so that the downloading code rate of the current segmented video is directly used as the downloading code rate of the next segmented video.
2) When the residual cache length is greater than a second length threshold value, if the code rate reference gear is less than or equal to the downloading code rate of the current segmented video, taking the downloading code rate of the current segmented video as the downloading code rate of the next segmented video; otherwise, selecting the maximum code rate in the code rate reference gear as the downloading code rate of the next section of video.
Specifically, when the remaining cache length is greater than the second length threshold, it is described that the remaining cache length in the cache region is too large, and the downloading of the next segmented video under the higher definition can be satisfied, so that the downloading of the next segmented video by using a higher code rate than a code rate reference gear meeting a preset condition is supported, at this time, it is judged whether the code rate reference gear meeting the preset condition is initially determined to be less than or equal to the downloading code rate of the current segmented video, and if so, the downloading code rate of the current segmented video is directly used as the downloading code rate of the next segmented video, so as to ensure the downloading of the next segmented video under the high definition; if not, the code rate higher than the downloading code rate of the current segmented video exists in the code rate reference gear which is initially determined to meet the preset condition, and at the moment, the maximum code rate in the code rate reference gear is directly selected as the downloading code rate of the next segmented video.
And S360, selecting the maximum code rate in the code rate reference gear as the downloading code rate of the next section of video.
Optionally, if the remaining buffer length is greater than or equal to the first length threshold and less than or equal to the second length threshold, and at this time, the downloaded code rate of the current segmented video is not considered in the middle interval of the buffer area, the maximum code rate is directly selected from the initially determined code rate reference gear meeting the preset condition as the download code rate of the next segmented video, and the download definition of the next segmented video is ensured on the basis of fully utilizing network transmission.
And S370, downloading the next segmented video according to the determined downloading code rate.
According to the technical scheme provided by the embodiment, the cache region is divided into three regions including a corresponding anti-jam region and an anti-jitter region through the first length threshold and the second length threshold, different code rate determining modes are adopted when the remaining cache length is in different regions, a corresponding code rate is selected from code rate reference gears meeting preset conditions and downloaded code rates of downloaded current segmented videos to serve as the downloading code rate of the next segmented video, on the basis of fully utilizing network transmission, jam and jitter of the next segmented video during playing are avoided, and downloading definition of the next segmented video is guaranteed.
EXAMPLE III
Fig. 4A is a flowchart of a video downloading method according to a third embodiment of the present invention, and fig. 4B is a schematic diagram of a video downloading process according to the third embodiment of the present invention. The present embodiment is optimized based on the above embodiments, and the present embodiment mainly explains in detail the specific determination process of the next bandwidth parameter and the next delay parameter of the next segmented video.
Optionally, as shown in fig. 4A, this embodiment may include the following steps:
s410, determining the residual cache length after the current segmented video is downloaded and the segmented playing time length of the next segmented video to be downloaded.
And S420, determining a next bandwidth parameter of the next segmented video according to the current bandwidth parameter, the actual download bandwidth and the preset bandwidth smoothing parameter of the current segmented video.
Specifically, in this embodiment, when the next bandwidth parameter of the next segmented video is determined, the network state of the downloaded current segmented video is analyzed to obtain the current bandwidth parameter of the current segmented video determined according to the network state of the previous segmented video and the actual download bandwidth of the current segmented video during downloading, and then the current bandwidth parameter of the current segmented video and the actual download bandwidth are smoothed according to the preset bandwidth smoothing parameter to obtain the next bandwidth parameter of the next segmented video.
For example, as shown in fig. 4B, in this embodiment, determining a next bandwidth parameter of a next segmented video according to a current bandwidth parameter and an actual download bandwidth of a current segmented video and a preset bandwidth smoothing parameter may specifically include: smoothing the current bandwidth parameter and the actual download bandwidth of the current segmented video by adopting a first preset bandwidth smoothing parameter and a second preset bandwidth smoothing parameter respectively to obtain a first bandwidth smoothing value and a second bandwidth smoothing value; and selecting the minimum value of the first bandwidth smooth value and the second bandwidth smooth value as a next bandwidth parameter of the next segmented video.
Specifically, in order to ensure the accuracy of the next bandwidth parameter, in this embodiment, the current bandwidth parameter and the actual download bandwidth of the current segmented video are respectively smoothed by the first preset bandwidth smoothing parameter and the second preset bandwidth smoothing parameter, so as to counter the jitter of the network bandwidth, obtain a first bandwidth smoothing value and a second bandwidth smoothing value, and then select the minimum value from the first bandwidth smoothing value and the second bandwidth smoothing value, so as to serve as the next bandwidth parameter of the next segmented video. Illustratively, the smoothing formula in this embodiment is:
wherein,
for the next bandwidth parameter of the next segmented video,
for the current bandwidth parameter of the downloaded current segmented video, b
iFor the actual download bandwidth of the current segmented video, α
1And alpha
2Respectively a first preset bandwidth smoothing parameter and a second preset bandwidth smoothing parameter; at this time, the following formula is adopted to smooth the current bandwidth parameter and the actual download bandwidth of the current segmented video, and the minimum value of the first bandwidth smooth value and the second bandwidth smooth value is selected as the next bandwidth parameter of the next segmented video.
In addition, because there is a certain error in the next bandwidth parameter of the next segment video determined by the network state of the current segment video and the actual download bandwidth of the next segment video during actual download, in order to ensure the accuracy of the next bandwidth parameter of the next segment video, the embodiment needs to reduce the error between the next bandwidth parameter and the next segment video as much as possible, so that the minimum value of the first bandwidth smooth value and the second bandwidth smooth value is selected in the embodiment to serve as the next bandwidth parameter of the next segment video, which may specifically include: selecting the minimum value of the first bandwidth smooth value and the second bandwidth smooth value as the middle bandwidth parameter of the next segmented video; and adjusting the intermediate bandwidth parameter according to the historical bandwidth error to obtain the next bandwidth parameter.
Specifically, the historical bandwidth error in this embodiment is the largest error among errors between the historical bandwidth parameters of each historical segmented video that has been downloaded before the next segmented video and the actual download bandwidth; illustratively, the historical bandwidth error is
Wherein epsilon is the maximum serial number of each historical segmented video downloaded before the next segmented video, gamma
iThe degree of influence of any historical segmented video relative to the next segmented video. At this time, after the first bandwidth smooth value and the second bandwidth smooth value are obtained, the minimum value of the first bandwidth smooth value and the second bandwidth smooth value is selected as the middle bandwidth parameter of the next segment of video; and then, the intermediate bandwidth parameter is adjusted according to the determined historical bandwidth error to obtain a next bandwidth error of the next segmented video, and at this time, the next bandwidth parameter of the next segmented video is dynamically adjusted based on an error between the historical bandwidth parameter of the historical segmented video and an actual download bandwidth in this embodiment, so that a prediction error of a network bandwidth is reduced.
And S430, determining a next delay parameter of the next segmented video according to the current delay parameter, the actual download delay and the preset delay smoothing parameter of the current segmented video.
Specifically, since the network bandwidth and the network delay both belong to the network state with the same attribute, the next delay parameter of the next segmented video may be determined according to the current delay parameter, the actual download delay, and the preset delay smoothing parameter of the current segmented video with reference to the determination manner of the next bandwidth parameter.
At this time, determining a next delay parameter of a next segmented video according to the current delay parameter, the actual download delay and the preset delay smoothing parameter of the current segmented video, which may specifically include: smoothing the current delay parameter and the actual download delay of the current segmented video by adopting a first preset delay smoothing parameter and a second preset delay smoothing parameter to obtain a first delay smoothing value and a second delay smoothing value; selecting the minimum value of the first delay smooth value and the second delay smooth value as a next delay parameter of the next segmented video; at this time, in this embodiment, the current bandwidth parameter and the actual download bandwidth of the current segmented video are smoothed based on two different preset bandwidth smoothing parameters, so as to avoid jitter of the network bandwidth.
Further, in this embodiment, selecting a minimum value of the first delay smooth value and the second delay smooth value as a next delay parameter of the next segment of video may specifically include: selecting the minimum value of the first delay smooth value and the second delay smooth value as an intermediate delay parameter of the next segmented video; and adjusting the intermediate delay parameter according to the historical delay error to obtain the next delay parameter. Wherein the historical delay error is the maximum error in the errors between the historical delay parameter and the actual download delay of each historical segmented video downloaded before the next segmented video.
And S440, determining the downloading code rate of the next segmented video according to the next bandwidth parameter, the next delay parameter, the segmented playing time and the residual cache length.
And S450, downloading the next section of video according to the determined downloading code rate.
According to the technical scheme provided by the embodiment, the next bandwidth parameter of the next segmented video is determined according to the current bandwidth parameter, the actual downloading bandwidth and the preset bandwidth smoothing parameter of the current segmented video, the next delay parameter of the next segmented video is determined according to the current delay parameter, the actual downloading delay and the preset delay smoothing parameter of the current segmented video, so that the accuracy of the next bandwidth parameter and the next delay parameter is ensured, the downloading code rate of the next segmented video is subsequently determined according to the next bandwidth parameter, the next delay parameter, the segmented playing time and the residual cache length, the accuracy of the downloading code rate is improved, and the downloading definition of the next segmented video is ensured on the basis of fully utilizing network transmission.
Example four
Fig. 5 is a flowchart of a video playing method according to a fourth embodiment of the present invention, where the present embodiment is applicable to a case where live webcasting or video-on-demand playing is performed through any player. The method for playing video provided by this embodiment may be executed by the apparatus for playing video provided by the embodiment of the present invention, and the apparatus may be implemented in a software and/or hardware manner, and is integrated in a device for executing the method, where the device may be a client configured with any video application for live network broadcast or video on demand, and the client may be any intelligent terminal such as a mobile phone, a tablet computer, or a notebook computer.
Specifically, referring to fig. 5, the method may include the steps of:
s510, executing the video downloading method in the foregoing embodiment to obtain a downloaded segmented video.
Specifically, when playing any video, the client first requests the resource server to download the video, and at this time, downloads each segmented video to be played from the resource server by executing the video downloading method provided in any of the above embodiments.
And S520, playing the downloaded segmented video.
Specifically, after the downloaded segmented videos are obtained, the downloaded segmented videos are sequentially played.
According to the technical scheme provided by the embodiment, the downloading code rate of the next segmented video is determined according to the player state and the network state in the video playing process, the next segmented video is downloaded according to the downloading code rate, at the moment, the playing state of each segment and the real-time downloading network state are considered simultaneously, the segmented downloading of different segmented videos under the self-adaptive code rate is guaranteed, the problem that the code rate of each segmented video is changed continuously and the playing is blocked due to the fact that the downloading code rate of the next segmented video is determined only according to the network bandwidth of the historical segmented video in the prior art is avoided, the scheme can select the appropriate downloading code rate for the next segmented video by utilizing the real-time downloading network state better according to the player state, and the downloading definition of the segmented video is improved on the basis of fully utilizing the network state; when the downloaded segmented video is played again, the situation that the playing is blocked due to untimely downloading is avoided, and the smoothness of video playing is ensured.
EXAMPLE five
Fig. 6 is a schematic structural diagram of a video downloading apparatus according to a fifth embodiment of the present invention, specifically, as shown in fig. 6, the apparatus may include:
aninformation determining module 610, configured to determine a remaining cache length after downloading a current segmented video and a segmented playing time length of a next segmented video to be downloaded;
a download coderate determining module 620, configured to adaptively select a download code rate that best meets the current network state in a code rate gear corresponding to the next segmented video according to the remaining cache length and the segmented playing time;
and avideo downloading module 630, configured to download the next segment of video according to the determined downloading code rate.
The technical solution provided in this embodiment is to determine the remaining buffer length after downloading the current segmented video and the segmented playing time of the next segmented video, and then adaptively select the downloading bitrate most suitable for the current network state in the bitrate gear corresponding to the next segmented video according to the remaining buffer length and the segmented playing time, download the next segmented video according to the downloading bitrate, and at this time, consider the playing states of the segments and the real-time downloading network state at the same time, ensure the segmented downloading of different segmented videos at the adaptive bitrate, avoid the problem that the downloading bitrate of the next segmented video is determined only according to the network bandwidth of the historical segmented video in the prior art, so that the bitrate of each segmented video is changed continuously, and the playing is blocked, and the scheme can select the appropriate downloading bitrate for the next segmented video by better utilizing the real-time downloading network state according to the remaining buffer length and the segmented playing time in the player state, on the basis of fully utilizing the current network state, the downloading definition of the segmented video is improved.
Further, the apparatus for downloading video may further include:
and the network state determining module is used for determining a next bandwidth parameter and a next delay parameter in the current network state corresponding to the next segmented video when downloading according to the network bandwidth and the network delay of the current segmented video when downloading.
Further, the download coderate determining module 620 may be specifically configured to:
determining a code rate reference gear meeting preset conditions in a code rate gear corresponding to the next segmented video according to the next bandwidth parameter, the next delay parameter and the segmented playing time;
if the residual cache length is smaller than the first length threshold or the residual cache length is larger than the second length threshold, determining the download code rate of the next segmented video according to the code rate reference gear and the download code rate of the current segmented video;
and if the residual cache length is greater than or equal to the first length threshold and less than or equal to the second length threshold, selecting the maximum code rate in the code rate reference gear as the downloading code rate of the next section of video.
Further, the download coderate determining module 620 may be specifically configured to:
when the residual cache length is smaller than a first length threshold, if the code rate reference gears are all smaller than or equal to the downloading code rate of the current segmented video, selecting the maximum code rate in the code rate reference gears as the downloading code rate of the next segmented video; otherwise, taking the downloading code rate of the current segmented video as the downloading code rate of the next segmented video;
when the residual cache length is greater than a second length threshold value, if the code rate reference gear is less than or equal to the downloading code rate of the current segmented video, taking the downloading code rate of the current segmented video as the downloading code rate of the next segmented video; otherwise, selecting the maximum code rate in the code rate reference gear as the downloading code rate of the next section of video.
Further, the download coderate determining module 620 may be specifically configured to:
according to the next delay parameter and the segmented playing time length, calculating a bandwidth lower limit parameter under each preset code rate gear corresponding to the next segmented video;
and if the bandwidth lower limit parameter is less than or equal to the next bandwidth parameter, taking the preset code rate gear corresponding to the bandwidth lower limit parameter as the code rate reference gear of the next sectional video.
Further, the network status determining module may be specifically configured to:
determining a next bandwidth parameter of a next segmented video according to the current bandwidth parameter, the actual download bandwidth and a preset bandwidth smoothing parameter of the current segmented video;
and determining the next delay parameter of the next segmented video according to the current delay parameter, the actual downloading delay and the preset delay smoothing parameter of the current segmented video.
Further, the network status determining module may be specifically configured to:
smoothing the current bandwidth parameter and the actual download bandwidth of the current segmented video by adopting a first preset bandwidth smoothing parameter and a second preset bandwidth smoothing parameter respectively to obtain a first bandwidth smoothing value and a second bandwidth smoothing value; selecting the minimum value of the first bandwidth smooth value and the second bandwidth smooth value as a next bandwidth parameter of the next segmented video; and/or the presence of a gas in the gas,
smoothing the current delay parameter and the actual download delay of the current segmented video by adopting a first preset delay smoothing parameter and a second preset delay smoothing parameter to obtain a first delay smoothing value and a second delay smoothing value; and selecting the minimum value of the first delay smooth value and the second delay smooth value as a next delay parameter of the next segmented video.
Further, the network status determining module may be specifically configured to:
selecting the minimum value of the first bandwidth smooth value and the second bandwidth smooth value as the middle bandwidth parameter of the next segmented video; adjusting the intermediate bandwidth parameter according to the historical bandwidth error to obtain a next bandwidth parameter; and/or the presence of a gas in the gas,
selecting the minimum value of the first delay smooth value and the second delay smooth value as an intermediate delay parameter of the next segmented video; and adjusting the intermediate delay parameter according to the historical delay error to obtain the next delay parameter.
Further, the historical bandwidth error is a maximum error between a historical bandwidth parameter and an actual download bandwidth of each historical segmented video downloaded before the next segmented video, and the historical delay error is a maximum error between a historical delay parameter and an actual download delay of each historical segmented video downloaded before the next segmented video.
Further, thevideo downloading module 630 may be specifically configured to:
sending a downloading request for the next segmented video to a resource server, wherein the downloading request carries the downloading code rate of the next segmented video;
and receiving the next section of video at the downloading code rate, which is transmitted by the resource server.
The video downloading device provided by the embodiment can be applied to the video downloading method provided by any embodiment, and has corresponding functions and beneficial effects.
EXAMPLE six
Fig. 7 is a schematic structural diagram of a video playing apparatus according to a sixth embodiment of the present invention, specifically, as shown in fig. 7, the apparatus may include:
thevideo downloading module 710 is configured to execute the video downloading method provided in any embodiment of the present invention to obtain a downloaded segmented video;
and avideo playing module 720, configured to play the downloaded segmented video.
According to the technical scheme provided by the embodiment, the downloading code rate of the next segmented video is determined according to the player state and the network state in the video playing process, the next segmented video is downloaded according to the downloading code rate, at the moment, the playing state of each segment and the real-time downloading network state are considered simultaneously, the segmented downloading of different segmented videos under the self-adaptive code rate is guaranteed, the problem that the code rate of each segmented video is changed continuously and the playing is blocked due to the fact that the downloading code rate of the next segmented video is determined only according to the network bandwidth of the historical segmented video in the prior art is avoided, the scheme can select the appropriate downloading code rate for the next segmented video by utilizing the real-time downloading network state better according to the player state, and the downloading definition of the segmented video is improved on the basis of fully utilizing the network state; when the downloaded segmented video is played again, the situation that the playing is blocked due to untimely downloading is avoided, and the smoothness of video playing is ensured.
The video playing device provided by the embodiment can be applied to the video playing method provided by any embodiment, and has corresponding functions and beneficial effects.
EXAMPLE seven
Fig. 8 is a schematic structural diagram of a video processing system according to a seventh embodiment of the present invention. Referring to fig. 8, the video playback system includes: aclient 810 and aresource server 820.
Specifically, theclient 810 is provided with a video downloading device provided in the above embodiment of the present invention and a video playing device provided in the above embodiment of the present invention, and the specific implementation process refers to the video playing method in any embodiment of the present invention, and has corresponding functions, which are not described in detail herein; theresource server 820 sequentially sends the segmented video at the download code rate in the video to be played to the client.
Example eight
Fig. 9 is a schematic structural diagram of an apparatus according to an eighth embodiment of the present invention, as shown in fig. 9, the apparatus includes aprocessor 90, astorage device 91, and acommunication device 92; the number ofprocessors 90 in the device may be one or more, and oneprocessor 90 is taken as an example in fig. 9; theprocessor 90, the storage means 91 and the communication means 92 in the device may be connected by a bus or other means, as exemplified by the bus connection in fig. 9.
Thestorage device 91 is a computer-readable storage medium, and can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the video downloading method or the video playing method provided in the embodiments of the present invention. Theprocessor 90 executes various functional applications and data processing of the apparatus, i.e., the method of video downloading or the method of video playing described above, by running software programs, instructions and modules stored in thestorage device 91.
Thestorage device 91 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, thestorage 91 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, thestorage 91 may further include memory located remotely from the processor 60, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The communication means 92 may be used to enable a network connection or a mobile data connection between the devices.
The device provided by this embodiment may be configured to execute the service access method provided by any of the above embodiments, and has corresponding functions and beneficial effects.
Example nine
Ninth embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, can implement the method for downloading a video or the method for playing a video in any of the above embodiments. The video downloading method may specifically include:
determining the residual cache length after downloading the current segmented video and the segmented playing time length of the next segmented video to be downloaded;
adaptively selecting the downloading code rate which best meets the current network state in the code rate gear corresponding to the next segmented video according to the residual cache length and the segmented playing time length;
and downloading the next segmented video according to the determined downloading code rate.
The video playing method may specifically include:
executing the video downloading method provided by any embodiment of the invention to obtain the downloaded segmented video;
and playing the downloaded segmented video.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform the video downloading method or the related operations in the video playing method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the video downloading apparatus or the video playing apparatus, the units and modules included in the apparatus are only divided according to the functional logic, but are not limited to the above division, as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.