CN103051955B - Flow media playing method and device - Google Patents
Flow media playing method and device Download PDFInfo
- Publication number
- CN103051955B CN103051955B CN201210562414.4A CN201210562414A CN103051955B CN 103051955 B CN103051955 B CN 103051955B CN 201210562414 A CN201210562414 A CN 201210562414A CN 103051955 B CN103051955 B CN 103051955B
- Authority
- CN
- China
- Prior art keywords
- streaming media
- buffer area
- rate
- data
- size
- 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.)
- Expired - Fee Related
Links
Landscapes
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本发明提供一种流媒体播放方法及装置。该方法包括检测得到流媒体的下载速率;根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,所述流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。本发明技术方案可在流媒体播放时基于流媒体下载速率动态对流媒体数据缓存区的大小进行调整,可有效提高流媒体播放的流畅度。
The invention provides a streaming media playing method and device. The method includes detecting the download rate of the streaming media; adjusting the size of the buffer area of the streaming media data according to the download rate and the playback rate of the streaming media, wherein the buffer area of the streaming media data is used to process the streaming media data Data storage space for cache operations. The technical scheme of the invention can dynamically adjust the size of the streaming media data buffer area based on the streaming media download rate during streaming media playback, and can effectively improve the fluency of streaming media playback.
Description
技术领域technical field
本发明实施例涉及流媒体播放技术,尤其涉及一种流媒体播放方法及装置。The embodiments of the present invention relate to streaming media playing technologies, and in particular, to a streaming media playing method and device.
背景技术Background technique
流媒体(StreamingMedia)播放技术是指通过采用流式技术进行多媒体文件传输而实现多媒体在线实时播放的技术。在进行视频/音频等多媒体文件播放时,服务器通过采用流媒体播放技术进行多媒体文件传输,可使得用户计算机上的客户端实现多媒体文件的边下载边播放的在线实时播放,可有效提高用户在线观看多媒体内容的体验。Streaming Media (Streaming Media) playback technology refers to the technology of multimedia online real-time playback by using streaming technology for multimedia file transmission. When playing multimedia files such as video/audio, the server transmits multimedia files by using streaming media playback technology, which can enable the client on the user's computer to realize online real-time playback of multimedia files while downloading and playing, which can effectively improve users' online viewing. The experience of multimedia content.
其中,流式技术是指服务器将多媒体文件压缩成一个个的压缩包,并将压缩包连续、实时地传输至用户计算机,这样的传输的多媒体文件也可称为流媒体,传输的压缩包也可称为流数据;用户计算机上的客户端可实时接收流数据,并对流数据进行实时解码、播放,从而实现流媒体的边下载边播放。目前,用户计算机上的客户端在接收流数据时,通常设置有固定大小的数据存储块作为缓冲区,用于对流数据进行缓存操作,这样,通过缓存流数据就可以改善网络抖动和时延变化对流媒体播放的影响,避免网络堵塞造成的流媒体播放停顿。Among them, streaming technology means that the server compresses multimedia files into individual compressed packages, and transmits the compressed packages to the user computer continuously and in real time. Such transmitted multimedia files can also be called streaming media, and the transmitted compressed packages can also be called streaming media. It can be called streaming data; the client on the user's computer can receive streaming data in real time, and decode and play the streaming data in real time, so as to realize streaming media playback while downloading. At present, when the client on the user's computer receives streaming data, it usually sets a fixed-size data storage block as a buffer for caching the streaming data. In this way, network jitter and delay changes can be improved by caching the streaming data. The impact on streaming media playback, avoiding the pause of streaming media playback caused by network congestion.
但是,现有流媒体播放技术中,用于流数据缓存操作的缓存区空间大小一定,这就带来以下如下问题:由于流媒体初始播放,或者播放过程中因停顿而重启播放时,需要缓冲区内的流数据满后才能播放,因此,现有流媒体播放过程中常常因缓冲区大小设置不合理而导致流媒体的播放效果较差,例如,若缓冲区设置过大,将会导致流媒体初始播放等待时间,以及播放过程中停顿时间过长;若缓冲区设置过小,将会导致流媒体播放过程中停顿次数过多,从而影响播放效果。However, in the existing streaming media playback technology, the size of the buffer area used for streaming data buffering operations is fixed, which brings the following problems: due to the initial playback of streaming media, or when playback is restarted due to a pause during playback, buffering is required. The streaming data in the area can only be played when it is full. Therefore, the unreasonable setting of the buffer size often causes the streaming media to play poorly in the existing streaming media playback process. For example, if the buffer size is set too large, it will cause streaming The waiting time for initial media playback and the pause time during playback are too long; if the buffer setting is too small, it will cause too many pauses during streaming media playback, which will affect the playback effect.
发明内容Contents of the invention
本发明实施例提供一种流媒体播放方法及装置,可克服现有流媒体播放过程中固定设置的缓存区大小不合理而导致播放效果较差的问题,可有效提高流媒体播放的流畅度。The embodiments of the present invention provide a method and device for playing streaming media, which can overcome the problem of poor playback effect caused by the unreasonable size of the fixed buffer area in the existing streaming media playing process, and can effectively improve the fluency of streaming media playing.
第一方面,本发明实施例提供一种流媒体播放方法,包括:In a first aspect, an embodiment of the present invention provides a method for playing streaming media, including:
检测得到流媒体的下载速率;Detect the download rate of streaming media;
根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,所述流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。According to the download rate and the playback rate of the streaming media, the size of the streaming media data buffer area is adjusted, wherein the streaming media data buffer area is a data storage space for caching the streaming media data.
结合第一方面,在第一种可能实现方式中,所述根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,具体包括:With reference to the first aspect, in a first possible implementation manner, the adjusting the size of the streaming media data buffer area according to the download rate and the streaming media playback rate specifically includes:
在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率大于或等于所述播放速率时,将流媒体数据的缓存区的大小调整到第一缓存长度,以便在所述预设的最小缓存长度的流媒体数据的缓存区满后开始播放流媒体,所述第一缓存长度为所述当前缓存区中已缓存数据占用的缓存区的长度与预设最小缓存长度中的最大值。During the initial playback of the streaming media or restarting playback after a pause, when the download rate is greater than or equal to the playback rate, the size of the buffer area of the streaming media data is adjusted to the first buffer length, so that the preset Start playing streaming media after the buffer area of the streaming media data with the minimum buffer length is full, the first buffer length is the maximum value between the length of the buffer area occupied by the buffered data in the current buffer area and the preset minimum buffer length .
结合第一方面的第一种可能实现方式,在第二种可能实现方式中,所述的流媒体播放方法还包括:With reference to the first possible implementation of the first aspect, in the second possible implementation, the streaming media playback method further includes:
在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率小于播放速率时,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并根据所述缓存变化率调整所述流媒体数据的缓存区的大小;During the initial playback of the streaming media or restarting playback after a pause, when the download rate is lower than the playback rate, obtain the cache change rate in the current buffer area according to the download rate and the playback rate, and adjust according to the cache change rate The size of the buffer area of the streaming media data;
其中,所述缓存变化率S(t)=D(t)-K(t),其中,D(t)为流媒体的下载速率,K(t)流媒体的播放速率,所述缓存变化率用于表示缓存区中数据增多或减少的变化量。Wherein, the cache change rate S(t)=D(t)-K(t), wherein, D(t) is the download rate of streaming media, K(t) the playback rate of streaming media, and the cache change rate It is used to indicate the change amount of data increase or decrease in the cache area.
结合第一方面的第二种可能实现方式,在第三种可能实现方式中,所述根据当前缓存区中的缓存变化率,调整所述流媒体数据的缓存区的大小,具体包括:With reference to the second possible implementation manner of the first aspect, in the third possible implementation manner, the adjusting the size of the buffer area of the streaming media data according to the buffer change rate in the current buffer area specifically includes:
在当前缓存区的缓存变化率增加时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。When the buffer change rate of the current buffer area increases, the buffer area occupied by the buffered data in the current buffer area is used as the buffer area of the streaming media data, so as to start playing the streaming media.
结合第一方面的第二种能实现方式,在第四种可能实现方式中,所述根据当前缓存区中的缓存变化率,调整所述流媒体数据的缓存区的大小,具体包括:In combination with the second possible implementation manner of the first aspect, in a fourth possible implementation manner, the adjusting the size of the buffer area of the streaming media data according to the buffer change rate in the current buffer area specifically includes:
在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率达到预设增长阈值时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。When the change rate of the current buffer area does not change or decreases, and the growth rate of the download rate reaches a preset growth threshold, the buffer area occupied by the cached data in the current buffer area is used as the buffer area of the streaming media data, so that Start streaming.
结合第一方面的第二种能实现方式,在第五种可能实现方式中,所述根据当前缓存区中的缓存变化率,调整所述流媒体数据的缓存区的大小,具体包括:In combination with the second possible implementation manner of the first aspect, in a fifth possible implementation manner, the adjusting the size of the buffer area of the streaming media data according to the buffer change rate in the current buffer area specifically includes:
在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率未达到预设增长阈值或下降时,根据当前缓存区中已缓存的数据的大小,调整所述流媒体数据的缓存区的大小。When the change rate of the current buffer area does not change or decreases, and the growth rate of the download rate does not reach the preset growth threshold or declines, adjust the cache of the streaming media data according to the size of the cached data in the current buffer area The size of the zone.
结合第一方面的第五种能实现方式,在第六种可能实现方式中,所述根据当前缓存区中已缓存的数据的大小,调整所述流媒体数据的缓存区的大小,具体包括:With reference to the fifth possible implementation of the first aspect, in the sixth possible implementation, the adjusting the size of the streaming media data buffer according to the size of the cached data in the current buffer specifically includes:
在当前缓存区中已缓存的数据B满足条件:B>=G*(1-D/K)时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体;The buffered data B in the current buffer area satisfies the condition: when B>=G*(1-D/K), the buffer area occupied by the buffered data in the current buffer area is used as the buffer area of the streaming media data, so that start streaming;
其中,所述G为未播放的流媒体的长度,D为下载速率,K为播放速率。Wherein, G is the length of the unplayed streaming media, D is the download rate, and K is the playback rate.
结合第一方面的第六种能实现方式,在第七种可能实现方式中,所述的流媒体播放方法还包括:In combination with the sixth possible implementation of the first aspect, in a seventh possible implementation, the streaming media playback method further includes:
当前缓存区缓存的数据B不满足条件:B>=G*(1-D/K),且G*(1-D/K)不大于流媒体数据的缓存区的最大值时,将所述G*(1-D/K)的长度作为流媒体数据的缓存区的大小,以便在所述流媒体数据的缓存区满后开始播放流媒体。The data B cached in the current buffer area does not satisfy the condition: B>=G*(1-D/K), and when G*(1-D/K) is not greater than the maximum value of the buffer area of streaming media data, the described The length of G*(1-D/K) is used as the size of the buffer area of the streaming media data, so as to start playing the streaming media after the buffer area of the streaming media data is full.
结合第一方面,在第八种可能实现方式中,所述的流媒体播放方法还包括:With reference to the first aspect, in an eighth possible implementation manner, the streaming media playback method further includes:
在所述流媒体停顿后重启播放时,若停顿次数大于预设停顿阈值时,增大流媒体数据的缓存区的大小。When restarting playback after the streaming media is paused, if the number of pauses is greater than a preset pause threshold, increase the size of the buffer area of the streaming media data.
结合第一方面或第一方面的第一或二或三或四或五或六或七或八种可能实现方式,在第九种可能实现方式中,所述检测得到流媒体的下载速率,具体包括:Combining the first aspect or the first or two or three or four or five or six or seven or eight possible implementations of the first aspect, in the ninth possible implementation, the detection obtains the download rate of the streaming media, specifically include:
在启动流媒体播放指令,或者停顿后重启播放开始后的预设时间检测得到流媒体的下载速率;The download rate of the streaming media is obtained by detecting the preset time after starting the streaming media playback command, or restarting the playback after a pause;
或者,在启动流媒体播放指令,或者停顿后重启播放开始后,周期性的检测得到流媒体的下载速率。Or, after starting the streaming media playback command, or restarting the playback after a pause, the download rate of the streaming media is obtained through periodic detection.
结合第一方面或第一方面的第一或二或三或四或五或六或七或八或九种可能实现方式,在第十种可能实现方式中,所述的流媒体播放方法还包括:In combination with the first aspect or the first or second or third or four or five or six or seven or eight or nine possible implementations of the first aspect, in the tenth possible implementation, the streaming media playback method further includes :
接收流媒体播放指令,并为流媒体播放设定预设大小的流媒体数据存储空间作为播放流媒体初始的流媒体数据的缓存区。Receive the streaming media playing instruction, and set the streaming media data storage space with a preset size for the streaming media playing as a buffer area for playing the streaming media initial streaming data.
结合第一方面的第一或二或三或四或五或六或七或八或九或十种可能实现方式,在第十一种可能实现方式中,所述的流媒体播放方法还包括:In combination with the first or second or third or four or five or six or seven or eight or nine or ten possible implementations of the first aspect, in the eleventh possible implementation, the streaming media playback method further includes:
在所述流媒体初始播放或停顿后重启播放过程中,若播放等待时间超过预设等待时间时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。During the initial playback of the streaming media or restarting the playback process after a pause, if the playback waiting time exceeds the preset waiting time, the buffer area occupied by the cached data in the current buffer area is used as the buffer area of the streaming media data, so as to start playing the stream media.
结合第一方面,在第十二中能实现方式中,所述根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,具体包括:In combination with the first aspect, in the twelfth implementation manner, the adjustment of the buffer size of the streaming media data according to the download rate and the playback rate of the streaming media specifically includes:
在流媒体播放过程中,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并在所述缓存变化率增长时,增大流媒体数据的缓存区的大小。During the streaming media playing process, the buffer change rate in the current buffer area is obtained according to the download rate and the playback rate, and when the buffer change rate increases, the size of the streaming media data buffer area is increased.
第二方面,本发明实施例提供一种流媒体播放装置,包括:In a second aspect, an embodiment of the present invention provides a streaming media playback device, including:
检测模块,用于检测得到流媒体的下载速率;A detection module is used to detect the download rate of streaming media;
调整模块,用于根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,所述流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。An adjustment module, configured to adjust the size of the buffer area of the streaming media data according to the download rate and the playback rate of the streaming media, wherein the buffer area of the streaming media data is a data storage space for caching the streaming media data .
结合第二方面,在第一种可能实现方式中,所述调整模块,具体用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率大于或等于所述播放速率时,将流媒体数据的缓存区的大小调整到第一缓存长度,以便在所述预设的最小缓存长度的流媒体数据的缓存区满后开始播放流媒体,所述第一缓存长度为所述当前缓存区中已缓存数据占用的缓存区的长度与预设最小缓存长度中的最大值。With reference to the second aspect, in the first possible implementation manner, the adjustment module is specifically configured to, when the download rate is greater than or equal to the playback rate during the initial playback of the streaming media or restart playback after a pause, Adjust the size of the buffer area of the streaming media data to the first buffer length, so as to start playing the streaming media after the buffer area of the streaming media data of the preset minimum buffer length is full, and the first buffer length is the current The maximum value between the length of the cache area occupied by the cached data in the cache area and the preset minimum cache length.
结合第二方面的第一种可能实现方式,在第二种可能实现方式中,所述调整模块,还用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率小于播放速率时,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并根据所述缓存变化率调整所述流媒体数据的缓存区的大小;With reference to the first possible implementation manner of the second aspect, in the second possible implementation manner, the adjustment module is further configured to: during the initial playback of the streaming media or restarting playback after a pause, the download rate is less than the playback rate. When the speed is high, obtain the buffer change rate in the current buffer area according to the download rate and the playback rate, and adjust the size of the buffer area of the streaming media data according to the buffer change rate;
其中,所述缓存变化率S(t)=D(t)-K(t),其中,D(t)为流媒体的下载速率,K(t)流媒体的播放速率,所述缓存变化率用于表示缓存区中数据增多或减少的变化量。Wherein, the cache change rate S(t)=D(t)-K(t), wherein, D(t) is the download rate of streaming media, K(t) the playback rate of streaming media, and the cache change rate It is used to indicate the change amount of data increase or decrease in the cache area.
结合第二方面的第二种可能实现方式,在第三种可能实现方式中,所述调整模块,具体用于在当前缓存区的缓存变化率增加时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。With reference to the second possible implementation of the second aspect, in the third possible implementation, the adjustment module is specifically configured to, when the cache change rate of the current buffer increases, increase the The buffer area serves as a buffer area for streaming media data in order to start playing streaming media.
结合第二方面的第二种能实现方式,在第四种可能实现方式中,所述调整模块,具体用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率达到预设增长阈值时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。With reference to the second possible implementation manner of the second aspect, in the fourth possible implementation manner, the adjustment module is specifically configured to have no change or decrease in the change rate of the current cache area, and the growth rate of the download rate reaches When the growth threshold is preset, the buffer area occupied by the buffered data in the current buffer area is used as the buffer area of the streaming media data, so as to start playing the streaming media.
结合第二方面的第二种能实现方式,在第五种可能实现方式中,所述调整模块,具体用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率未达到预设增长阈值或下降时,根据当前缓存区中已缓存的数据的大小,调整所述流媒体数据的缓存区的大小。With reference to the second possible implementation manner of the second aspect, in a fifth possible implementation manner, the adjustment module is specifically configured to: the change rate of the current buffer area does not change or decrease, and the growth rate of the download rate does not change. When the preset growth threshold is reached or decreased, the size of the streaming media data buffer area is adjusted according to the size of the buffered data in the current buffer area.
结合第二方面的第五种能实现方式,在第六种可能实现方式中,所述调整模块,具体用于在当前缓存区中已缓存的数据B满足条件:B>=G*(1-D/K)时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体;In combination with the fifth possible implementation of the second aspect, in the sixth possible implementation, the adjustment module is specifically configured to satisfy the condition that the cached data B in the current buffer area: B>=G*(1- During D/K), the cache area occupied by cached data in the current buffer area is used as the buffer area of streaming media data, so as to start playing streaming media;
其中,所述G为未播放的流媒体的长度,D为下载速率,K为播放速率。Wherein, G is the length of the unplayed streaming media, D is the download rate, and K is the playback rate.
结合第二方面的第六种能实现方式,在第七种可能实现方式中,所述调整模块,还用于当前缓存区缓存的数据B不满足条件:B>=G*(1-D/K),且G*(1-D/K)不大于流媒体数据的缓存区的最大值时,将所述G*(1-D/K)的长度作为流媒体数据的缓存区的大小,以便在所述流媒体数据的缓存区满后开始播放流媒体。In combination with the sixth possible implementation of the second aspect, in the seventh possible implementation, the adjustment module is also used for the data B cached in the current buffer area not to satisfy the condition: B>=G*(1-D/ K), and when G*(1-D/K) is not greater than the maximum value of the buffer area of the streaming media data, the length of the G*(1-D/K) is used as the size of the buffer area of the streaming media data, In order to start playing the streaming media after the buffer area of the streaming media data is full.
结合第二方面,在第八种可能实现方式中,所述调整模块,还用于在所述流媒体停顿后重启播放时,若停顿次数大于预设停顿阈值时,增大流媒体数据的缓存区的大小。In combination with the second aspect, in an eighth possible implementation manner, the adjustment module is further configured to increase the cache of streaming media data if the number of pauses is greater than a preset pause threshold when restarting playback after the streaming media pauses The size of the zone.
结合第二方面或第二方面的第一或二或三或四或五或六或七或八种可能实现方式,在第九种可能实现方式中,所述检测模块,具体用于在启动流媒体播放指令,或者停顿后重启播放开始后的预设时间检测得到流媒体的下载速率;或者,用于在启动流媒体播放指令,或者停顿后重启播放开始后,周期性的检测得到流媒体的下载速率。In combination with the second aspect or the first or two or three or four or five or six or seven or eight possible implementations of the second aspect, in a ninth possible implementation, the detection module is specifically configured to Media play command, or restart after a pause, and detect the download rate of the streaming media at the preset time after the start of playback; or, use it to start the streaming media playback command, or restart the playback after a pause, and periodically detect the download rate of the streaming media download rate.
结合第二方面或第二方面的第一或二或三或四或五或六或七或八或九种可能实现方式,在第十种可能实现方式中,所述的流媒体播放装置还包括:In combination with the second aspect or the first or two or three or four or five or six or seven or eight or nine possible implementations of the second aspect, in the tenth possible implementation, the streaming media player further includes :
播放指令接收模块,用于接收流媒体播放指令,并为流媒体播放设定预设大小的流媒体数据存储空间作为播放流媒体初始的流媒体数据的缓存区。The play command receiving module is used to receive the stream media play command, and set the stream media data storage space with a preset size for the stream media play as a buffer area for playing the initial stream media data of the stream media.
结合第二方面的第一或二或三或四或五或六或七或八或九或十种可能实现方式,在第十一种可能实现方式中,所述调整模块,还用于在所述流媒体初始播放或停顿后重启播放过程中,若播放等待时间超过预设等待时间时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。In combination with the first or two or three or four or five or six or seven or eight or nine or ten possible implementation manners of the second aspect, in an eleventh possible implementation manner, the adjustment module is further configured to During the initial playback of the streaming media or restarting the playback after a pause, if the playback waiting time exceeds the preset waiting time, the buffer area occupied by the buffered data in the current buffer area is used as the buffer area of the streaming media data, so as to start playing the streaming media.
结合第二方面,在第十二中能实现方式中,所述调整模块,还用于在流媒体播放过程中,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并在所述缓存变化率增长时,增大流媒体数据的缓存区的大小。With reference to the second aspect, in the twelfth possible implementation manner, the adjustment module is further configured to obtain the buffer change rate in the current buffer area according to the download rate and playback rate during streaming media playback, and When the buffer change rate increases, increase the size of the streaming media data buffer area.
综上,本实施例可基于流媒体的下载速率和播放速率,动态调整流媒体数据的缓存区的大小,在流媒体播放过程中可根据当前流媒体播放情况,将流媒体数据的缓存区调整至合适大小,从而可避免现有流媒体播放中仅采用固定缓存区大小导致的流媒体播放流畅度较差的问题。In summary, this embodiment can dynamically adjust the size of the buffer area of the streaming media data based on the download rate and playback rate of the streaming media, and adjust the buffer area of the streaming media data according to the current streaming media playback situation during the streaming media playback process. to an appropriate size, thereby avoiding the problem of poor fluency of streaming media playback caused by only using a fixed buffer size in existing streaming media playback.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1为本发明实施例一提供的流媒体播放方法的流程示意图;FIG. 1 is a schematic flow diagram of a streaming media playback method provided by Embodiment 1 of the present invention;
图2为本发明实施例二提供的流媒体播放方法的流程示意图;FIG. 2 is a schematic flow diagram of a streaming media playing method provided in Embodiment 2 of the present invention;
图3为本发明实施例三提供的流媒体播放方法的流程示意图;FIG. 3 is a schematic flowchart of a streaming media playback method provided in Embodiment 3 of the present invention;
图4为本发明实施例四提供的流媒体播放方法的流程示意图;FIG. 4 is a schematic flowchart of a streaming media playing method provided in Embodiment 4 of the present invention;
图5为本发明实施例五提供的流媒体播放装置的结构示意图;FIG. 5 is a schematic structural diagram of a streaming media playback device provided in Embodiment 5 of the present invention;
图6为本发明实施例六提供的流媒体播放装置的结构示意图;FIG. 6 is a schematic structural diagram of a streaming media playback device provided in Embodiment 6 of the present invention;
图7为本发明实施例七提供的流媒体播放装置的结构示意图。FIG. 7 is a schematic structural diagram of a streaming media playback device provided by Embodiment 7 of the present invention.
具体实施方式detailed description
本发明实施例提供的流媒体播放方法及装置,可基于流媒体的下载速率以及播放速率,对流媒体数据的缓存区的大小进行实时调整,从而可确保流媒体播放的流畅度,提高用户观看流媒体的体验。The streaming media playback method and device provided by the embodiments of the present invention can adjust the size of the buffer area of the streaming media data in real time based on the download rate and playback rate of the streaming media, thereby ensuring the smoothness of the streaming media playback and improving the user's ability to watch the streaming media. Media experience.
图1为本发明实施例一提供的流媒体播放方法的流程示意图。本实施例应用于流媒体播放中,具体地,播放流媒体的客户端在接收到流媒体播放指令后,即可接收流媒体数据,并可根据流媒体的下载速率以及播放速率来调整用于缓存流媒体数据的缓存区的大小,提高流媒体播放的流畅度,具体地,如图1所示,本实施例方法可包括如下步骤:FIG. 1 is a schematic flowchart of a streaming media playing method provided by Embodiment 1 of the present invention. This embodiment is applied to streaming media playback. Specifically, after receiving a streaming media playback instruction, a client playing streaming media can receive streaming media data, and can adjust the data used for streaming according to the download rate and playback rate of the streaming media. The size of the cache area of cache streaming media data improves the fluency of streaming media playback, specifically, as shown in Figure 1, the method of this embodiment may include the following steps:
步骤101、检测得到流媒体的下载速率;Step 101, detecting the download rate of streaming media;
步骤102、根据下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。Step 102: Adjust the size of the streaming media data buffer area according to the download rate and the streaming media playback rate, wherein the streaming media data buffer area is a data storage space for caching the streaming media data.
本实施例中,客户端需要播放流媒体时,可边接收流媒体数据,边进行流媒体的播放,且在播放流媒体过程中,可基于流媒体的下载速率来调整流媒体数据的缓存区的大小,实现对流媒体数据的缓存区大小的动态调整,这样可避免现有采用单一缓存区大小时,因缓存区的大小设置不合理而导致流媒体初始播放等待时间较长,或者播放停顿后等待时间过长,或者因缓存设置过小而导致频繁停顿等播放问题,可有效提高流媒体播放的流畅度,提高用户观看流媒体的体验。In this embodiment, when the client needs to play streaming media, it can receive streaming data while playing streaming media, and in the process of playing streaming media, it can adjust the buffer area of streaming media data based on the download rate of streaming media The size of the streaming media data buffer area can be dynamically adjusted, which can avoid the unreasonable size setting of the buffer area when the existing single buffer area size is used, resulting in a long waiting time for the initial playback of the streaming media, or after the playback pauses. Playing problems such as too long waiting time or frequent pauses due to too small cache settings can effectively improve the fluency of streaming media playback and improve the user experience of watching streaming media.
本领域技术人员可以理解,流媒体的播放速率可携带在流媒体播放指令下达时,或者在接收到的第一段流媒体数据中解析得到。上述检测得到流媒体的下载速率,具体可以接收到流媒体播放指令后,周期性的检测,并在每一次检测到流媒体的下载速率时,均基于该下载速率来调整流媒体数据的缓存区的大小;或者上述检测得到流媒体的下载速率,也可以是在各播放阶段,例如初始播放、停顿后重启播放或者连续播放一定时间过程中,按照预设时间检测得到,并在检测得到流媒体的下载速率后,基于流媒体下载速率来调整流媒体数据的缓存区的大小。Those skilled in the art can understand that the playback rate of the streaming media can be carried when the streaming media playback instruction is issued, or can be obtained by analyzing the first piece of streaming media data received. The above-mentioned detection obtains the download rate of the streaming media. Specifically, after receiving the streaming media playback instruction, the periodic detection is performed, and each time the download rate of the streaming media is detected, the buffer area of the streaming media data is adjusted based on the download rate. or the download rate of the streaming media obtained from the above detection, can also be detected at each playback stage, such as initial playback, restarting playback after a pause, or continuous playback for a certain period of time, according to the preset time, and when the streaming media is detected. After the download rate is set, the size of the streaming media data buffer area is adjusted based on the streaming media download rate.
综上,本实施例提供的流媒体播放方法,可基于流媒体的下载速率和播放速率,动态调整流媒体数据的缓存区的大小,在流媒体播放过程中可根据当前流媒体播放情况,将流媒体数据的缓存区调整至合适大小,从而可避免现有流媒体播放中仅采用固定缓存区大小导致的流媒体播放流畅度较差的问题。To sum up, the streaming media playback method provided by this embodiment can dynamically adjust the size of the buffer area of streaming media data based on the download rate and playback rate of the streaming media, and can set the The buffer area of streaming media data is adjusted to an appropriate size, so that the problem of poor fluency of streaming media playback caused by only using a fixed buffer size in existing streaming media playback can be avoided.
图2为本发明实施例二提供的流媒体播放方法的流程示意图。本实施例可在接收到流媒体播放指令,流媒体初始播放过程中,基于流媒体的下载速率以及播放速率对流媒体数据的缓存区的大小进行动态调整,以避免流媒体初始播放等待时间过长,具体地,客户端接收到流媒体播放指令后,就可以基于本实施例方法来调整流媒体数据的缓存区的大小,并在缓存区满后,启动播放流媒体,如图2所示,本实施例方法可包括如下步骤:FIG. 2 is a schematic flowchart of a streaming media playing method provided in Embodiment 2 of the present invention. This embodiment can dynamically adjust the size of the buffer area of the streaming media data based on the download rate and playback rate of the streaming media during the initial playback of the streaming media after receiving the streaming media playback instruction, so as to avoid too long waiting time for the initial playback of the streaming media Specifically, after the client receives the streaming media playback instruction, it can adjust the size of the buffer area of the streaming media data based on the method of this embodiment, and start playing the streaming media after the buffer area is full, as shown in Figure 2, The method of this embodiment may include the following steps:
步骤201、接收流媒体播放指令;Step 201, receiving a streaming media playback instruction;
步骤202、检测得到当前流媒体的下载速率;Step 202, detecting the download rate of the current streaming media;
步骤203、判断流媒体的下载速率是否大于或等于流媒体的播放速率,是则执行步骤204,否则,执行步骤207;Step 203, judging whether the download rate of streaming media is greater than or equal to the playback rate of streaming media, if so, execute step 204, otherwise, execute step 207;
步骤204、判断当前缓存区中已缓存数据占用的缓存区的大小是否大于预设的最小缓存长度,是则执行步骤205,否则,执行步骤206;Step 204, judging whether the size of the buffer area occupied by the cached data in the current buffer area is greater than the preset minimum buffer length, if so, execute step 205, otherwise, execute step 206;
步骤205、将当前缓存区中已缓存数据占用的缓存区的大小作为流媒体数据的缓存区,执行步骤216;Step 205, using the size of the buffer area occupied by the cached data in the current buffer area as the buffer area of the streaming media data, and performing step 216;
步骤206、将流媒体数据的缓存区大小调整到预设的最小缓存长度,以便在预设的最小缓存长度的流媒体数据的缓存区满后,执行步骤216;Step 206, adjusting the size of the buffer area of the streaming media data to a preset minimum buffer length, so that after the buffer area of the streaming media data with the preset minimum buffer length is full, perform step 216;
步骤207、判断当前缓存区的缓存变化率是否增加,是则执行步骤208,否则,执行步骤209;Step 207, judging whether the buffer change rate of the current buffer area increases, if yes, execute step 208, otherwise, execute step 209;
步骤208、将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,执行步骤216;Step 208, using the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data, and performing step 216;
步骤209、判断流媒体的下载速率的增长率是否达到预设增长阈值,是则执行步骤210,否则执行步骤211;Step 209, judging whether the growth rate of the download rate of the streaming media reaches the preset growth threshold, if yes, execute step 210, otherwise execute step 211;
步骤210、将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,执行步骤216;Step 210, using the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data, and performing step 216;
步骤211、判断当前缓存区中已缓存的数据B是否满足条件:B>=G*(1-D/K),是则执行步骤212,否则执行步骤213;Step 211, judging whether the cached data B in the current buffer area satisfies the condition: B>=G*(1-D/K), if yes, execute step 212, otherwise execute step 213;
步骤212、将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,执行步骤216;Step 212, using the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data, and performing step 216;
步骤213、判断G*(1-D/K)是否大于流媒体数据的缓存区的最大值,是则执行步骤214,否则,执行步骤215;Step 213, judge whether G*(1-D/K) is greater than the maximum value of the buffer zone of streaming media data, if yes then perform step 214, otherwise, perform step 215;
步骤214、将G*(1-D/K)的长度作为流媒体数据的缓存区的大小,以便在流媒体数据的缓存区满后,执行步骤216;Step 214, use the length of G*(1-D/K) as the size of the buffer area of the streaming media data, so that after the buffer area of the streaming media data is full, execute step 216;
步骤215、将流媒体数据的缓存区的最大值作为流媒体数据的缓存区,以便在流媒体数据的缓存区满后,执行步骤216;Step 215, using the maximum value of the buffer area of the streaming media data as the buffer area of the streaming media data, so that after the buffer area of the streaming media data is full, step 216 is performed;
步骤216、开始播放流媒体。Step 216, start playing streaming media.
上述步骤201中,流媒体初始播放时,会接收流媒体播放指令,并基于流媒体播放指令开始接收流媒体数据,并可在接收到流媒体播放指令后为,为流媒体播放设定预设大小的流媒体数据存储空间,以作为流媒体播放初始的流媒体数据的缓存区。其中,该初始的流媒体数据的缓存区的大小可以为客户端根据当前网络情况设定,或者由客户端默认设定。In the above step 201, when the streaming media is initially played, the streaming media playback instruction will be received, and the streaming media data will be received based on the streaming media playback instruction, and the preset can be set for the streaming media playback after receiving the streaming media playback instruction The size of the streaming media data storage space is used as the buffer area of the initial streaming media data for streaming media playback. Wherein, the size of the initial streaming media data buffer area may be set by the client according to current network conditions, or set by default by the client.
本实施例中,上述步骤202中,流媒体检测得到流媒体的下载速率,具体可以是流媒体播放指令后的预设时间,例如1s后,对流媒体的下载速率进行检测,以得到当前流媒体的下载速率,并基于下载速率调整流媒体数据的缓存区的大小,或者,也可以在接收到流媒体播放指令后,周期性的检测下载速率,以周期性的调整流媒体数据的缓存区的大小。In this embodiment, in the above-mentioned step 202, the download rate of the streaming media is obtained through streaming media detection, which may be the preset time after the streaming media play instruction, for example, after 1 second, the download rate of the streaming media is detected to obtain the current streaming media download rate, and adjust the size of the buffer area of the streaming media data based on the download rate, or, after receiving the streaming media playback instruction, periodically detect the download rate to periodically adjust the size of the buffer area of the streaming media data size.
上述步骤203-步骤205中,当流媒体的下载速率大于播放速率时,说明当前网络资源足够流媒体流畅播放,此时,可将流媒体数据的缓存区大小调整到一个最小值,以减少流媒体初始播放时的等待时间,该最小值即是第一缓存长度,为当前缓存区中已缓存数据占用的缓存区的长度和预设的最小长度的最大值。其中,该预设的最小长度可以是为了避免缓存区数据被快速用完而导致流媒体播放停顿设定的一个保护值,该保护值可以避免网络带宽波动而导致流媒体播放长度,可以设定为可满足流媒体可播放0.5s-2s的缓存区的大小,即在最小缓存长度的缓存区缓存的数据,可以确保流媒体能播放0.5s-2s,该最小缓存长度可以由客户端默认设置,或者也可根据当前网络情况来设定。In the above steps 203-205, when the download rate of streaming media is greater than the playback rate, it means that the current network resources are sufficient for streaming media to play smoothly. At this time, the size of the buffer area of streaming media data can be adjusted to a minimum value to reduce streaming For the waiting time when the media is initially played, the minimum value is the first buffer length, which is the maximum value between the length of the buffer area occupied by the buffered data in the current buffer area and the preset minimum length. Wherein, the preset minimum length can be a protection value set in order to avoid the pause of the streaming media playback caused by the rapid exhaustion of the buffer data. This protection value can avoid the fluctuation of the network bandwidth and cause the streaming media playback length, which can be set In order to meet the size of the streaming media playable buffer area of 0.5s-2s, that is, the data cached in the buffer area of the minimum buffer length can ensure that the streaming media can be played for 0.5s-2s, and the minimum buffer length can be set by the client by default , or it can also be set according to the current network conditions.
上述步骤207和步骤208中,流媒体的下载速率小于播放速率,且当前缓存区的缓存变化率增加时,说明缓存区的缓存量在持续增加,流媒体的下载速率的变化率高于播放速率,此时网络带宽可满足流媒体的播放,从而可将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以进行流媒体播放,可减少流媒体初始播放的等待时间。In the above steps 207 and 208, when the download rate of the streaming media is lower than the playback rate, and the cache change rate of the current buffer area increases, it indicates that the buffer size of the buffer area is continuously increasing, and the change rate of the stream media download rate is higher than the playback rate , at this time, the network bandwidth can meet the streaming media playback, so that the buffer area occupied by the buffered data in the current buffer area can be used as the streaming media data buffer area for streaming media playback, which can reduce the waiting time for the initial streaming media playback.
上述步骤209-步骤210中,流媒体的下载速率小于播放速率,当前缓存区的缓存变化率没有增加,且流媒体的下载速率的增长率达到预设增长阈值时,说明当前流媒体数据传输处于TCP的慢启动区间,网络吞吐率会随着时间快速增长,此时网络可满足流媒体流畅播放。In the above steps 209-210, if the download rate of the streaming media is lower than the playback rate, the cache change rate of the current buffer area does not increase, and when the growth rate of the download rate of the streaming media reaches the preset growth threshold, it means that the current streaming media data transmission is in the In the slow start interval of TCP, the network throughput rate will increase rapidly with time, and the network can satisfy the smooth playback of streaming media at this time.
上述步骤211和步骤214中,流媒体的下载速率小于播放速率,当前缓存区的缓存变化率没有增加,且流媒体的下载速率的增长率未达到预设增长阈值时,说明当前网络吞吐率接近或趋于稳态,且网络带宽小于播放速率,此时,即可根据当前缓存区中已缓存数据是否满足流媒体流畅播放,来确定流媒体数据的缓存区的大小。其中,若B>=G*(1-D/K),则说明当前缓存区中的数据可以满足流媒体流畅播放,所述的G也就是流媒体的播放长度,当缓存区缓存的数据长度满足该公式时,说明缓存的数据可满足流媒体流畅播放,此时可以进行流媒体播放,以减少流媒体初始播放的等待时间,否则,说明缓存区中缓存的流媒体数据无法满足流畅播放,此时就可以步骤211和步骤213来调整缓存区的大小。In the above steps 211 and 214, if the download rate of the streaming media is lower than the playback rate, the cache change rate of the current buffer area does not increase, and the growth rate of the download rate of the streaming media does not reach the preset growth threshold, it means that the current network throughput rate is close to Or it tends to a steady state, and the network bandwidth is lower than the playback rate. At this time, the size of the buffer area of the streaming media data can be determined according to whether the buffered data in the current buffer area satisfies the smooth playback of the streaming media. Among them, if B>=G*(1-D/K), it means that the data in the current buffer area can satisfy the smooth playback of streaming media, and the G is the playback length of streaming media. When this formula is satisfied, it means that the cached data can satisfy the smooth playback of streaming media, and streaming media playback can be performed at this time to reduce the waiting time for the initial playback of streaming media; otherwise, it means that the streaming media data cached in the buffer area cannot satisfy smooth playback. At this point, the size of the buffer area can be adjusted in steps 211 and 213 .
步骤213-步骤215中,通过判断G*(1-D/K)是否大于流媒体数据的缓存区的最大值,确定流媒体数据的缓存区的大小,即将流媒体数据的缓存区的调整为流媒体数据的缓存区的最大值与当前可满足流媒体流畅播放的最小值之间的一个最小值,以减少流媒体初始播放等待时间。In step 213-step 215, by judging whether G*(1-D/K) is greater than the maximum value of the buffer area of streaming media data, determine the size of the buffer area of streaming media data, be about to adjust the buffer area of streaming media data as A minimum value between the maximum value of the streaming media data buffer area and the current minimum value that can satisfy the smooth playback of streaming media, so as to reduce the waiting time for the initial playback of streaming media.
本领域技术人员可以理解,流媒体初始播放时,只要设定的流媒体数据的缓存区数据满时,就可启动播放,因此,通过调整流媒体数据的缓存区的大小,在确保流媒体流畅播放的情况下,可减少初始播放等待时间。Those skilled in the art can understand that when the streaming media is initially played, as long as the buffer area data of the set streaming media data is full, the playback can be started. Therefore, by adjusting the size of the buffer area of the streaming media data, the smooth flow of the streaming media In the case of playback, the initial playback wait time can be reduced.
为便于对本发明实施例技术方案有更好的了解,下面将以流媒体初始播放过程中,周期性的来检测流媒体的下载速率,并基于下载速率周期性的对流媒体数据的缓存区大小进行调整为例,对本发明技术方案进行说明。其中,缓存区的大小以可供流媒体播放的时间来表示;检测流媒体的下载速率的周期性时间设定为tm,即每个tm来检测一次流媒体的下载速率并对流媒体数据的缓存区进行一次调整。In order to have a better understanding of the technical solutions of the embodiments of the present invention, the download rate of the streaming media will be periodically detected during the initial playback of the streaming media, and the buffer size of the streaming media data will be periodically checked based on the download rate. The adjustment is taken as an example to illustrate the technical solution of the present invention. Wherein, the size of the cache area is represented by the time available for streaming media playback; the periodic time for detecting the download rate of the streaming media is set as tm, that is, each tm detects the download rate of the streaming media once and buffers the streaming media data area to make an adjustment.
图3为本发明实施例三提供的流媒体播放方法的流程示意图。如图3所示,本实施例方法可包括如下步骤:FIG. 3 is a schematic flowchart of a method for playing streaming media provided by Embodiment 3 of the present invention. As shown in Figure 3, the method of this embodiment may include the following steps:
步骤301、接收流媒体播放指令,并为流媒体播放设定预设大小的流媒体数据的缓存区,设定播放时间t的初始值为0,并对t开始计时;Step 301, receiving a streaming media playback instruction, and setting a buffer area of streaming media data with a preset size for streaming media playback, setting the initial value of the playback time t to 0, and starting timing for t;
步骤302、判断当前时间t是否等于tm,是则执行步骤303,否则,继续执行步骤302,直到t=tm;Step 302, judging whether the current time t is equal to tm, if so, execute step 303, otherwise, continue to execute step 302 until t=tm;
步骤303、检测得到流媒体的下载速率D,并判断流媒体的下载速率D是否大于流媒体的播放速率K,是则执行步骤304,否则,执行步骤308;Step 303, detect the download rate D of the streaming media, and judge whether the download rate D of the streaming media is greater than the play rate K of the streaming media, if yes, perform step 304, otherwise, perform step 308;
步骤304、将流媒体数据的缓存区的大小调整到Ts=max(t,E);Step 304, adjusting the size of the streaming media data buffer to Ts=max(t, E);
步骤305、判断当前时间t是否大于Ts,是则执行步骤306,否则,执行步骤307;Step 305, judging whether the current time t is greater than Ts, if yes, execute step 306, otherwise, execute step 307;
步骤306、播放流媒体,结束;Step 306, play streaming media, end;
步骤307、判断当前时间t是否等于t’+tm,其中t’为前次检测流媒体的下载速率的时间,是则执行步骤303,否则,继续执行步骤307,直到t为t’+tm;Step 307, judge whether the current time t is equal to t'+tm, wherein t' is the time of the previous detection of the download rate of streaming media, if so, step 303 is performed, otherwise, step 307 is continued until t is t'+tm;
步骤308、判断当前缓存区中的缓存变化率S是否增加,即S(t)是否大于S(t-1),是则执行步骤309,否则,执行步骤310;Step 308, judging whether the buffer change rate S in the current buffer area increases, that is, whether S(t) is greater than S(t-1), if yes, execute step 309, otherwise, execute step 310;
步骤309、将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,执行步骤306;Step 309, using the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data, and performing step 306;
步骤310、判断当前流媒体数据的下载速率的增长率是否呈指数增长,是则执行步骤309,否则,执行步骤311;Step 310, judging whether the growth rate of the download rate of the current streaming media data increases exponentially, if so, execute step 309, otherwise, execute step 311;
步骤311、判断当前时间t是否大于预设等待时间Hs,是,则执行步骤309,否则,执行步骤312;Step 311, judging whether the current time t is greater than the preset waiting time Hs, if yes, execute step 309, otherwise, execute step 312;
步骤312、判断当前缓存区中已缓存的数据B’是否满足条件:B’>=L*(1-D/K),是则执行步骤309,否则,执行步骤313;Step 312, judging whether the buffered data B' in the current buffer area satisfies the condition: B'>=L*(1-D/K), if yes, execute step 309, otherwise, execute step 313;
步骤313、将流媒体数据的缓存区Ts调整到Ts=min(Bmax,L)*(1-D/K),执行步骤305。Step 313 , adjust the buffer area Ts of the streaming media data to Ts=min(Bmax, L)*(1-D/K), and execute step 305 .
上述步骤301中,客户端接收到流媒体播放指令后,就可以为流媒体播放设置预设大小的流媒体数据缓存区,同时对播放时间t进行计时,并按照tm周期进行周期性的检测流媒体的下载速率,并对流媒体数据的缓存区进行周期性的调整。In the above step 301, after the client receives the streaming media playback instruction, it can set a streaming media data buffer area with a preset size for streaming media playback, and at the same time time the playback time t, and periodically detect the streaming media according to the tm cycle The download rate of the media, and periodically adjust the buffer area of the streaming media data.
上述步骤304中,所述的Ts、E均是指流媒体播放的时间,其中,Ts表示缓存区满时可供流媒体播放的时间长度,E则是预设的一个时间,用于表示流媒体播放时缓存区满时可供流媒体播放的最小的时间长度。该E通常设定为0.5s-2s,且该E也可称为保护时间或初始播放的最小时延,用于避免在网络带宽波动情况下,可播放速度大于下载速度时,缓存快速用完而导致播放停顿的问题。In above-mentioned step 304, described Ts, E all refer to the time of streaming media playback, wherein, Ts represents the length of time available for streaming media playback when the buffer area is full, and E is a preset time, used to represent the streaming media playback time. The minimum length of time available for streaming when the buffer is full during media playback. The E is usually set to 0.5s-2s, and this E can also be called the protection time or the minimum delay of the initial playback, which is used to avoid the rapid exhaustion of the cache when the playable speed is greater than the download speed in the case of network bandwidth fluctuations And cause the problem of playback pause.
上述步骤308中,当缓存区中的缓存变化率S增加时,说明下载速率变化率高于播放速率,当前网络带宽可满足流媒体的流畅播放,此时就可以启动播放。In the above step 308, when the buffer change rate S in the buffer area increases, it means that the download rate change rate is higher than the playback rate, and the current network bandwidth can meet the smooth playback of streaming media, and the playback can be started at this time.
上述步骤310中,当流媒体的下载速率呈指数增长,也即下载速率的增长率达到一个预设增长阈值时,就可以确定当前网络带宽处于TCP的慢启动区间,此时网络吞吐率会随时间指数快速增长,可满足流媒体的流畅播放,因此,可启动播放。In the above-mentioned step 310, when the download rate of the streaming media increases exponentially, that is, when the growth rate of the download rate reaches a preset growth threshold, it can be determined that the current network bandwidth is in the slow start interval of TCP, and the network throughput rate will increase accordingly. The time index increases rapidly to meet the smooth playback of streaming media, so playback can be started.
上述步骤311中,所述的等待时间Hs为预设的流媒体初始播放的最大等待时间,当超过该等待时间Hs时,用户的观看流媒体的等待时间过长,将会导致用户观看流媒体的体验极差,因此,在超过该Hs时,就可以直接播放,否则,就可以基于已缓存的流媒体数据的大小,来调整流媒体数据的缓存区的大小。In the above step 311, the waiting time Hs is the preset maximum waiting time for the initial playback of the streaming media. When the waiting time Hs is exceeded, the waiting time for the user to watch the streaming media is too long, which will cause the user to watch the streaming media. Therefore, when the Hs is exceeded, it can be played directly; otherwise, the size of the buffer area of the streaming media data can be adjusted based on the size of the buffered streaming media data.
上述步骤312中,B’是指流媒体数据的缓存区中已缓存的数据可供流媒体播放的时间长度,L就是流媒体的总的播放时长,当B’>=L*(1-D/K)时,说明流媒体数据的缓存区中已缓存的数据可满足流媒体的流畅播放,为减少初始播放等待时间,就可以直接利用已缓存的数据进行播放。In the above-mentioned step 312, B' refers to the length of time that the buffered data in the buffer area of the streaming media data can be played by the streaming media, and L is exactly the total playing time of the streaming media, when B'>=L*(1-D /K), it means that the buffered data in the buffer area of streaming media data can satisfy the smooth playback of streaming media. In order to reduce the initial playback waiting time, the buffered data can be directly used for playback.
上述步骤313中,Bmax是流媒体数据的缓存区的最大值,也可称为客户端可为流媒体播放提供的最大的缓存区。In the above step 313, Bmax is the maximum value of the streaming media data buffer area, and can also be referred to as the largest buffer area that the client can provide for streaming media playback.
本实施例中,当流媒体播放过程中,出现播放停顿需要重启播放时,可执行与上述图2或图3相同的步骤,来调整流媒体数据的缓存区,以减少播放停顿时间,提高重启播放流畅度。此外,在重启播放时,还可根据流媒体停顿次数,来调整当前流媒体数据的缓存区的大小。下面将以具体实例,对流媒体播放过程中因停顿需要重启播放时,流媒体数据的缓存区的调整过程进行说明。In this embodiment, when a playback pause occurs during streaming media playback and playback needs to be restarted, the same steps as those shown in Figure 2 or Figure 3 above can be performed to adjust the buffer area of the streaming media data to reduce the playback pause time and improve the restart time. Play fluency. In addition, when the playback is restarted, the size of the buffer area of the current streaming media data can also be adjusted according to the number of pauses in the streaming media. In the following, a specific example will be used to illustrate the adjustment process of the buffer area of the streaming media data when the streaming media playback needs to be restarted due to a pause.
图4为本发明实施例四提供的流媒体播放方法的流程示意图。如图4所示,本实施例方法可包括如下步骤:FIG. 4 is a schematic flowchart of a method for playing streaming media according to Embodiment 4 of the present invention. As shown in Figure 4, the method of this embodiment may include the following steps:
步骤401、流媒体播放过程中,播放停顿时,记录播放停顿的当前时间t1,并继续对t1进行计时;Step 401, during streaming media playback, when the playback pauses, record the current time t1 of the playback pause, and continue timing t1;
步骤402、在当前时间t是否等于t1+tm,是则执行步骤403,否则,继续执行步骤402,直到t=t1+tm;Step 402, whether the current time t is equal to t1+tm, if yes, execute step 403, otherwise, continue to execute step 402 until t=t1+tm;
步骤403、检测得到流媒体的下载速率D,并判断流媒体的下载速率D是否大于流媒体的播放速率K,是则执行步骤404,否则,执行步骤408;Step 403, detect the download rate D of the streaming media, and judge whether the download rate D of the streaming media is greater than the playback rate K of the streaming media, if yes, perform step 404, otherwise, perform step 408;
步骤404、将流媒体数据的缓存区的大小调整到Tr=max(t-t1,E);Step 404, adjusting the size of the streaming media data buffer to Tr=max(t-t1, E);
步骤405、判断当前时间t是否大于t1+Tr,是则执行步骤406,否则,执行步骤407;Step 405, judging whether the current time t is greater than t1+Tr, if yes, execute step 406, otherwise, execute step 407;
步骤406、播放流媒体,结束;Step 406, play streaming media, end;
步骤407、判断当前时间t是否等于t’+tm,其中t’为前次检测流媒体的下载速率的时间,是则执行步骤403,否则,继续执行步骤407,直到t为t’+tm;Step 407, judge whether the current time t is equal to t'+tm, wherein t' is the time of the previous detection of the download rate of streaming media, if so, step 403 is performed, otherwise, step 407 is continued until t is t'+tm;
步骤408、判断流媒体播放的停顿次数是否超过预设次数n,在停顿次数超过预设次数n时增大当前缓存区的大小,执行步骤409;Step 408, judging whether the number of pauses of streaming media playback exceeds the preset number of times n, increasing the size of the current buffer area when the number of pauses exceeds the preset number of times n, and performing step 409;
步骤409、判断当前缓存区中的缓存变化率S是否增加,即S(t)是否大于S(t-1),是则执行步骤410,否则,执行步骤411;Step 409, judging whether the buffer change rate S in the current buffer area increases, that is, whether S(t) is greater than S(t-1), if yes, execute step 410, otherwise, execute step 411;
步骤410、将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,执行步骤406;Step 410, use the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data, and execute step 406;
步骤411、判断当前流媒体数据的下载速率的增长率是否呈指数增长,是则执行步骤410,否则,执行步骤412;Step 411, judging whether the growth rate of the download rate of the current streaming media data increases exponentially, if yes, execute step 410, otherwise, execute step 412;
步骤412、判断当前时间t是否大于预设等待时间Hr,是,则执行步骤410,否则,执行步骤413;Step 412, judging whether the current time t is greater than the preset waiting time Hr, if yes, execute step 410, otherwise, execute step 413;
步骤413、判断当前缓存区中已缓存的数据B’是否满足条件:Step 413, judging whether the cached data B' in the current buffer area satisfies the condition:
B’>=R*(1-D/K),是则执行步骤410,否则,执行步骤414;B'>=R*(1-D/K), if yes, execute step 410, otherwise, execute step 414;
步骤414、将流媒体数据的缓存区Tr调整到Tr=min(Bmax,R)*(1-D/K),执行步骤405。Step 414 , adjust the buffer area Tr of the streaming media data to Tr=min(Bmax, R)*(1-D/K), and execute step 405 .
本实施例中,上述的Tr为播放停顿而重启播放时的缓存区满时可允许流媒体播放的时长;上述的R为流媒体播放剩余的时间;上述的Hr为播放停顿需要重启播放时,重启播放所设定的重启播放最大时延,若重启播放等待时间超过该Hr,说明播放停顿过长,会影响用户观看体验。In this embodiment, the above-mentioned Tr is the time length that the streaming media can be played when the buffer area is full when the playback is paused and restarted; the above-mentioned R is the remaining time of the streaming media playback; the above-mentioned Hr is when the playback is paused and needs to be restarted. The maximum delay for restarting playback set by restarting playback. If the waiting time for restarting playback exceeds this Hr, it means that the playback pause is too long, which will affect the user's viewing experience.
本实施例可在播放停顿重启播放时,可基于流媒体下载速度以及播放速度,实时对流媒体数据的缓存区的大小进行调整,以减少流媒体重启播放的等待时间。This embodiment can adjust the size of the buffer area of the streaming media data in real time based on the streaming media download speed and playback speed when the playback is paused and restarted, so as to reduce the waiting time for the streaming media to restart playing.
上述步骤408中,可基于播放停顿次数,并在停顿次数大于预设的停顿次数n时,说明播放停顿过多,此时可增加流媒体数据的缓存区的大小,这样,可避免流媒体播放停顿次数过多,影响流媒体播放的流畅度和用户观看效果。In the above step 408, based on the number of playback pauses, and when the number of pauses is greater than the preset number of pauses n, it means that there are too many pauses in playback. At this time, the size of the buffer area of the streaming media data can be increased, so that streaming media playback can be avoided. Too many pauses will affect the fluency of streaming media playback and the viewing effect of users.
上述本发明各实施例中,在流媒体播放过程中,可根据流媒体的下载速率和播放速率获得当前缓存区中的缓存变化率,并在缓存变化率增长时,增大流媒体数据的缓存区的大小。本领域技术人员可以理解,流媒体播放期间,流媒体服务器会通过网络持续发送流数据,而流数据的发送会受TCP滑动窗口大小的限制,且TCP滑动窗口由min(RWD,CWD)决定,其中RWD是接收窗口,CWD是拥塞窗口。在这种情况下,通过调整缓存区的大小,可以避免流媒体播放期间,尽量不要让缓存长度成为下载带宽的限制。In the various embodiments of the present invention described above, in the streaming media playback process, the cache change rate in the current buffer area can be obtained according to the download rate and playback rate of the stream media, and when the cache change rate increases, the cache of the streaming media data is increased. The size of the zone. Those skilled in the art can understand that during streaming media playback, the streaming media server will continue to send streaming data through the network, and the sending of streaming data will be limited by the size of the TCP sliding window, and the TCP sliding window is determined by min(RWD, CWD), Where RWD is the receive window and CWD is the congestion window. In this case, by adjusting the size of the buffer area, it is possible to prevent the length of the buffer from becoming a limitation of the download bandwidth during streaming media playback.
具体地,实际应用中,为保障流媒体的顺畅观看,当网络可用带宽较多时,应该尽可能多地下载以存储足够多的内容,以便当可用带宽短暂减少时,缓存内容不至于被用光,导致播放停顿,因此,本实施例可在缓存的变化率增长时,可将缓存区大小增大到S*R,其中,R为流媒体剩余播放时间,直到S*R等于Bmax。Specifically, in practical applications, in order to ensure the smooth viewing of streaming media, when the available bandwidth of the network is large, it should download as much as possible to store enough content, so that when the available bandwidth is temporarily reduced, the cached content will not be used up , resulting in playback pause, therefore, this embodiment can increase the size of the buffer area to S*R when the change rate of the buffer increases, where R is the remaining playback time of the streaming media until S*R is equal to Bmax.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps for realizing the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
图5为本发明实施例五提供的流媒体播放装置的结构示意图。如图5所示,本实施例装置可包括检测模块11和调整模块12,其中:FIG. 5 is a schematic structural diagram of a streaming media playback device provided by Embodiment 5 of the present invention. As shown in Figure 5, the device of this embodiment may include a detection module 11 and an adjustment module 12, wherein:
检测模块11,用于检测得到流媒体的下载速率;Detection module 11, is used for detecting the download rate that obtains streaming media;
调整模块12,用于根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,所述流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。The adjustment module 12 is used to adjust the size of the buffer area of the streaming media data according to the download rate and the playback rate of the streaming media, wherein the buffer area of the streaming media data is a data storage for caching the streaming media data space.
本实施例流媒体播放装置可基于上述本发明实施例方法来实现对流媒体的播放,并可根据流媒体下载速率动态调整流媒体数据的缓存区的大小,其具体实现可参见上述本发明方法实施例的说明。The streaming media playback device of this embodiment can realize the playback of streaming media based on the method of the above-mentioned embodiment of the present invention, and can dynamically adjust the size of the buffer area of the streaming media data according to the streaming media download rate, and its specific implementation can refer to the implementation of the above-mentioned method of the present invention Example description.
在图5所示的实施例中,上述的调整模块12,具体可用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率大于或等于所述播放速率时,将流媒体数据的缓存区的大小调整到第一缓存长度,以便在所述预设的最小缓存长度的流媒体数据的缓存区满后开始播放流媒体,所述第一缓存长度为所述当前缓存区中已缓存数据占用的缓存区的长度与预设最小缓存长度中的最大值。In the embodiment shown in FIG. 5 , the above-mentioned adjustment module 12 can specifically be used to, during the initial playback of the streaming media or restart playback after a pause, when the download rate is greater than or equal to the playback rate, the streaming media The size of the buffer area of the data is adjusted to the first buffer length, so that the streaming media starts to be played after the buffer area of the streaming media data of the preset minimum buffer length is full, and the first buffer length is in the current buffer area The maximum value between the length of the cache area occupied by the cached data and the preset minimum cache length.
进一步地,上述的调整模块12,还可用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率小于播放速率时,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并根据所述缓存变化率调整所述流媒体数据的缓存区的大小;其中,所述缓存变化率S(t)=D(t)-K(t),其中,D(t)为流媒体的下载速率,K(t)流媒体的播放速率,所述缓存变化率用于表示缓存区中数据增多或减少的变化量。Further, the above-mentioned adjustment module 12 can also be used to obtain the data in the current buffer according to the download rate and the playback rate when the download rate is lower than the playback rate during the initial playback of the streaming media or restarting the playback after a pause. cache change rate, and adjust the size of the buffer area of the streaming media data according to the cache change rate; wherein, the cache change rate S(t)=D(t)-K(t), wherein, D(t ) is the download rate of the streaming media, K(t) is the playback rate of the streaming media, and the change rate of the buffer is used to represent the amount of change in which the data in the buffer increases or decreases.
进一步地,上述的调整模块12,具体可用于在当前缓存区的缓存变化率增加时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。以及用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率达到预设增长阈值时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。Further, the adjustment module 12 mentioned above can be specifically configured to use the buffer area occupied by the buffered data in the current buffer area as the buffer area of the streaming media data when the buffer change rate of the current buffer area increases, so as to start playing the streaming media. And when the rate of change of the current buffer area does not change or decrease, and the growth rate of the download rate reaches a preset growth threshold, the buffer area occupied by the cached data in the current buffer area is used as a buffer for streaming media data zone to start streaming.
进一步地,上述的调整模块12,具体可用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率未达到预设增长阈值或下降时,根据当前缓存区中已缓存的数据的大小,调整所述流媒体数据的缓存区的大小。具体地,调整模块12可用于在当前缓存区中已缓存的数据B满足条件:B>=G*(1-D/K)时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体;其中,所述G为未播放的流媒体的长度,D为下载速率,K为播放速率。以及调整模块12,还可用于当前缓存区缓存的数据B不满足条件:B>=G*(1-D/K),且G*(1-D/K)不大于流媒体数据的缓存区的最大值时,将所述G*(1-D/K)的长度作为流媒体数据的缓存区的大小,以便在所述流媒体数据的缓存区满后开始播放流媒体。Further, the above-mentioned adjustment module 12 can specifically be used to: when the change rate of the current buffer area does not change or decrease, and the growth rate of the download rate does not reach the preset growth threshold or declines, according to the cached data in the current buffer area The size of the data is to adjust the size of the buffer area of the streaming media data. Specifically, the adjustment module 12 may be configured to use the buffer area occupied by the cached data in the current buffer area as A buffer area for streaming media data, so as to start playing streaming media; wherein, the G is the length of the unplayed streaming media, D is the download rate, and K is the playback rate. And the adjustment module 12, the data B that can also be used for the buffering of the current buffer area does not satisfy the condition: B>=G*(1-D/K), and G*(1-D/K) is not greater than the buffer area of streaming media data When the maximum value of , the length of G*(1-D/K) is used as the size of the buffer area of the streaming media data, so as to start playing the streaming media after the buffer area of the streaming media data is full.
进一步地,上述的调整模块12,还可用于在所述流媒体停顿后重启播放时,若停顿次数大于预设停顿阈值时,增大流媒体数据的缓存区的大小。Further, the adjustment module 12 mentioned above can also be used to increase the size of the buffer area of the streaming media data when the playback of the streaming media is restarted after the pause, if the number of pauses is greater than the preset pause threshold.
进一步地,上述的检测模块11,具体可用于在启动流媒体播放指令,或者停顿后重启播放开始后的预设时间检测得到流媒体的下载速率;或者,用于在启动流媒体播放指令,或者停顿后重启播放开始后,周期性的检测得到流媒体的下载速率。Further, the above-mentioned detection module 11 can specifically be used to detect the download rate of the streaming media at the preset time after starting the streaming media playback instruction, or restarting the playback after a pause; or, for starting the streaming media playback instruction, or Restart after a pause After the playback starts, periodically detect the download rate of the streaming media.
进一步地,上述的调整模块12,还可用于在所述流媒体初始播放或停顿后重启播放过程中,若播放等待时间超过预设等待时间时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。Further, the above-mentioned adjustment module 12 can also be used to reset the buffer area occupied by the buffered data in the current buffer area if the playback waiting time exceeds the preset waiting time during the initial playback of the streaming media or restarting the playback after a pause. As a buffer area for streaming media data, in order to start playing streaming media.
进一步地,上述的调整模块12,还可用于在流媒体播放过程中,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并在所述缓存变化率增长时,增大流媒体数据的缓存区的大小。Further, the above-mentioned adjustment module 12 can also be used to obtain the buffer change rate in the current buffer area according to the download rate and playback rate during streaming media playback, and increase the stream rate when the buffer change rate increases. The size of the media data buffer.
图6为本发明实施例六提供的流媒体播放装置的结构示意图。在上述图5所示实施例技术方案基础上,如图6所示,本实施例装置还可包括播放指令接收模块13,用于接收流媒体播放指令,并为流媒体播放设定预设大小的流媒体数据存储空间作为播放流媒体初始的流媒体数据的缓存区。FIG. 6 is a schematic structural diagram of a streaming media playback device provided by Embodiment 6 of the present invention. On the basis of the technical solution of the embodiment shown in FIG. 5 above, as shown in FIG. 6, the device of this embodiment may also include a play instruction receiving module 13 for receiving a streaming media playback instruction and setting a preset size for streaming media playback The streaming media data storage space is used as a buffer area for playing the initial streaming media data of the streaming media.
图7为本发明实施例七提供的流媒体播放装置的结构示意图。如图7所示,本实施例流媒体播放装置可包括处理器10和存储器20,处理器10可通过总线与存储器20连接,其中,存储器20可用于存储指令,处理器10用于执行该指令用于执行相关操作。具体地,处理器10可执行存储器20存储的指令用于检测得到流媒体的下载速率,以及用于根据所述下载速率以及流媒体的播放速率,调整流媒体数据的缓存区的大小,其中,所述流媒体数据的缓存区为用于对流媒体数据进行缓存操作的数据存储空间。FIG. 7 is a schematic structural diagram of a streaming media playback device provided by Embodiment 7 of the present invention. As shown in FIG. 7 , the streaming media playback device of this embodiment may include a processor 10 and a memory 20, the processor 10 may be connected to the memory 20 through a bus, wherein the memory 20 may be used to store instructions, and the processor 10 is used to execute the instructions Used to perform related operations. Specifically, the processor 10 can execute the instructions stored in the memory 20 to detect the download rate of the streaming media, and to adjust the size of the buffer area of the streaming media data according to the download rate and the playback rate of the streaming media, wherein, The streaming media data buffer area is a data storage space for caching the streaming media data.
本实施例中,处理器10具体可用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率大于或等于所述播放速率时,将流媒体数据的缓存区的大小调整到第一缓存长度,以便在所述预设的最小缓存长度的流媒体数据的缓存区满后开始播放流媒体,所述第一缓存长度为所述当前缓存区中已缓存数据占用的缓存区的长度与预设最小缓存长度中的最大值。In this embodiment, the processor 10 can be specifically configured to adjust the size of the buffer area of the streaming media data to The first buffer length, in order to start playing the streaming media after the buffer area of the streaming media data of the preset minimum buffer length is full, the first buffer length is the buffer area occupied by the buffered data in the current buffer area The maximum value between the length and the preset minimum cache length.
进一步地,处理器10还可用于在所述流媒体初始播放或停顿后重启播放过程中,所述下载速率小于播放速率时,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并根据所述缓存变化率调整所述流媒体数据的缓存区的大小;其中,所述缓存变化率S(t)=D(t)-K(t),其中,D(t)为流媒体的下载速率,K(t)流媒体的播放速率,所述缓存变化率用于表示缓存区中数据增多或减少的变化量。Further, the processor 10 can also be used to obtain the buffer change rate in the current buffer according to the download rate and the playback rate when the download rate is lower than the playback rate during the initial playback of the streaming media or restarting playback after a pause. , and adjust the size of the buffer area of the streaming media data according to the cache change rate; wherein, the cache change rate S(t)=D(t)-K(t), where D(t) is the stream The download rate of the media, the play rate of K(t) streaming media, and the change rate of the buffer is used to indicate the amount of change in the increase or decrease of data in the buffer.
进一步地,处理器10还可用于在当前缓存区的缓存变化率增加时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。Further, the processor 10 is further configured to use the buffer area occupied by the buffered data in the current buffer area as a buffer area for streaming media data when the buffer change rate of the current buffer area increases, so as to start playing the streaming media.
进一步地,处理器10还可用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率达到预设增长阈值时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。Further, the processor 10 is further configured to, when the change rate of the current buffer area does not change or decrease, and the growth rate of the download rate reaches a preset growth threshold, set the buffer area occupied by the cached data in the current buffer area to As a buffer area for streaming media data, in order to start playing streaming media.
进一步地,处理器10还可用于在当前缓存区的变化率没有变化或减少,且所述下载速率的增长率未达到预设增长阈值或下降时,根据当前缓存区中已缓存的数据的大小,调整所述流媒体数据的缓存区的大小。Further, the processor 10 is further configured to: when the change rate of the current buffer area does not change or decreases, and the growth rate of the download rate does not reach a preset growth threshold or decreases, according to the size of the cached data in the current buffer area , to adjust the size of the streaming media data buffer.
进一步地,处理器10还可用于在当前缓存区中已缓存的数据B满足条件:B>=G*(1-D/K)时,将所述当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体;其中,所述G为未播放的流媒体的长度,D为下载速率,K为播放速率。Further, the processor 10 can also be used to set the buffer area occupied by the cached data in the current buffer area to As a buffer area for streaming media data, so as to start playing streaming media; wherein, the G is the length of the unplayed streaming media, D is the download rate, and K is the playback rate.
进一步地,处理器10还可用于当前缓存区缓存的数据B不满足条件:B>=G*(1-D/K),且G*(1-D/K)不大于流媒体数据的缓存区的最大值时,将所述G*(1-D/K)的长度作为流媒体数据的缓存区的大小,以便在所述流媒体数据的缓存区满后开始播放流媒体。Further, the processor 10 can also be used for the data B buffered in the current buffer area does not meet the condition: B>=G*(1-D/K), and G*(1-D/K) is not greater than the cache of streaming media data When the maximum value of the area is set, the length of G*(1-D/K) is used as the size of the buffer area of the streaming media data, so as to start playing the streaming media after the buffer area of the streaming media data is full.
本实施例中,处理器10还可用于在所述流媒体停顿后重启播放时,若停顿次数大于预设停顿阈值时,增大流媒体数据的缓存区的大小。In this embodiment, the processor 10 is further configured to increase the size of the buffer area of the streaming media data when the streaming media is paused and the playback is restarted, if the number of pauses is greater than a preset pause threshold.
本实施例中,处理器10还可用于在启动流媒体播放指令,或者停顿后重启播放开始后的预设时间检测得到流媒体的下载速率;或者,在启动流媒体播放指令,或者停顿后重启播放开始后,周期性的检测得到流媒体的下载速率。In this embodiment, the processor 10 can also be used to detect the download rate of the streaming media at a preset time after starting the streaming media playback instruction, or restarting the playback after a pause; or, starting the streaming media playback instruction, or restarting after a pause After the playback starts, periodically detect the download rate of the streaming media.
本实施例中,处理器10还可用于接收流媒体播放指令,并为流媒体播放设定预设大小的流媒体数据存储空间作为播放流媒体初始的流媒体数据的缓存区。In this embodiment, the processor 10 may also be configured to receive a streaming media playing instruction, and set a preset size of streaming media data storage space for streaming media playing as a buffer area for initially playing streaming media data.
本实施例中,处理器10还可用于在所述流媒体初始播放或停顿后重启播放过程中,若播放等待时间超过预设等待时间时,将当前缓存区中已缓存数据占用的缓存区作为流媒体数据的缓存区,以便开始播放流媒体。In this embodiment, the processor 10 is further configured to use the buffer area occupied by the buffered data in the current buffer area as The buffer area of streaming media data, in order to start playing streaming media.
本实施例中,处理器10还可用于在流媒体播放过程中,根据所述下载速率和播放速率获得当前缓存区中的缓存变化率,并在所述缓存变化率增长时,增大流媒体数据的缓存区的大小。In this embodiment, the processor 10 can also be used to obtain the buffer change rate in the current buffer area according to the download rate and playback rate during streaming media playback, and increase the streaming media rate when the buffer change rate increases. The size of the data buffer.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.
Claims (24)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210562414.4A CN103051955B (en) | 2012-12-21 | 2012-12-21 | Flow media playing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210562414.4A CN103051955B (en) | 2012-12-21 | 2012-12-21 | Flow media playing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103051955A CN103051955A (en) | 2013-04-17 |
CN103051955B true CN103051955B (en) | 2016-08-03 |
Family
ID=48064436
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210562414.4A Expired - Fee Related CN103051955B (en) | 2012-12-21 | 2012-12-21 | Flow media playing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103051955B (en) |
Families Citing this family (30)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104185285A (en) * | 2013-05-28 | 2014-12-03 | 华为技术有限公司 | Media data transmission method, device and system |
CN103856558B (en) * | 2014-01-22 | 2017-07-14 | 北京京东尚科信息技术有限公司 | A kind of data processing method and device for terminal applies |
CN105227588A (en) * | 2014-05-28 | 2016-01-06 | 中国移动通信集团公司 | A kind of method for down loading of files in stream media and user terminal |
CN104639977B (en) * | 2015-02-05 | 2018-05-08 | 小米科技有限责任公司 | The method and device that program plays |
CN105991477B (en) * | 2015-02-11 | 2019-07-19 | 腾讯科技(深圳)有限公司 | A kind of method of adjustment and device in voice jitter buffer area |
CN106067870A (en) * | 2015-04-22 | 2016-11-02 | 北京邮电大学 | Portable medical stream media data dispatching method based on mix of priorities and system |
CN104811751B (en) * | 2015-04-28 | 2018-08-28 | 深圳市优网科技有限公司 | A kind of interim card recognition methods when streaming media playing and device |
CN105100876B (en) * | 2015-08-28 | 2019-04-12 | 北京奇艺世纪科技有限公司 | A kind of playback method and device of Streaming Media |
CN106559684B (en) * | 2015-09-30 | 2019-12-20 | 中国电信股份有限公司 | Method, terminal and system for reducing live broadcast delay |
CN105430475A (en) * | 2015-11-04 | 2016-03-23 | 北京奇虎科技有限公司 | Video data buffering method and device |
CN106713948B (en) * | 2015-11-13 | 2019-10-11 | 北京国双科技有限公司 | Video segmentation loading method and device |
CN106911656A (en) * | 2015-12-23 | 2017-06-30 | 北京奇虎科技有限公司 | A kind of data download method and device |
CN105657523B (en) | 2016-01-28 | 2019-11-08 | 腾讯科技(深圳)有限公司 | The method and apparatus that video preloads |
CN105898536A (en) * | 2016-04-29 | 2016-08-24 | 乐视控股(北京)有限公司 | Video play method and device |
CN107731243B (en) * | 2016-08-12 | 2020-08-07 | 电信科学技术研究院 | Voice real-time variable-speed playing method and device |
EP4228275A3 (en) * | 2016-11-03 | 2023-10-11 | Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. | Network-based download/streaming concept |
CN106792139A (en) * | 2017-02-24 | 2017-05-31 | 腾讯科技(深圳)有限公司 | A kind of data dispatching method and data dispatch equipment |
CN107205160A (en) * | 2017-06-27 | 2017-09-26 | 青岛海信电器股份有限公司 | A kind of player method and device of the video issued for server |
CN107948713B (en) * | 2017-10-31 | 2020-10-27 | 北京飞利信电子技术有限公司 | Delayed live broadcasting method and system |
CN108282690A (en) * | 2018-01-26 | 2018-07-13 | 广东欧珀移动通信有限公司 | Network video downloading method and device and computer readable storage medium |
CN108810656B (en) * | 2018-06-12 | 2021-10-26 | 深圳国微视安科技有限公司 | Real-time live broadcast TS (transport stream) jitter removal processing method and processing system |
CN109040231B (en) * | 2018-07-31 | 2021-06-11 | 优视科技新加坡有限公司 | Data transmission method, device, equipment/terminal/server and computer readable storage medium |
CN109327716B (en) | 2018-10-31 | 2020-09-11 | 北京达佳互联信息技术有限公司 | Delay control method, delay control apparatus, and computer-readable storage medium |
CN109600676A (en) * | 2018-12-17 | 2019-04-09 | 北京金山云网络技术有限公司 | A kind of data buffering method and device |
CN111339351B (en) * | 2018-12-19 | 2023-08-11 | 成都鼎桥通信技术有限公司 | Audio playing method in Android system |
CN109672745A (en) * | 2018-12-29 | 2019-04-23 | 苏州思必驰信息科技有限公司 | The online control method for playing back of audio and device for FreeRTOS |
CN110351595B (en) * | 2019-07-17 | 2023-08-18 | 北京百度网讯科技有限公司 | Buffer processing method, device, equipment and computer storage medium |
US12284416B2 (en) | 2020-02-04 | 2025-04-22 | Dolby International Ab | Method and device for adaptive playout of media content |
CN115798492A (en) * | 2021-09-13 | 2023-03-14 | 北京字跳网络技术有限公司 | Audio playing method and equipment |
CN114727128B (en) * | 2022-03-30 | 2024-04-12 | 恒玄科技(上海)股份有限公司 | Data transmission method and device of playing terminal, playing terminal and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1798097A (en) * | 2004-12-24 | 2006-07-05 | 腾讯科技(深圳)有限公司 | Method for buffering data in stream media |
CN101321286A (en) * | 2008-06-27 | 2008-12-10 | 上海华为技术有限公司 | A method and device for calculating terminal cache size |
CN101583025A (en) * | 2009-06-11 | 2009-11-18 | 中兴通讯股份有限公司 | Streaming media playing method and device |
CN101702711A (en) * | 2009-10-30 | 2010-05-05 | 中兴通讯股份有限公司 | Method and terminal for playing data |
CN102413379A (en) * | 2011-11-29 | 2012-04-11 | 中国传媒大学 | Starting delaying method for streaming media live broadcasting system |
CN102665131A (en) * | 2012-04-27 | 2012-09-12 | 山东省计算中心 | Video buffer method for receiving end of network video service system |
-
2012
- 2012-12-21 CN CN201210562414.4A patent/CN103051955B/en not_active Expired - Fee Related
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1798097A (en) * | 2004-12-24 | 2006-07-05 | 腾讯科技(深圳)有限公司 | Method for buffering data in stream media |
CN101321286A (en) * | 2008-06-27 | 2008-12-10 | 上海华为技术有限公司 | A method and device for calculating terminal cache size |
CN101583025A (en) * | 2009-06-11 | 2009-11-18 | 中兴通讯股份有限公司 | Streaming media playing method and device |
CN101702711A (en) * | 2009-10-30 | 2010-05-05 | 中兴通讯股份有限公司 | Method and terminal for playing data |
CN102413379A (en) * | 2011-11-29 | 2012-04-11 | 中国传媒大学 | Starting delaying method for streaming media live broadcasting system |
CN102665131A (en) * | 2012-04-27 | 2012-09-12 | 山东省计算中心 | Video buffer method for receiving end of network video service system |
Non-Patent Citations (1)
Title |
---|
基于P2P技术的流媒体系统研究与实现;蔡幸波;《中国优秀博硕士学位论文全文数据库(硕士) 信息科技辑》;20070615(第6期);文献第10页至第11页第1段、第16页 * |
Also Published As
Publication number | Publication date |
---|---|
CN103051955A (en) | 2013-04-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103051955B (en) | Flow media playing method and device | |
CN102204272B (en) | A processing method after a playing timepoint in streaming media jumps and a device thereof | |
US7870281B2 (en) | Content playback device, content playback method, computer-readable storage medium, and content playback system | |
CN103152651B (en) | A kind of automatic adjustment streaming media buffer district plays the method and system of thresholding | |
CN108271048B (en) | A bit rate adaptive adjustment device and method for both throughput and video buffering | |
US6665751B1 (en) | Streaming media player varying a play speed from an original to a maximum allowable slowdown proportionally in accordance with a buffer state | |
US9781183B2 (en) | Accelerated playback of streaming media | |
CN107154918B (en) | Video live broadcast transmission control method and system based on PID control | |
CN105430475A (en) | Video data buffering method and device | |
CN112702649B (en) | A method for optimizing the smoothness of live video playback on a mobile terminal, a storage medium, and an electronic device | |
CN100461757C (en) | Real-time streaming media transmission method and system | |
JP2014505425A (en) | System and method for adaptive bitrate streaming based on stream delay and channel rate | |
JP5421346B2 (en) | High-speed transmission method and apparatus for unicast stream in high-speed channel change | |
US9379990B2 (en) | System and method for streaming a media file from a server to a client device | |
JP2008187723A (en) | Improved start-up method and apparatus for use in streaming content | |
CN110022498B (en) | A method and device for realizing code rate switching | |
CN106331766A (en) | Video file playing method and device | |
CN100473160C (en) | A buffer control method for multimedia data | |
TW200926806A (en) | Content reproduction apparatus, content reproduction method, and content reproduction system | |
CN106851337B (en) | Video buffering control method and device | |
CN104581340B (en) | Client, stream medium data method of reseptance and stream medium data transmission system | |
JP7162019B2 (en) | DATA STREAMING METHOD, DATA STREAMING DEVICE, AND COMPUTER PROGRAM | |
WO2015074623A1 (en) | Video playback method, apparatus and intelligent terminal | |
JP6099715B2 (en) | Streaming media playback apparatus, streaming media playback method, and program | |
CN115336283A (en) | Low latency content delivery |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20160803 |