Movatterモバイル変換


[0]ホーム

URL:


CN108668146A - A method and device for adjusting streaming media code rate - Google Patents

A method and device for adjusting streaming media code rate
Download PDF

Info

Publication number
CN108668146A
CN108668146ACN201710190142.2ACN201710190142ACN108668146ACN 108668146 ACN108668146 ACN 108668146ACN 201710190142 ACN201710190142 ACN 201710190142ACN 108668146 ACN108668146 ACN 108668146A
Authority
CN
China
Prior art keywords
code rate
terminal device
candidate
duration
server
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.)
Granted
Application number
CN201710190142.2A
Other languages
Chinese (zh)
Other versions
CN108668146B (en
Inventor
白天
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co LtdfiledCriticalHuawei Technologies Co Ltd
Priority to CN201710190142.2ApriorityCriticalpatent/CN108668146B/en
Publication of CN108668146ApublicationCriticalpatent/CN108668146A/en
Application grantedgrantedCritical
Publication of CN108668146BpublicationCriticalpatent/CN108668146B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

A kind of method and apparatus of adjustment streaming media bit rate, this method may include:The resource request of server receiving terminal equipment, the resource request include the caching duration of smoothing code rate and the terminal device buffer area, and the smooth code check is the matched code check of downloading rate with the current foradownloaded video film source of the terminal device;The server determines target fragment from the current video film source to be played of the terminal device, the target fragment is sent to the terminal device, the code check of the target fragment is less than the smooth code check, and the prediction downloading duration of the target fragment is less than the caching duration.By using the program, server can provide the fragment adapted to terminal device for terminal device in real time, ensure the broadcasting continuity of Streaming Media.

Description

Translated fromChinese
一种调整流媒体码率的方法及设备A method and device for adjusting streaming media code rate

技术领域technical field

本申请涉及直播视频处理技术领域,尤其涉及一种调整流媒体码率的方法及设备。The present application relates to the technical field of live video processing, and in particular to a method and device for adjusting the code rate of streaming media.

背景技术Background technique

在互联网和多媒体技术应用中,用户可以通过智能电视、手机等视频播放终端设备从互联网上在线获取视频,由于从互联网上获取的视频是通过公网进行数据传输,当网络抖动、网络时延波动比较大等现象导致网络传输速率抖动时,终端设备就需要不间断的缓冲视频,这样便导致视频画面不断卡顿。目前主要采用自适应流媒体传输技术,在自适应传输系统中,服务器将同一份视频编成不同的码率,且将视频切成多个分片。在视频流的传输过程中可根据网络带宽、缓存大小等因素,动态调整资源比特率来为终端设备提供与当前网络状态适应的视频流传输速率,使得在网络环境较差时也能达到的最佳播放体验。终端设备可向服务器请求不同码率的分片,例如终端设备在根据当前网络带宽的码率和本地缓存计算出平滑码率后,向服务器请求下载接近平滑码率的分片,从而实现动态码率切换。In the application of the Internet and multimedia technology, users can obtain videos online from the Internet through video playback terminal devices such as smart TVs and mobile phones. Since the videos obtained from the Internet are transmitted through the public network, when the network jitters and the network delay fluctuates When the network transmission rate fluctuates due to relatively large phenomena, the terminal device needs to buffer the video uninterruptedly, which will cause the video picture to freeze continuously. At present, the adaptive streaming media transmission technology is mainly used. In the adaptive transmission system, the server encodes the same video into different bit rates, and cuts the video into multiple fragments. During the transmission of video streams, the resource bit rate can be dynamically adjusted according to factors such as network bandwidth and cache size to provide terminal devices with a video stream transmission rate adapted to the current network status, so that the best possible performance can be achieved even when the network environment is poor. best playback experience. The terminal device can request fragments with different code rates from the server. For example, after the terminal device calculates the smooth code rate based on the code rate of the current network bandwidth and the local cache, it requests the server to download fragments close to the smooth code rate, so as to realize dynamic code rate switching.

但终端设备计算的平滑码率值和实际下载的播放分片的实际码率误差很大,导致客户端的播放缓存发生欠载,出现播放卡顿,影响用户体验。由于目前主流的片源编码器采用VBR模式进行媒体编码,即片源的媒体码率不固定,而在服务器下发的片源码率描述文件中的媒体码率是分片的平均码率。客户端会将计算出的平滑码率与分片的平均码率进行比较,若平滑码率大于平均码率,客户端就会进行码率的上切(是指调高码率),以从服务器获取更高码率的分片。但是,若原来的分片的实际码率远高于平均码率,客户端再进行上切,这样就会出现客户端的缓存数据耗尽后,分片还未下载完成的情况,最终导致播放卡顿,当卡顿后,可能又会触发客户端进行码率下切,如此,下切之后上切,上切完因为卡顿又下切,可以将该种现象称之为乒乓效应。However, there is a large error between the smoothed bit rate value calculated by the terminal device and the actual bit rate of the actually downloaded playback segment, which causes the client's playback cache to be underloaded and playback freezes, affecting user experience. Since the current mainstream video encoders use the VBR mode for media encoding, that is, the media bit rate of the video source is not fixed, and the media bit rate in the video source bit rate description file delivered by the server is the average bit rate of the fragments. The client will compare the calculated smooth bit rate with the average bit rate of the slice. If the smooth bit rate is greater than the average bit rate, the client will perform an up-cut of the bit rate (referring to increase the bit rate) to from The server obtains fragments with a higher bit rate. However, if the actual bit rate of the original fragment is much higher than the average bit rate, the client will perform an upscaling, which will cause the situation that the fragment has not been downloaded after the client's cache data is exhausted, which will eventually cause the player to be stuck. Pause, when the freeze occurs, the client may be triggered to perform bit rate downcutting. In this way, downcutting is followed by upcutting, and downcutting occurs again after upcutting. This phenomenon can be called a ping-pong effect.

发明内容Contents of the invention

本申请提供了一种调整流媒体码率的方法及设备,能够解决现有技术中采用自适应流媒体传输技术进行直播视频时的乒乓效应的问题。The present application provides a method and device for adjusting the code rate of streaming media, which can solve the problem of ping-pong effect when using adaptive streaming media transmission technology for live video in the prior art.

本申请第一方面提供一种调整流媒体码率的方法,该方法包括:The first aspect of the present application provides a method for adjusting the bit rate of streaming media, the method comprising:

终端设备在计算出平滑码率后向服务器发送资源请求,所述资源请求主要包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,该平滑码率能够适应当前带宽,是当前终端设备播放视频片源的最佳理想码率,终端设备使用该平滑码率播放视频,则不会出现卡顿现象。After the terminal device calculates the smooth code rate, it sends a resource request to the server. The resource request mainly includes the smooth code rate and the cache duration of the buffer area of the terminal device. The smooth code rate is the same as that of the video clip currently downloaded by the terminal device. The bit rate that matches the download rate of the source. This smooth bit rate can adapt to the current bandwidth and is the best ideal bit rate for the current terminal device to play the video source. If the terminal device uses this smooth bit rate to play the video, there will be no freeze phenomenon. .

服务器在接收终端设备的资源请求后,可在数据库中找到所述终端设备当前待播放的视频片源,然后从所述终端设备当前待播放的视频片源中确定目标分片,再将所述目标分片发送至所述终端设备。其中,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。After receiving the resource request of the terminal device, the server can find the video source to be played by the terminal device in the database, then determine the target segment from the video source to be played by the terminal device, and then The target segment is sent to the terminal device. Wherein, the code rate of the target segment is smaller than the smoothed code rate, and the predicted download duration of the target segment is smaller than the cache duration.

现有机制中,客户端只能将平滑码率与分片的平均码率进行比较,最终导致码率切换的乒乓效应。与现有机制相比,本申请中则是服务器在接收终端设备发送的包括平滑码率和缓存时长的资源请求后,从视频片源中确定目标分片,然后所述服务器将该目标分片发送给所述终端设备。可见,由于服务器发送给终端设备的目标分片的码率小于所述平滑码率,并且该目标分片的预测下载时长小于所述缓存时长,所以最终发送给终端设备的目标分片是满足当前流畅播放的条件的,能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。In the existing mechanism, the client can only compare the smoothed code rate with the average code rate of the slice, which eventually leads to a ping-pong effect of code rate switching. Compared with the existing mechanism, in this application, the server determines the target fragmentation from the video source after receiving the resource request sent by the terminal device, including smooth code rate and cache duration, and then the server determines the target fragmentation sent to the terminal device. It can be seen that since the code rate of the target segment sent by the server to the terminal device is lower than the smoothed code rate, and the predicted download duration of the target segment is shorter than the cache duration, the target segment finally sent to the terminal device meets the current The conditions for smooth playback can provide the terminal equipment with fragments adapted to the terminal equipment in real time, ensure the continuity of streaming media playback, and also reduce the playback freeze caused by dynamic bit rate switching during streaming media playback The problem is to maximize the use of network bandwidth resources.

在一些可能的设计中,所述服务器从所述终端设备当前待播放的视频片源中确定目标分片,将所述目标分片发送给所述终端设备的具体过程可以参考如下1-3所描述的操作:In some possible designs, the server determines the target segment from the video source currently to be played by the terminal device, and the specific process of sending the target segment to the terminal device can refer to the following 1-3 Operation described:

1、所述服务器从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率。1. The server selects a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes at least two Fragmentation information of the fragments, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of the fragmentation.

可选的,所述码率集合可由所述资源请求携带的指示信息指示,或者所述码率集合可由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。下面分别进行说明:Optionally, the code rate set may be indicated by the indication information carried in the resource request, or the code rate set may be a code rate set selected by the server from the slice information set according to the smoothed code rate. Instructions are given below:

(a)、码率集合由终端设备提供(a), the code rate set is provided by the terminal device

终端设备在发送资源请求之前,可从服务器获取上述分片信息集合,然后终端设备计算出平滑码率,再将平滑码率与分片信息集合中的各码率进行比较,最终可以确定出低于所述平滑码率的码率的码率集合,最后将指示所述码率集合的信息或者所述码率集合携带在资源请求中。Before the terminal device sends a resource request, it can obtain the above fragmentation information set from the server, and then the terminal device calculates the smoothed code rate, and then compares the smoothed code rate with each code rate in the fragmentation information set, and finally can determine the low Based on the code rate set of the code rate of the smoothed code rate, finally, the information indicating the code rate set or the code rate set is carried in the resource request.

可见,由终端设备为服务器提供上述码率集合,能够减少服务器侧在确定目标分片时,只需要遍历码率集合中的码率即可。当然,若由服务器来确定上述码率集合,那么,(a)种方式中,由终端设备直接提供的话,就不需要由服务器去从分片信息集合中比较一遍了。由此可见,采用本方案,可有效减少服务器的运算量,进而提高运算效率,最终使得服务器能够快速的定位到目标分片。It can be seen that the above code rate set is provided by the terminal device to the server, which can reduce the server side only needing to traverse the code rates in the code rate set when determining the target slice. Of course, if the above code rate set is determined by the server, then, in the method (a), if it is directly provided by the terminal device, there is no need for the server to compare it from the slice information set. It can be seen that the adoption of this solution can effectively reduce the calculation amount of the server, thereby improving the calculation efficiency, and finally enabling the server to quickly locate the target segment.

(b)、码率集合由服务器提供(b), the code rate set is provided by the server

若上述码率集合由服务器确定,那么,服务器只需要从终端设备处获取的平滑码率就可以确定出上述码率集合,且服务器确定码率集合的方式与终端设备相同,此处不作赘述。If the above code rate set is determined by the server, then the server only needs to obtain the smooth code rate from the terminal device to determine the above code rate set, and the method of determining the code rate set by the server is the same as that of the terminal device, which will not be repeated here.

服务器在确定码率集合后,就可以通过遍历码率集合来确定目标分片了,通过缩小码率的搜索范围,这样在确定目标分片时,就不需要将平滑码率分别与分片信息集合中的每个码率都遍历一遍,只需要遍历码率集合中的码率即可。由此可见,采用本方案,可有效减少服务器的运算量,进而提高运算效率,最终使得服务器能够快速的定位到目标分片。After the server determines the code rate set, it can determine the target fragment by traversing the code rate set. By narrowing the search range of the code rate, it is not necessary to separate the smoothed code rate from the fragment information when determining the target fragment. Each code rate in the collection is traversed once, and only the code rates in the code rate collection need to be traversed. It can be seen that the adoption of this solution can effectively reduce the calculation amount of the server, thereby improving the calculation efficiency, and finally enabling the server to quickly locate the target segment.

2、所述服务器从码率集合中选择候选码率后,可根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率。可选的,所述平均速率可在所述资源请求携带,或者由所述服务器统计得到。2. After the server selects a candidate code rate from the code rate set, the predicted download time of the candidate fragment can be obtained according to the average rate and the fragment size of the target fragment corresponding to the candidate code rate. The average rate The current average rate of downloading fragments for the terminal device. Optionally, the average rate may be carried in the resource request, or obtained by statistics of the server.

3、在得到所述候选分片的预测下载时长后,所述服务器判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则服务器从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率,并且重复前面所述的“计算候选分片的预测下载时长和判断候选分片的预测下载时长是否大于所述缓存时长”的操作,直至找到预测下载时长小于缓存时长的候选分片。3. After obtaining the predicted download duration of the candidate segment, the server judges whether the predicted download duration of the candidate segment is greater than the cache duration, and if the predicted download duration is greater than the cache duration, the server starts from Select a code rate lower than the candidate code rate in the code rate set as the candidate code rate, and repeat the above-mentioned "calculating the predicted download duration of the candidate fragment and judging the predicted download duration of the candidate fragment" Is it greater than the cache duration" operation until a candidate fragment whose predicted download duration is less than the cache duration is found.

相应的,若所述候选分片的预测下载时长小于所述缓存时长,则所述服务器将所述候选分片作为所述目标分片发送至所述终端设备。Correspondingly, if the predicted download duration of the candidate segment is less than the cache duration, the server sends the candidate segment as the target segment to the terminal device.

在一些可能的设计中,在同时有很多终端设备向服务器请求视频片源资源时,为减少服务器侧的判断时长,若所述候选分片的预测下载时长大于所述缓存时长,服务器可直接从所述终端设备当前待播放的视频片源中选择至少一个与所述候选分片属于相同视频片源且码率低于所述候选分片的分片。然后,所述服务器将请求响应发送至所述终端设备,其中,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址,以供终端设备直接下载。可选的,请求响应中可以携带与所述候选分片所属视频片源中码率最低的分片的下载地址,这样可以保证终端设备侧可以流畅的播放该分片。通过这种处理机制,可进一步优化服务器侧对多个终端设备的响应,这样可以提高服务器的处理效率,同时也减少终端设备侧的等待时长。In some possible designs, when there are many terminal devices requesting video source resources from the server at the same time, in order to reduce the judgment time on the server side, if the predicted download time of the candidate segment is longer than the cache time, the server can directly download from the The terminal device selects at least one segment that belongs to the same video source as the candidate segment and has a bit rate lower than the candidate segment among the video sources currently to be played by the terminal device. Then, the server sends a request response to the terminal device, wherein the request response carries a download address of a segment that belongs to the same video source as the candidate segment and has a code rate lower than the candidate segment, for direct download by terminal devices. Optionally, the request response may carry the download address of the segment with the lowest code rate among the video sources to which the candidate segment belongs, so as to ensure that the segment can be played smoothly on the terminal device side. Through this processing mechanism, the response of the server side to multiple terminal devices can be further optimized, so that the processing efficiency of the server can be improved, and the waiting time of the terminal device side can also be reduced.

在一些可能的设计中,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,一种实施方式中,该字段可以为动态请求(dynamic-request)。如果dynamic-request指示的值为1时,则表示当前采用码率自适应模式,那么服务器就需要进行动态码率切换,可通过资源请求的前两个扩展头域识别出当前与终端设备的下载速率最匹配的分片,并将该分片返回给终端设备。如果dynamic-request指示的值为0时,则表示当前未采用码率自适应模式(例如用户在终端设备的客户端上手动关闭了码率自适应的功能),那么服务器在收到该资源请求后,就不需要进行动态码率切换。In some possible designs, the resource request further includes a field for indicating whether the server switches to the code rate adaptive mode. In one implementation manner, this field may be a dynamic request (dynamic-request). If the value indicated by dynamic-request is 1, it means that the code rate adaptive mode is currently used, then the server needs to perform dynamic code rate switching, and the current download with the terminal device can be identified through the first two extension header fields of the resource request. The fragment with the best matching rate is returned to the terminal device. If the value indicated by dynamic-request is 0, it means that the code rate adaptation mode is not currently used (for example, the user manually turns off the code rate adaptation function on the client of the terminal device), then the server receives the resource request After that, there is no need for dynamic code rate switching.

在一些可能的设计中,考虑到终端设备发出资源请求至服务器计算候选分片的预测下载时长期间,终端设备的缓存区的缓存会存在一些消耗,所以,为提高服务器侧确定目标分片的准确度,还需要考虑该期间终端设备缓存区的缓存消耗量。由此,终端设备可在所述资源请求携带指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。该估计值可以是经验值,也可是终端设备根据当前的播放速率动态计算出,具体本申请不作限定,这样服务器在比较预测下载时长与缓存时长时,减去该缓存偏移量即可。In some possible designs, considering that during the period from the terminal device sending a resource request to the server calculating the predicted download time of candidate fragments, there will be some consumption in the buffer cache of the terminal device. Therefore, in order to improve the accuracy of determining the target fragment on the server side In this period, the buffer consumption of the terminal device buffer area also needs to be considered. Therefore, the terminal device may carry a field indicating a cache offset in the resource request, and the cache offset refers to a period from when the terminal device sends the resource request to when the server receives the resource request, Estimated value of buffer consumption for the end device buffer. The estimated value can be an empirical value, or it can be dynamically calculated by the terminal device according to the current playback rate, which is not limited in this application. In this way, when the server compares the predicted download duration with the cache duration, it only needs to subtract the cache offset.

本申请第二方面提供一种调整流媒体码率的方法,所述方法包括:The second aspect of the present application provides a method for adjusting the bit rate of streaming media, the method comprising:

终端设备获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The terminal device acquires the current smoothed code rate and fragmentation information set, the smoothed code rate is a code rate that matches the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two fragments Fragmentation information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;

所述终端设备从所述分片信息集合中确定目标码率,将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。The terminal device determines a target code rate from the fragmentation information set, and sends a resource request to the server, the target code rate is less than the smoothed code rate, and the prediction of the target fragment corresponding to the target code rate The download duration is shorter than the current cache duration in the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.

现有机制中,客户端只能将平滑码率与分片的平均码率进行比较,最终导致码率切换的乒乓效应。与现有机制相比,本申请所提供的方案中,终端设备获取平滑码率和分片信息集合后,可从分片信息集合中选择小于所述平滑码率的目标码率,当确定选中的目标码率对应的目标分片的预测下载时长小于当前的缓存时长时,就表示该目标码率适应当前的带宽,所以终端设备可以将该目标码率携带在资源请求中发送给服务器,最终得到合适的目标分片。可见终端设备通过将目标分片的预测下载时长与缓存时长进行比较,能够准确的判断自身计算出的目标码率所对应的目标分片是否满足当前流畅播放的条件,以便服务器能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。In the existing mechanism, the client can only compare the smoothed code rate with the average code rate of the slice, which eventually leads to a ping-pong effect of code rate switching. Compared with the existing mechanism, in the solution provided by this application, after the terminal device obtains the smooth code rate and fragmentation information set, it can select a target code rate less than the smooth code rate from the fragmentation information set. When the predicted download duration of the target segment corresponding to the target code rate is less than the current cache duration, it means that the target code rate is suitable for the current bandwidth, so the terminal device can carry the target code rate in the resource request and send it to the server. Get the appropriate target shard. It can be seen that by comparing the predicted download duration of the target segment with the cache duration, the terminal device can accurately judge whether the target segment corresponding to the target bit rate calculated by itself satisfies the current smooth playback conditions, so that the server can provide real-time information for the terminal device. Provide fragments adapted to the terminal equipment to ensure the continuity of streaming media playback, and also reduce the problem of playback freezes caused by dynamic bit rate switching during streaming media playback, and maximize the use of network bandwidth resources.

在一些可能的设计中,在所述终端设备获取当前的平滑码率和分片信息集合之后,所述终端设备从所述分片信息集合中确定目标码率之前,所述终端设备还可从所述分片信息集合中确定低于所述平滑码率的码率集合,在确定码率集合后,终端设备就可以确定目标分片了,通过缩小码率的搜索范围,这样在确定目标分片时,就不需要将平滑码率分别与分片信息集合中的每个码率都遍历一遍,只需要遍历码率集合中的码率即可。由此可见,采用本方案,可有效减少运算量,也能提高运算效率。In some possible designs, after the terminal device acquires the current smooth code rate and fragmentation information set, before the terminal device determines the target code rate from the fragmentation information set, the terminal device can also obtain the The code rate set lower than the smooth code rate is determined in the fragmentation information set. After the code rate set is determined, the terminal device can determine the target fragmentation. By narrowing the search range of the code rate, the target fragmentation In slice time, there is no need to traverse the smoothed code rate and each code rate in the slice information set, but only need to traverse the code rates in the code rate set. It can be seen that, adopting this solution can effectively reduce the calculation amount and improve the calculation efficiency.

在一些可能的设计中,所述终端设备从所述分片信息集合中确定目标码率,将资源请求发送至所述服务器,可包括:In some possible designs, the terminal device determines the target code rate from the fragmentation information set, and sends the resource request to the server, which may include:

所述终端设备从所述码率集合中选择候选码率,然后根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长。The terminal device selects a candidate code rate from the code rate set, and then obtains the predicted download duration of the candidate segment according to the segment size of the candidate segment corresponding to the candidate code rate and the average rate.

在得到所述候选分片的预测下载时长后,所述终端设备判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率,重复执行上述“计算候选分片的预测下载时长和判断候选分片的预测下载时长是否大于所述缓存时长”的操作,直至找到预测下载时长小于缓存时长的候选分片对应的目标码率。After obtaining the predicted download duration of the candidate segment, the terminal device judges whether the predicted download duration of the candidate segment is greater than the cache duration, if the predicted download duration of the candidate segment is greater than the cache duration, Then select a code rate lower than the candidate code rate from the fragment set as the candidate code rate, and repeat the above "calculating the predicted download duration of the candidate fragment and judging whether the predicted download duration of the candidate fragment is greater than the specified "cache duration" until the target code rate corresponding to the candidate segment whose predicted download duration is less than the cache duration is found.

若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, the candidate code rate is used as the target code rate, and the resource request is sent to the server, and the resource request is used to request to download the The target slice corresponding to the target code rate.

在一些可能的设计中,除了终端设备自行确定目标分片,还可以由服务器来确定,那么,终端设备就需要为服务器提供与确定目标分片相关的参数。具体来说,所述终端设备在从分片信息集合中选择小于所述平滑码率的码率之后,可向所述服务器发送另一资源请求,所述另一资源请求可包括所述平滑码率和所述终端设备缓存区的缓存时长。In some possible designs, in addition to determining the target segment by the terminal device itself, the server may also determine the target segment. Then, the terminal device needs to provide the server with parameters related to determining the target segment. Specifically, after the terminal device selects a code rate smaller than the smooth code rate from the slice information set, it may send another resource request to the server, and the other resource request may include the smooth code rate rate and the cache duration of the terminal device cache.

之后,所述服务器在接收到上述另一资源请求后,从分片信息集合中选择小于所述平滑码率的码率,当确定选中的码率对应的分片的预测下载时长小于所述终端设备缓存区当前的缓存时长时,所述服务器将预测下载时长小于所述缓存时长的分片发送给所述终端设备。Afterwards, after receiving the above-mentioned another resource request, the server selects a code rate smaller than the smooth code rate from the fragment information set, and when it is determined that the predicted download duration of the fragment corresponding to the selected code rate is shorter than the terminal When the current cache duration in the device cache area is lower than the cache duration, the server sends the fragments whose download duration is predicted to be shorter than the cache duration to the terminal device.

对服务器来说,如何根据终端设备发送的另一资源请求来确定目标分片的具体操作可参考上述第一方面所述的技术方案,此处不作赘述。For the specific operation of how to determine the target segment according to another resource request sent by the terminal device, for the server, reference may be made to the technical solution described in the first aspect above, which will not be repeated here.

需要说明的是,对于是否由终端设备来确定目标分片,还是由服务器来确定目标分片,可以优先由终端设备来确定目标分片,这样可以有效的降低服务器的运算负荷,也能提高确定与实际下载速率匹配的目标分片的准确率。终端设备可以主动执行确定目标码率的操作;也可以是在用户关闭了码率动态切换的功能时,为服务器提供运算的参数,最终由服务器来确定目标分片;还可以是,不考虑用户是否关闭码率动态切换的功能,终端设备都可主动为服务器提供运算的参数,最终由服务器来确定目标分片;当然也可以是在终端设备无法正确的确定目标码率时,向服务器发出上述另一资源请求。It should be noted that, as to whether the target slice is determined by the terminal device or the server determines the target slice, the target slice can be determined by the terminal device first, which can effectively reduce the computing load of the server and improve the determination of the target slice. Accuracy of target shards matched to actual download rate. The terminal device can actively perform the operation of determining the target code rate; it can also provide calculation parameters for the server when the user turns off the dynamic switching function of the code rate, and finally the server determines the target fragmentation; it can also be that the user is not considered Whether to disable the function of dynamic code rate switching, the terminal device can actively provide computing parameters for the server, and finally the server determines the target fragmentation; of course, when the terminal device cannot correctly determine the target code rate, it can send the above-mentioned Another resource request.

可选的,为了减少服务器的运算,终端设备还可在所述另一资源请求携带用于指示所述分片信息集合中低于所述平滑码率的码率集合的信息,使得服务器可以小范围的去确定候选码率、减少判断候选分片的预测下载时长是否小于缓存时长的次数等操作,最终使得服务器能够快速的定位到目标分片。Optionally, in order to reduce the calculation of the server, the terminal device may also carry information indicating a code rate set in the fragmentation information set that is lower than the smooth code rate in the another resource request, so that the server can reduce A wide range of operations such as determining the candidate code rate and reducing the number of times to judge whether the predicted download duration of the candidate segment is less than the cache duration will ultimately enable the server to quickly locate the target segment.

可选的,所述另一资源请求还包括所述终端设备当前下载分片的平均速率,所述平均速率用于所述服务器计算分片的预测下载时长。Optionally, the other resource request further includes an average rate at which the terminal device currently downloads segments, and the average rate is used by the server to calculate a predicted download duration of segments.

可选的,考虑到终端设备发出上述另一资源请求至服务器计算候选分片的预测下载时长期间,终端设备的缓存区的缓存会存在一些消耗,所以,为提高服务器侧确定目标分片的准确度,还需要考虑该期间终端设备缓存区的缓存消耗量。由此,终端设备可在上述另一资源请求携带指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送上述另一资源请求到所述服务器接收到所述另一资源请求期间,所述终端设备缓存区的缓存消耗的估计值。该估计值可以是经验值,也可是终端设备根据当前的播放速率动态计算出,具体本申请不作限定,这样服务器在比较预测下载时长与缓存时长时,减去该缓存偏移量即可。Optionally, considering that during the period from the terminal device sending the above another resource request to the server calculating the predicted download duration of the candidate segment, there will be some consumption in the cache area of the terminal device, so in order to improve the accuracy of determining the target segment on the server side In this period, the buffer consumption of the terminal device buffer area also needs to be considered. Therefore, the terminal device may carry a field indicating a cache offset in the above-mentioned another resource request, and the cache offset refers to the time when the terminal device sends the above-mentioned another resource request to the time when the server receives the other resource request. The estimated value of the buffer consumption of the terminal device buffer during the resource request. The estimated value can be an empirical value, or it can be dynamically calculated by the terminal device according to the current playback rate, which is not limited in this application. In this way, when the server compares the predicted download duration with the cache duration, it only needs to subtract the cache offset.

本申请第三方面提供一种服务器,具有实现对应于上述第一方面提供的调整流媒体码率的方法的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的模块,所述模块可以是软件和/或硬件。The third aspect of the present application provides a server, which has the function of implementing the method corresponding to the method for adjusting the code rate of streaming media provided in the first aspect. The functions described above may be implemented by hardware, or may be implemented by executing corresponding software on the hardware. Hardware or software includes one or more modules corresponding to the above functions, and the modules may be software and/or hardware.

一种可能的设计中,所述服务器可包括:In a possible design, the server may include:

收发模块,用于接收终端设备的资源请求,所述资源请求包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率;A transceiver module, configured to receive a resource request from a terminal device, where the resource request includes a smoothed code rate and a cache duration of the buffer area of the terminal device, and the smoothed code rate is the same as the download rate of the currently downloaded video source of the terminal device matching code rate;

处理模块,用于从所述终端设备当前待播放的视频片源中确定目标分片,通过所述收发模块将所述目标分片发送至所述终端设备,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。A processing module, configured to determine a target segment from the video source currently to be played by the terminal device, and send the target segment to the terminal device through the transceiver module, and the code rate of the target segment is less than In the smooth code rate, the predicted download duration of the target segment is less than the cache duration.

可选的,所述处理模块具体用于:Optionally, the processing module is specifically used for:

从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;Select a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes fragments of at least two fragments information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes the code rate of fragmentation size and fragmentation;

根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率;Obtain the predicted download duration of the candidate fragment according to the fragment size of the target fragment corresponding to the average rate and the candidate code rate, and the average rate is the average rate of the terminal device currently downloading the fragment;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration is greater than the cache duration, select a code rate lower than the code rate of the candidate fragment from the code rate set As the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则通过所述收发模块将所述候选分片作为所述目标分片发送至所述终端设备。If the predicted download duration of the candidate segment is less than the buffer duration, the candidate segment is sent to the terminal device as the target segment by the transceiver module.

可选的,所述码率集合由所述资源请求携带的指示信息指示,或者所述码率集合由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。Optionally, the code rate set is indicated by the indication information carried in the resource request, or the code rate set is a code rate set selected by the server from the slice information set according to the smoothed code rate.

可选的,所述平均速率在所述资源请求携带,或者由所述服务器统计得到。Optionally, the average rate is carried in the resource request, or obtained by statistics of the server.

可选的,所述处理模块还用于:Optionally, the processing module is also used for:

若所述候选分片的预测下载时长大于所述缓存时长,则通过所述收发模块将请求响应发送至所述终端设备,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址。If the predicted download duration of the candidate segment is longer than the buffer duration, the request response is sent to the terminal device through the transceiver module, and the request response carries the same video source as the candidate segment and the code The download address of the segment whose rate is lower than the candidate segment.

可选的,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,和/或,所述资源请求还包括指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。Optionally, the resource request further includes a field for indicating whether the server switches to a code rate adaptive mode, and/or, the resource request further includes a field indicating a cache offset, and the cache offset The amount refers to an estimated value of cache consumption of the cache area of the terminal device during the period from when the terminal device sends the resource request to when the server receives the resource request.

另一种可能的设计中,所述服务器包括:In another possible design, the server includes:

至少一个处理器、存储器和收发器;at least one processor, memory and transceiver;

其中,所述存储器用于存储程序代码,所述处理器用于调用所述存储器中的程序代码来执行以下操作:Wherein, the memory is used to store program codes, and the processor is used to call the program codes in the memory to perform the following operations:

通过所述收发器接收终端设备的资源请求,所述资源请求包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率;The resource request of the terminal device is received by the transceiver, the resource request includes a smooth code rate and the buffer duration of the buffer area of the terminal device, and the smooth code rate is the same as the download rate of the video source currently downloaded by the terminal device matching code rate;

从所述终端设备当前待播放的视频片源中确定目标分片,通过所述收发器将所述目标分片发送至所述终端设备,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。Determine the target segment from the video source currently to be played by the terminal device, and send the target segment to the terminal device through the transceiver, and the code rate of the target segment is smaller than the smooth code rate , the predicted download duration of the target segment is less than the cache duration.

可选的,所述处理器具体用于:Optionally, the processor is specifically used for:

从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;Select a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes fragments of at least two fragments information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes the code rate of fragmentation size and fragmentation;

根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率;Obtain the predicted download duration of the candidate fragment according to the fragment size of the target fragment corresponding to the average rate and the candidate code rate, and the average rate is the average rate of the terminal device currently downloading the fragment;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration is greater than the cache duration, select a code rate lower than the code rate of the candidate fragment from the code rate set As the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则通过所述收发器将所述候选分片作为所述目标分片发送至所述终端设备。If the predicted download duration of the candidate segment is less than the buffer duration, the candidate segment is sent to the terminal device as the target segment by the transceiver.

可选的,所述码率集合由所述资源请求携带的指示信息指示,或者所述码率集合由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。Optionally, the code rate set is indicated by the indication information carried in the resource request, or the code rate set is a code rate set selected by the server from the slice information set according to the smoothed code rate.

可选的,所述平均速率在所述资源请求携带,或者由所述服务器统计得到。Optionally, the average rate is carried in the resource request, or obtained by statistics of the server.

可选的,所述处理器还用于:Optionally, the processor is also used for:

若所述候选分片的预测下载时长大于所述缓存时长,则通过所述收发器将请求响应发送至所述终端设备,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址。If the predicted download duration of the candidate segment is longer than the buffer duration, the request response is sent to the terminal device through the transceiver, and the request response carries the same video source as the candidate segment and the code The download address of the segment whose rate is lower than the candidate segment.

可选的,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,和/或,所述资源请求还包括指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。Optionally, the resource request further includes a field for indicating whether the server switches to a code rate adaptive mode, and/or, the resource request further includes a field indicating a cache offset, and the cache offset The amount refers to an estimated value of cache consumption of the cache area of the terminal device during the period from when the terminal device sends the resource request to when the server receives the resource request.

本申请第四方面提供一种终端设备,具有实现对应于上述第二方面提供的调整流媒体码率的方法的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的模块,所述模块可以是软件和/或硬件。A fourth aspect of the present application provides a terminal device, which has a function of implementing the method corresponding to the method for adjusting a stream media code rate provided in the above second aspect. The functions described above may be implemented by hardware, or may be implemented by executing corresponding software on the hardware. Hardware or software includes one or more modules corresponding to the above functions, and the modules may be software and/or hardware.

一种可能的设计中,所述终端设备可包括:In a possible design, the terminal device may include:

收发模块,用于获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The transceiver module is used to obtain the current smooth code rate and fragmentation information set, the smooth code rate matches the code rate of the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two The fragmentation information of fragments, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;

处理模块,用于从所述收发模块获取的所述分片信息集合中确定目标码率,通过所述收发模块将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。a processing module, configured to determine a target code rate from the fragmentation information set acquired by the transceiver module, and send a resource request to the server through the transceiver module, where the target code rate is less than the smoothed code rate, The predicted download duration of the target segment corresponding to the target code rate is less than the current buffer duration of the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.

可选的,所述处理模块在所述收发模块获取当前的平滑码率和分片信息集合之后,在从所述分片信息集合中确定目标码率之前,还用于:Optionally, the processing module is further configured to: after the transceiver module obtains the current smooth code rate and fragmentation information set, and before determining the target code rate from the fragmentation information set:

从所述分片信息集合中确定低于所述平滑码率的码率集合。Determining a code rate set lower than the smoothed code rate from the slice information set.

可选的,所述处理模块具体用于:Optionally, the processing module is specifically used for:

从所述码率集合中选择候选码率;Select a candidate code rate from the code rate set;

根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长;Obtaining the predicted download duration of the candidate fragments according to the fragment size of the candidate fragments corresponding to the candidate code rate and the average rate;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration of the candidate fragment is greater than the cache duration, then select the candidate fragment lower than the candidate fragment from the fragment set The code rate is used as the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,通过所述收发模块将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, then use the candidate code rate as the target code rate, and send the resource request to the server through the transceiver module, and the resource request It is used to request to download the target segment corresponding to the target code rate.

另一种可能的设计中,所述终端设备包括:In another possible design, the terminal device includes:

至少一个处理器、存储器和收发器;at least one processor, memory and transceiver;

其中,所述存储器用于存储程序代码,所述处理器用于调用所述存储器中的程序代码来执行以下操作:Wherein, the memory is used to store program codes, and the processor is used to call the program codes in the memory to perform the following operations:

通过所述收发器获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;Obtain the current smooth code rate and fragmentation information set through the transceiver, the smooth code rate matches the code rate of the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two The fragmentation information of fragments, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;

从通过所述收发器获取的所述分片信息集合中确定目标码率,通过所述收发器将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。Determine a target code rate from the fragmentation information set obtained through the transceiver, send a resource request to the server through the transceiver, the target code rate is less than the smoothed code rate, and the target code rate is The predicted download duration of the target segment corresponding to the code rate is less than the current buffer duration of the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.

可选的,所述处理器在所述收发器获取当前的平滑码率和分片信息集合之后,在从所述分片信息集合中确定目标码率之前,还用于:Optionally, after the transceiver acquires the current smooth code rate and fragmentation information set, and before determining the target code rate from the fragmentation information set, the processor is further configured to:

从所述分片信息集合中确定低于所述平滑码率的码率集合。Determining a code rate set lower than the smoothed code rate from the slice information set.

可选的,所述处理处理器具体用于:Optionally, the processing processor is specifically used for:

从所述码率集合中选择候选码率;Select a candidate code rate from the code rate set;

根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长;Obtaining the predicted download duration of the candidate fragments according to the fragment size of the candidate fragments corresponding to the candidate code rate and the average rate;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration of the candidate fragment is greater than the cache duration, then select the candidate fragment lower than the candidate fragment from the fragment set The code rate is used as the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,通过所述收发器将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, then use the candidate code rate as the target code rate, and send the resource request to the server through the transceiver, and the resource request It is used to request to download the target segment corresponding to the target code rate.

本申请的又一方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面所述的方法。Yet another aspect of the present application provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, it causes the computer to execute the methods described in the above aspects.

相较于现有技术,本申请提供的方案中,服务器在接收终端设备发送的包括平滑码率和缓存时长的资源请求后,从视频片源中确定目标分片,然后所述服务器将该目标分片发送给所述终端设备。可见,由于服务器发送给终端设备的目标分片的码率小于所述平滑码率,并且该目标分片的预测下载时长小于所述缓存时长,所以最终发送给终端设备的目标分片是满足当前流畅播放的条件的,能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。Compared with the prior art, in the solution provided by this application, after receiving the resource request sent by the terminal device, the server determines the target segment from the video source, and then the server determines the target segment The fragments are sent to the terminal device. It can be seen that since the code rate of the target segment sent by the server to the terminal device is lower than the smoothed code rate, and the predicted download duration of the target segment is shorter than the cache duration, the target segment finally sent to the terminal device meets the current The conditions for smooth playback can provide the terminal equipment with fragments adapted to the terminal equipment in real time, ensure the continuity of streaming media playback, and also reduce the playback freeze caused by dynamic bit rate switching during streaming media playback The problem is to maximize the use of network bandwidth resources.

附图说明Description of drawings

图1为本发明实施例中的一种网络拓扑结构示意图;FIG. 1 is a schematic diagram of a network topology in an embodiment of the present invention;

图2为本发明实施例中的调整流媒体码率的一种流程示意图;Fig. 2 is a kind of schematic flow chart of adjusting streaming media code rate in the embodiment of the present invention;

图3为本发明实施例中的调整流媒体码率的另一种流程示意图;Fig. 3 is another schematic flow chart of adjusting the code rate of streaming media in the embodiment of the present invention;

图4为本发明实施例中的调整流媒体码率的另一种流程示意图;Fig. 4 is another schematic flow chart of adjusting the code rate of streaming media in the embodiment of the present invention;

图5为本发明实施例中的调整流媒体码率的另一种流程示意图;Fig. 5 is another schematic flow chart of adjusting the code rate of streaming media in the embodiment of the present invention;

图6为本发明实施例中的调整流媒体码率的装置的一种结构示意图;FIG. 6 is a schematic structural diagram of a device for adjusting a stream media code rate in an embodiment of the present invention;

图7为本发明实施例中的执行调整流媒体码率的装置的实体装置的一种结构示意图。FIG. 7 is a schematic structural diagram of a physical device executing a device for adjusting a code rate of streaming media in an embodiment of the present invention.

具体实施方式Detailed ways

本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或模块的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或模块,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或模块,本申请中所出现的模块的划分,仅仅是一种逻辑上的划分,实际应用中实现时可以有另外的划分方式,例如多个模块可以结合成或集成在另一个系统中,或一些特征可以忽略,或不执行,另外,所显示的或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,模块之间的间接耦合或通信连接可以是电性或其他类似的形式,本申请中均不作限定。并且,作为分离部件说明的模块或子模块可以是也可以不是物理上的分离,可以是也可以不是物理模块,或者可以分布到多个电路模块中,可以根据实际的需要选择其中的部分或全部模块来实现本申请方案的目的。The terms "first", "second" and the like in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or modules is not necessarily limited to the expressly listed Those steps or modules, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or equipment, and the division of modules presented in this application is only a logical division , there may be another way of division when implemented in practical applications, for example, multiple modules may be combined or integrated in another system, or some features may be ignored, or not implemented. In addition, the shown or discussed mutual The coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection between modules may be electrical or other similar forms, which are not limited in this application. Moreover, the modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed into multiple circuit modules, and some or all of them may be selected according to actual needs module to achieve the purpose of this application scheme.

本申请供了一种调整流媒体码率的方法及设备,可用于直播技术领域。以下进行详细说明。图1为流媒体传输的一种网络拓扑图,服务器端存储各种视频片源,每种视频片源包括多个不同码率的分片,服务器可用于创建客户端、配置客户端的各种信息以及处理终端设备上针对客户端的各种请求,此外,还可用于保存使用客户端的用户的操作数据。终端设备上安装了交客户端,可响应于用户针对客户端的各种操作指令,能够与服务器进行交互。The present application provides a method and equipment for adjusting the code rate of streaming media, which can be used in the technical field of live broadcasting. The details will be described below. Figure 1 is a network topology diagram of streaming media transmission. The server stores various video sources. Each video source includes multiple fragments with different bit rates. The server can be used to create clients and configure various information of clients. And process various requests for the client on the terminal device, in addition, it can also be used to save the operation data of the user who uses the client. The communication client is installed on the terminal device, which can respond to various operation instructions of the user on the client, and can interact with the server.

本申请中,终端设备可向服务器发送资源请求以请求不同码率的分片,然后在终端设备上安装的客户端上播放。In this application, the terminal device can send resource requests to the server to request fragments with different code rates, and then play them on the client installed on the terminal device.

其中,需要特别说明的是,本申请涉及的服务器可以为代理服务器,网页服务器等。本申请涉及的终端设备,可以是指向用户提供语音和/或数据连通性的设备,具有无线连接功能的手持式设备、或连接到无线调制解调器的其他处理设备。无线终端可以经无线接入网(英文全称:Radio Access Network,英文简称:RAN)与一个或多个核心网进行通信,无线终端可以是移动终端,如移动电话(或称为“蜂窝”电话)和具有移动终端的计算机,例如,可以是便携式、袖珍式、手持式、计算机内置的或者车载的移动装置,它们与无线接入网交换语音和/或数据。例如,个人通信业务(英文全称:Personal Communication Service,英文简称:PCS)电话、无绳电话、会话发起协议(SIP)话机、无线本地环路(Wireless LocalLoop,英文简称:WLL)站、个人数字助理(英文全称:Personal Digital Assistant,英文简称:PDA)等设备。无线终端也可以称为系统、订户单元(Subscriber Unit)、订户站(Subscriber Station),移动站(Mobile Station)、移动台(Mobile)、远程站(RemoteStation)、接入点(Access Point)、远程终端(Remote Terminal)、接入终端(AccessTerminal)、用户终端(User Terminal)、终端设备、用户代理(User Agent)、用户设备(UserDevice)、或用户装备(User Equipment)。Wherein, it should be specially noted that the server involved in this application may be a proxy server, a webpage server, and the like. The terminal device involved in this application may be a device that provides voice and/or data connectivity to users, a handheld device with a wireless connection function, or other processing devices connected to a wireless modem. The wireless terminal can communicate with one or more core networks via the radio access network (English full name: Radio Access Network, English abbreviation: RAN), and the wireless terminal can be a mobile terminal, such as a mobile phone (or called a "cellular" phone) And computers with mobile terminals, such as portable, pocket, hand-held, built-in computer or vehicle-mounted mobile devices, which exchange voice and/or data with the radio access network. For example, Personal Communication Service (English full name: Personal Communication Service, English abbreviation: PCS) telephone, cordless telephone, Session Initiation Protocol (SIP) telephone, Wireless Local Loop (Wireless Local Loop, English abbreviation: WLL) station, personal digital assistant ( English full name: Personal Digital Assistant, English abbreviation: PDA) and other equipment. The wireless terminal can also be called a system, a subscriber unit (Subscriber Unit), a subscriber station (Subscriber Station), a mobile station (Mobile Station), a mobile station (Mobile), a remote station (RemoteStation), an access point (Access Point), a remote Terminal (Remote Terminal), access terminal (AccessTerminal), user terminal (User Terminal), terminal equipment, user agent (User Agent), user equipment (UserDevice), or user equipment (User Equipment).

由于采用自适应流媒体传输技术进行直播视频时,客户端所选择的要切换的码率的准确度不高,会产生码率切换的乒乓效应。为解决上述技术问题,本申请主要提供以下技术方案:Since the adaptive streaming media transmission technology is used for live video, the accuracy of the code rate to be switched selected by the client is not high, and a ping-pong effect of code rate switching will occur. In order to solve the above technical problems, the application mainly provides the following technical solutions:

方案一:由服务器根据终端设备提供的平滑码率和缓存区的缓存时长,以及终端设备当前下载分片的平均速率,来预测选择的待下载分片的码率是否会在消耗完缓存区中缓存之前完成下载。Option 1: The server predicts whether the code rate of the selected segment to be downloaded will be consumed in the buffer area based on the smooth bit rate provided by the terminal device and the cache duration of the buffer area, as well as the average rate of the current download segment of the terminal device. Complete download before caching.

方案二:由终端设备计算出平滑码率和平均速率后,自行预测选择的待下载分片的码率是否会在消耗完缓存区中缓存之前完成下载。Solution 2: After calculating the smooth bit rate and average bit rate by the terminal device, predict whether the selected bit rate of the segment to be downloaded will be downloaded before the buffer in the buffer area is consumed.

通过上述方案一和方案二,均可解决进行直播视频时的乒乓效应的问题,提高动态切换码率的准确性和终端设备播放分片的连续性和稳定性,方案一和方案二也可交替进行,具体本申请不作限定。Through the above schemes 1 and 2, the problem of ping-pong effect during live video can be solved, the accuracy of dynamic switching bit rate can be improved and the continuity and stability of fragmentation played by terminal devices can be improved. Scheme 1 and scheme 2 can also be alternated. The specific application is not limited.

可以理解的是,本申请中的服务器和终端设备可称为用于调整流媒体码率的装置,该装置可以是设置在装置端,在有些场景下,也可以设置在终端设备中作为具备调整流媒体码率功能的客户端,本申请的下述实施例主要是以该装置设置于服务器端和终端设备端分别作为服务端为例,若该装置为设置于终端设备中的客户端,那么,在调整流媒体码率时,调整流媒体码率的操作均可由该客户端完成,具体该装置设置于哪些类型的设备,本申请不作限定。It can be understood that the server and terminal equipment in this application can be referred to as a device for adjusting the bit rate of streaming media. The device can be set on the device side, and in some scenarios, it can also be set in the terminal For the client side of the streaming media code rate function, the following embodiments of the present application are mainly based on the device being set on the server side and the terminal equipment side as the server respectively. If the device is a client terminal set up in the terminal equipment, then , when adjusting the bit rate of the streaming media, the operation of adjusting the bit rate of the streaming media can be completed by the client, and the specific types of devices where the device is set are not limited by this application.

参照图2,以下从服务器确定目标分片的角度,对本申请提供的调整流媒体码率的方法进行举例说明,本方法实施例主要包括:With reference to Fig. 2, the method for adjusting the bit rate of streaming media provided by the application is illustrated below from the perspective of the server determining the target fragmentation, and the method embodiment mainly includes:

201、终端设备计算出平滑码率和当前终端设备缓存区的缓存时长。201. The terminal device calculates the smoothed code rate and the buffer duration of the current terminal device buffer area.

所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,该平滑码率能够适应当前带宽,是当前终端设备播放视频片源的最佳理想码率,终端设备使用该平滑码率播放视频,则不会出现卡顿现象。The smooth code rate matches the download rate of the video source currently downloaded by the terminal device. The smooth code rate can adapt to the current bandwidth and is the best ideal code rate for the current terminal device to play the video source. The terminal device If you play the video with this smooth bit rate, there will be no stuttering.

所述缓存时长则是指当前终端设备缓存区中的剩余的数据缓存容量,也可以称为数据时长,可播放的时长或者数据缓存量。需要说明的是,本申请中的资源请求可采用超文本传输协议(英文全称:HyperText Transfer Protocol,英文简称:HTTP)作为请求下载分片的协议,终端设备可向服务器发送HTTP GET请求,在该HTTP GET请求中可携带两个扩展头字段:avg-download-rate(表示当前终端设备下载分片的平均速率),以及buffer-length(表示当前终端设备缓存区的缓存时长)。本申请中终端设备的缓存区中的缓存数据是指客户端当前播放的视频片源的视频数据。The cache duration refers to the remaining data cache capacity in the buffer area of the current terminal device, which may also be referred to as data duration, playable duration or data cache volume. It should be noted that the resource request in this application can use Hypertext Transfer Protocol (full English name: HyperText Transfer Protocol, English abbreviation: HTTP) as the protocol for requesting to download fragments, and the terminal device can send an HTTP GET request to the server. Two extended header fields can be carried in the HTTP GET request: avg-download-rate (represents the average rate at which the current terminal device downloads fragments), and buffer-length (represents the cache duration of the current terminal device buffer area). In this application, the cache data in the cache area of the terminal device refers to the video data of the video source currently played by the client.

202、终端设备向服务器发送资源请求。202. The terminal device sends a resource request to the server.

所述资源请求主要包括平滑码率和所述终端设备缓存区的缓存时长。The resource request mainly includes the smooth code rate and the buffer duration of the terminal device buffer.

203、服务器接收终端设备的资源请求,在数据库中找到所述终端设备当前待播放的视频片源。203. The server receives the resource request of the terminal device, and finds the video source currently to be played by the terminal device in the database.

204、服务器从所述终端设备当前待播放的视频片源中确定目标分片,再将所述目标分片发送至所述终端设备。204. The server determines a target segment from the video source currently to be played by the terminal device, and then sends the target segment to the terminal device.

其中,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。Wherein, the code rate of the target segment is smaller than the smoothed code rate, and the predicted download duration of the target segment is smaller than the cache duration.

205、终端设备接收服务器发送的目标分片。205. The terminal device receives the target segment sent by the server.

现有机制中,客户端只能将平滑码率与分片的平均码率进行比较,最终导致码率切换的乒乓效应。与现有机制相比,本申请中则是服务器在接收终端设备发送的包括平滑码率和缓存时长的资源请求后,从视频片源中确定目标分片,然后所述服务器将该目标分片发送给所述终端设备。可见,由于服务器发送给终端设备的目标分片的码率小于所述平滑码率,并且该目标分片的预测下载时长小于所述缓存时长,所以最终发送给终端设备的目标分片是满足当前流畅播放的条件的,能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。In the existing mechanism, the client can only compare the smoothed code rate with the average code rate of the slice, which eventually leads to a ping-pong effect of code rate switching. Compared with the existing mechanism, in this application, the server determines the target fragmentation from the video source after receiving the resource request sent by the terminal device, including smooth code rate and cache duration, and then the server determines the target fragmentation sent to the terminal device. It can be seen that since the code rate of the target segment sent by the server to the terminal device is lower than the smoothed code rate, and the predicted download duration of the target segment is shorter than the cache duration, the target segment finally sent to the terminal device meets the current The conditions for smooth playback can provide the terminal equipment with fragments adapted to the terminal equipment in real time, ensure the continuity of streaming media playback, and also reduce the playback freeze caused by dynamic bit rate switching during streaming media playback The problem is to maximize the use of network bandwidth resources.

可选的,在一些发明实施例中,考虑到服务器的运算复杂度和运算负荷,在确定目标分片之前,所述服务器还可获取码率集合以提高运算效率。一些实施方式中,所述码率集合可由所述资源请求携带的指示信息指示,或者所述码率集合可由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。下面分别进行说明:Optionally, in some embodiments of the invention, considering the computing complexity and computing load of the server, before determining the target slice, the server may also obtain a code rate set to improve computing efficiency. In some implementations, the code rate set may be indicated by the indication information carried in the resource request, or the code rate set may be a code rate set selected by the server from the slice information set according to the smoothed code rate . Instructions are given below:

(a)、码率集合由终端设备提供(a), the code rate set is provided by the terminal device

终端设备在发送资源请求之前,可从服务器获取上述分片信息集合,然后终端设备计算出平滑码率,再将平滑码率与分片信息集合中的各码率进行比较,最终可以确定出低于所述平滑码率的码率的码率集合,最后将指示所述码率集合的信息或者所述码率集合携带在资源请求中。Before the terminal device sends a resource request, it can obtain the above fragmentation information set from the server, and then the terminal device calculates the smoothed code rate, and then compares the smoothed code rate with each code rate in the fragmentation information set, and finally can determine the low Based on the code rate set of the code rate of the smoothed code rate, finally, the information indicating the code rate set or the code rate set is carried in the resource request.

可见,由终端设备为服务器提供上述码率集合,能够减少服务器侧在确定目标分片时,只需要遍历码率集合中的码率即可。当然,若由服务器来确定上述码率集合,那么,(a)种方式中,由终端设备直接提供的话,就不需要由服务器去从分片信息集合中比较一遍了。由此可见,采用本方案,可有效减少服务器的运算量,进而提高运算效率,最终使得服务器能够快速的定位到目标分片。It can be seen that the above code rate set is provided by the terminal device to the server, which can reduce the server side only needing to traverse the code rates in the code rate set when determining the target slice. Of course, if the above code rate set is determined by the server, then, in the method (a), if it is directly provided by the terminal device, there is no need for the server to compare it from the slice information set. It can be seen that the adoption of this solution can effectively reduce the calculation amount of the server, thereby improving the calculation efficiency, and finally enabling the server to quickly locate the target segment.

(b)、码率集合由服务器提供(b), the code rate set is provided by the server

若上述码率集合由服务器确定,那么,服务器只需要从终端设备处获取的平滑码率就可以确定出上述码率集合,且服务器确定码率集合的方式与终端设备相同,此处不作赘述。If the above code rate set is determined by the server, then the server only needs to obtain the smooth code rate from the terminal device to determine the above code rate set, and the method of determining the code rate set by the server is the same as that of the terminal device, which will not be repeated here.

服务器在确定码率集合后,就可以通过遍历码率集合来确定目标分片了,通过缩小码率的搜索范围,这样在确定目标分片时,就不需要将平滑码率分别与分片信息集合中的每个码率都遍历一遍,只需要遍历码率集合中的码率即可。由此可见,采用本方案,可有效减少服务器的运算量,进而提高运算效率,最终使得服务器能够快速的定位到目标分片。After the server determines the code rate set, it can determine the target fragment by traversing the code rate set. By narrowing the search range of the code rate, it is not necessary to separate the smoothed code rate from the fragment information when determining the target fragment. Each code rate in the collection is traversed once, and only the code rates in the code rate collection need to be traversed. It can be seen that the adoption of this solution can effectively reduce the calculation amount of the server, thereby improving the calculation efficiency, and finally enabling the server to quickly locate the target segment.

在获取上述码率集合后,服务器可开始执行确定目标分片的操作,上述步骤204中,所述服务器从所述终端设备当前待播放的视频片源中确定目标分片,将所述目标分片发送给所述终端设备的具体过程可以参考如下1-3所描述的操作。After obtaining the above code rate set, the server can start to perform the operation of determining the target segment. In the above step 204, the server determines the target segment from the video source currently to be played by the terminal device, and the target segment For the specific process of sending the slice to the terminal device, refer to the operations described in 1-3 below.

1、服务器可从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率。1. The server can select a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes at least two fragments Fragment information of the slice, the at least two slices belong to the same video slice source currently to be played, and the slice information includes the slice size and the code rate of the slice.

2、所述服务器从码率集合中选择候选码率后,可根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率。可选的,所述平均速率可在所述资源请求携带,或者由所述服务器统计得到。2. After the server selects a candidate code rate from the code rate set, the predicted download time of the candidate fragment can be obtained according to the average rate and the fragment size of the target fragment corresponding to the candidate code rate. The average rate The current average rate of downloading fragments for the terminal device. Optionally, the average rate may be carried in the resource request, or obtained by statistics of the server.

3、在得到所述候选分片的预测下载时长后,所述服务器判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则服务器从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率,并且重复前面所述的“选择候选码率,计算候选分片的预测下载时长和判断候选分片的预测下载时长是否大于所述缓存时长”的操作,直至找到预测下载时长小于缓存时长的候选分片。3. After obtaining the predicted download duration of the candidate segment, the server judges whether the predicted download duration of the candidate segment is greater than the cache duration, and if the predicted download duration is greater than the cache duration, the server starts from Select a code rate lower than the candidate code rate in the code rate set as the candidate code rate, and repeat the above-mentioned "selecting a candidate code rate, calculating the predicted download time of the candidate fragment and judging the candidate score." Is the predicted download duration of the segment greater than the cache duration" until a candidate segment whose predicted download duration is less than the cache duration is found.

相应的,若所述候选分片的预测下载时长小于所述缓存时长,则所述服务器将所述候选分片作为所述目标分片发送至所述终端设备。Correspondingly, if the predicted download duration of the candidate segment is less than the cache duration, the server sends the candidate segment as the target segment to the terminal device.

由此可见,本申请中则是服务器在接收终端设备发送的包括平滑码率和缓存时长的资源请求后,可从码率集合中选择小于所述平滑码率的候选码率,当确定选中的候选码率对应的候选分片的预测下载时长小于所述终端设备缓存区当前的缓存时长时,服务器将该候选分片作为目标分片发送给所述终端设备。可见服务器通过将候选分片的预测下载时长与缓存时长进行比较,能够准确的判断终端设备所请求切换的分片是否满足当前流畅播放的条件,能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。It can be seen that in this application, after receiving the resource request sent by the terminal device including the smoothed code rate and the cache duration, the server can select a candidate code rate that is less than the smoothed code rate from the code rate set. When the predicted download duration of the candidate segment corresponding to the candidate code rate is less than the current buffer duration in the buffer area of the terminal device, the server sends the candidate segment as the target segment to the terminal device. It can be seen that the server can accurately determine whether the segment requested by the terminal device meets the current smooth playback conditions by comparing the predicted download duration of the candidate segment with the cache duration, and can provide the terminal device with a segment suitable for the terminal device in real time , to ensure the continuity of streaming media playback, and also reduce the problem of playback freeze caused by dynamic bit rate switching during streaming media playback, and maximize the use of network bandwidth resources.

可选的,在一些发明实施例中,在同时有很多终端设备向服务器请求视频片源资源时,为减少服务器侧的判断时长,若所述候选分片的预测下载时长大于所述缓存时长,服务器可直接从所述终端设备当前待播放的视频片源中选择至少一个与所述候选分片属于相同视频片源且码率低于所述候选分片的分片。然后,所述服务器将请求响应发送至所述终端设备,其中,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址,以供终端设备直接下载。可选的,请求响应中可以携带与所述候选分片所属视频片源中码率最低的分片的下载地址,这样可以保证终端设备侧可以流畅的播放该分片。通过这种处理机制,可进一步优化服务器侧对多个终端设备的响应,这样可以提高服务器的处理效率,同时也减少终端设备侧的等待时长。Optionally, in some embodiments of the invention, when many terminal devices request video source resources from the server at the same time, in order to reduce the judgment time on the server side, if the predicted download time of the candidate segment is longer than the cache time, The server may directly select at least one segment that belongs to the same video source as the candidate segment and has a lower code rate than the candidate segment from the video source currently to be played by the terminal device. Then, the server sends a request response to the terminal device, wherein the request response carries a download address of a segment that belongs to the same video source as the candidate segment and has a code rate lower than the candidate segment, for direct download by terminal devices. Optionally, the request response may carry the download address of the segment with the lowest code rate among the video sources to which the candidate segment belongs, so as to ensure that the segment can be played smoothly on the terminal device side. Through this processing mechanism, the response of the server side to multiple terminal devices can be further optimized, so that the processing efficiency of the server can be improved, and the waiting time of the terminal device side can also be reduced.

可选的,在一些发明实施例中,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,一种实施方式中,该字段可以为动态请求(dynamic-request)。如果dynamic-request指示的值为1时,则表示当前采用码率自适应模式,那么服务器就需要进行动态码率切换,可通过资源请求的前两个扩展头域识别出当前与终端设备的下载速率最匹配的分片,并将该分片返回给终端设备。如果dynamic-request指示的值为0时,则表示当前未采用码率自适应模式(例如用户在终端设备的客户端上手动关闭了码率自适应的功能),那么服务器在收到该资源请求后,就不需要进行动态码率切换。Optionally, in some embodiments of the invention, the resource request further includes a field used to indicate whether the server switches to the code rate adaptive mode. In one implementation, this field may be a dynamic request (dynamic-request ). If the value indicated by dynamic-request is 1, it means that the code rate adaptive mode is currently used, then the server needs to perform dynamic code rate switching, and the current download with the terminal device can be identified through the first two extension header fields of the resource request. The fragment with the best matching rate is returned to the terminal device. If the value indicated by dynamic-request is 0, it means that the code rate adaptation mode is not currently used (for example, the user manually turns off the code rate adaptation function on the client of the terminal device), then the server receives the resource request After that, there is no need for dynamic code rate switching.

可选的,在一些发明实施例中,考虑到终端设备发出资源请求至服务器计算候选分片的预测下载时长期间,终端设备的缓存区的缓存会存在一些消耗,所以,为提高服务器侧确定目标分片的准确度,还需要考虑该期间终端设备缓存区的缓存消耗量。由此,终端设备可在所述资源请求携带指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。该估计值可以是经验值,也可是终端设备根据当前的播放速率动态计算出,具体本申请不作限定,这样服务器在比较预测下载时长与缓存时长时,减去该缓存偏移量即可。Optionally, in some embodiments of the invention, considering that during the period from the terminal device sending a resource request to the server calculating the predicted download time of the candidate fragments, there will be some consumption in the cache of the terminal device's buffer area, so, in order to improve the server side to determine the target The accuracy of fragmentation also needs to consider the buffer consumption of the terminal device buffer during this period. Therefore, the terminal device may carry a field indicating a cache offset in the resource request, and the cache offset refers to a period from when the terminal device sends the resource request to when the server receives the resource request, Estimated value of buffer consumption for the end device buffer. The estimated value can be an empirical value, or it can be dynamically calculated by the terminal device according to the current playback rate, which is not limited in this application. In this way, when the server compares the predicted download duration with the cache duration, it only needs to subtract the cache offset.

为便于理解,本申请的图3还提供一种详细的流程图,具体如下操作:For ease of understanding, Figure 3 of the present application also provides a detailed flow chart, specifically as follows:

在终端设备侧,终端设备从服务器下载视频片源对应的分片信息集合,然后计算下一个待播放分片的码率,在向服务器发送下载该分片的资源请求,在该资源请求中携带计算出的下一个待播放分片的码率,还可携带用于指示是否切换动态自适应模式的头域字段dynamic-switch,该dynamic-switch的值可以为1或0。On the terminal device side, the terminal device downloads the segment information set corresponding to the video source from the server, then calculates the code rate of the next segment to be played, and sends a resource request for downloading the segment to the server. The calculated code rate of the next segment to be played may also carry a header field dynamic-switch for indicating whether to switch the dynamic adaptive mode, and the value of the dynamic-switch may be 1 or 0.

在服务器侧,服务器接受到终端设备发送的资源请求后,根据资源请求为dynamic-switch判断是否需要进行分片切换。当dynamic-switch的值为1,则进入是否需要进行分片切换计算的操作,若是,那么服务器计算出需要返回给终端设备的分片,计算出需要的分片后,将该分片发给终端设备,使得终端设备将收到的分片放入播放缓存区,以等待播放。若不需要进行分片切换计算的操作,那么服务器可直接根据资源请求来从数据库读取对应的分片内容,然后将该分片发给终端设备,使得终端设备将收到的分片放入播放缓存区,以等待播放。On the server side, after receiving the resource request sent by the terminal device, the server judges whether slice switching needs to be performed according to the dynamic-switch of the resource request. When the value of dynamic-switch is 1, enter the operation of whether to perform slice switching calculation. If yes, then the server calculates the slices that need to be returned to the terminal device, and after calculating the required slices, sends the slices to The terminal device is used to make the terminal device put the received fragments into the playing buffer area, so as to wait for playing. If there is no need to perform slice switching operations, the server can directly read the corresponding slice content from the database according to the resource request, and then send the slice to the terminal device, so that the terminal device puts the received slice into the The playback buffer is waiting to be played.

当dynamic-switch的值为0,则忽略该资源请求。When the value of dynamic-switch is 0, the resource request is ignored.

参照图4,以下从终端设备确定目标分片的角度,对本申请提供的调整流媒体码率的方法进行举例说明,终端设备上安装了客户端,该客户端可用于播放下载的视频,本方法实施例主要包括:With reference to Fig. 4, the method for adjusting the bit rate of streaming media provided by the present application is illustrated from the perspective of determining the target fragmentation from the terminal equipment. The terminal equipment is installed with a client, and the client can be used to play downloaded videos. This method Embodiment mainly includes:

401、终端设备获取当前的平滑码率和当前待播放的视频片源对应的分片信息集合。401. The terminal device acquires the current smoothing code rate and the fragmentation information set corresponding to the currently to-be-played video source.

其中,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率。该平滑码率可依赖于当前网络带宽的码率以及终端设备缓存区的充盈状态等参数来计算,也可以在现有机制中计算的基础之上加入其他新的参数,具体本申请不作限定。Wherein, the smoothed code rate is a code rate that matches the download rate of the video source currently downloaded by the terminal device. The smooth code rate can be calculated depending on parameters such as the code rate of the current network bandwidth and the filling state of the buffer area of the terminal device, or other new parameters can be added on the basis of the calculation in the existing mechanism, which is not limited in this application.

所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率。该分片信息集合可从服务器处获取,也可以通过其他途径获取,例如,邮件、短信或者网络数据库等,具体的获取途径本申请不作限定。The fragment information set includes fragment information of at least two fragments, the at least two fragments belong to the same video fragment source currently to be played, and the fragment information includes fragment size and fragment code rate. The fragment information set can be obtained from the server, or can be obtained through other means, such as email, short message or network database, etc. The specific acquisition means are not limited in this application.

该分片信息集合可称为媒体描述文件、片源码率列表等等,如果视频片源的分片基于HTTP的动态自适应流(英文全称:Dynamic Adaptive Streaming over HTTP,英文简称:DASH)传输,那么下载的分片信息集合为媒体展示描述(英文全称:Media PresentationDescription,英文简称:MPD)文件,终端设备获取MPD文件后,可通过解析MPD文件可以获取视频的相关信息,然后使用HTTP请求即可按片获取相应的分片;如果视频片源的分片基于超文本传输协议直播流(英文全称:HTTP Live Streaming,英文简称:HLS)传输,那么下载的分片信息集合为m3u8文件。例如某个流媒体可支持2种码率的视频,每种码率的视频包含3个分片,分那么上述分片信息集合中所包括的各种码率的分片的分片信息可以通过一张表来呈现,如下表1所示:The fragmentation information collection can be called media description file, piece source code rate list, etc., if the fragmentation of video piece source is based on dynamic adaptive streaming of HTTP (English full name: Dynamic Adaptive Streaming over HTTP, English abbreviation: DASH) transmission, Then the downloaded fragment information set is a Media Presentation Description (English full name: Media Presentation Description, English abbreviation: MPD) file. After the terminal device obtains the MPD file, it can obtain the relevant information of the video by parsing the MPD file, and then use HTTP request. Obtain the corresponding fragments by slice; if the slices of the video source are transmitted based on the hypertext transfer protocol live stream (English full name: HTTP Live Streaming, English abbreviation: HLS), then the downloaded slice information set is an m3u8 file. For example, a certain streaming media can support 2 kinds of bit rate videos, and each bit rate video contains 3 slices, then the slice information of the various bit rate slices included in the above slice information set can be passed A table is presented, as shown in Table 1 below:

码率code rate分片大小Fragment size码率1(2Mbps)Code rate 1(2Mbps)分片1(30000Byte)Fragment 1 (30000Byte)分片2(25000Byte)Fragment 2 (25000Byte)分片3(32000Byte)Fragment 3 (32000Byte)码率2(4Mbps)Code rate 2(4Mbps)分片1(50000Byte)Fragment 1 (50000Byte)分片2(60000Byte)Fragment 2 (60000Byte)分片3(55000Byte)Fragment 3 (55000Byte)

表1Table 1

402、终端设备从所述分片信息集合中确定目标码率。402. The terminal device determines a target code rate from the fragmentation information set.

其中,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长。Wherein, the target code rate is smaller than the smoothed code rate, and the predicted download duration of the target segment corresponding to the target code rate is shorter than the current cache duration of the buffer area of the terminal device.

403、终端设备将资源请求发送至所述服务器。403. The terminal device sends a resource request to the server.

所述资源请求用于请求下载所述目标码率对应的目标分片,该资源请求中可指示目标码率。The resource request is used to request to download the target segment corresponding to the target code rate, and the resource request may indicate the target code rate.

404、服务器将目标分片下发给终端设备。404. The server delivers the target segment to the terminal device.

405、终端设备接收服务器发送的目标分片。405. The terminal device receives the target segment sent by the server.

现有机制中,客户端只能将平滑码率与分片的平均码率进行比较,最终导致码率切换的乒乓效应。与现有机制相比,本申请所提供的方案中,一方面,终端设备获取平滑码率和分片信息集合后,可从分片信息集合中选择小于所述平滑码率的目标码率,当确定选中的目标码率对应的目标分片的预测下载时长小于当前的缓存时长时,就表示该目标码率适应当前的带宽,所以终端设备可以将该目标码率携带在资源请求中发送给服务器,最终得到合适的目标分片。可见终端设备通过将目标分片的预测下载时长与缓存时长进行比较,能够准确的判断自身计算出的目标码率所对应的目标分片是否满足当前流畅播放的条件,以便服务器能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题,最大限度利用网络带宽资源。In the existing mechanism, the client can only compare the smoothed code rate with the average code rate of the slice, which eventually leads to a ping-pong effect of code rate switching. Compared with the existing mechanism, in the solution provided by this application, on the one hand, after the terminal device obtains the smoothed code rate and fragmentation information set, it can select a target code rate that is less than the smoothed code rate from the fragmentation information set, When it is determined that the predicted download duration of the target segment corresponding to the selected target code rate is less than the current cache duration, it means that the target code rate is suitable for the current bandwidth, so the terminal device can carry the target code rate in the resource request and send it to server, and finally get the appropriate target shard. It can be seen that by comparing the predicted download duration of the target segment with the cache duration, the terminal device can accurately judge whether the target segment corresponding to the target bit rate calculated by itself satisfies the current smooth playback conditions, so that the server can provide real-time information for the terminal device. Provide fragments adapted to the terminal equipment to ensure the continuity of streaming media playback, and also reduce the problem of playback freezes caused by dynamic bit rate switching during streaming media playback, and maximize the use of network bandwidth resources.

另一方面,考虑到网络带宽波动,本地的缓存时长的消耗等因素都会影响到当前的平滑码率,有可能出现即使将计算出的平滑码率发送给服务器,而服务器确定目标分片需要消耗运算时长,在服务器运算过程中,可能当前提供给服务器的平滑码率可能已经不适应当前终端设备侧的网络带宽了,这样服务器根据平滑码率和缓存时长所确定出的目标码率可能不准确,尤其在网络带宽减小的情况下,服务器所计算出的目标码率实质上是高于此时终端设备侧新计算出的平滑码率的。这样服务器最终确定的目标分片可能不准确,会导致终端设备侧出现播放卡顿现象。而本申请中,由终端设备去确定目标分片,由于平滑码率是由终端设备自行动态计算的,那么,终端设备所计算出的平滑码率是能够代表当前网络带宽适应终端设备播放的真实平滑码率的。所以,由终端设备实施上述方案,可以有效的排除传送到服务器的期间可能出现的网络波动现象所带来的不准确问题。On the other hand, considering network bandwidth fluctuations, local cache time consumption and other factors will affect the current smooth bit rate, it may happen that even if the calculated smooth bit rate is sent to the server, the server needs to consume Calculation time, during the calculation process of the server, the smooth bit rate currently provided to the server may not be suitable for the network bandwidth of the current terminal device side, so the target bit rate determined by the server based on the smooth bit rate and cache duration may not be accurate , especially when the network bandwidth is reduced, the target code rate calculated by the server is substantially higher than the smooth code rate newly calculated by the terminal device side at this time. In this way, the target segment finally determined by the server may be inaccurate, which may cause playback freezes on the terminal device side. However, in this application, the terminal device determines the target fragmentation. Since the smooth code rate is dynamically calculated by the terminal device itself, the smooth code rate calculated by the terminal device is a real value that can represent the current network bandwidth and adapt to the playback of the terminal device. Smooth code rate. Therefore, implementing the above solution by the terminal device can effectively eliminate the problem of inaccuracy caused by network fluctuations that may occur during transmission to the server.

可选的,在一些发明实施例中,在所述终端设备获取当前的平滑码率和分片信息集合之后,所述终端设备从所述分片信息集合中确定目标码率之前,所述终端设备还可从所述分片信息集合中确定低于所述平滑码率的码率集合,在确定码率集合后,终端设备就可以确定目标分片了,通过缩小码率的搜索范围,这样在确定目标分片时,就不需要将平滑码率分别与分片信息集合中的每个码率都遍历一遍,只需要遍历码率集合中的码率即可。由此可见,采用本方案,可有效减少运算量,也能提高运算效率。Optionally, in some embodiments of the invention, after the terminal device obtains the current smooth code rate and fragmentation information set, and before the terminal device determines the target code rate from the fragmentation information set, the terminal The device can also determine a code rate set lower than the smooth code rate from the fragment information set. After determining the code rate set, the terminal device can determine the target fragment. By narrowing the code rate search range, this When determining the target slice, it is not necessary to traverse the smoothed code rate and each code rate in the slice information set, but only need to traverse the code rates in the code rate set. It can be seen that, adopting this solution can effectively reduce the calculation amount and improve the calculation efficiency.

在获取码率集合后,所述终端设备从所述分片信息集合中确定目标码率,将资源请求发送至所述服务器,可包括:After obtaining the code rate set, the terminal device determines the target code rate from the fragmentation information set, and sends the resource request to the server, which may include:

所述终端设备从所述码率集合中选择候选码率,然后根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长。The terminal device selects a candidate code rate from the code rate set, and then obtains the predicted download duration of the candidate segment according to the segment size of the candidate segment corresponding to the candidate code rate and the average rate.

在得到所述候选分片的预测下载时长后,所述终端设备判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率,重复执行上述“计算候选分片的预测下载时长和判断候选分片的预测下载时长是否大于所述缓存时长”的操作,直至找到预测下载时长小于缓存时长的候选分片对应的目标码率。After obtaining the predicted download duration of the candidate segment, the terminal device judges whether the predicted download duration of the candidate segment is greater than the cache duration, if the predicted download duration of the candidate segment is greater than the cache duration, Then select a code rate lower than the candidate code rate from the fragment set as the candidate code rate, and repeat the above "calculating the predicted download duration of the candidate fragment and judging whether the predicted download duration of the candidate fragment is greater than the specified "cache duration" until the target code rate corresponding to the candidate segment whose predicted download duration is less than the cache duration is found.

若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, the candidate code rate is used as the target code rate, and the resource request is sent to the server, and the resource request is used to request to download the The target slice corresponding to the target code rate.

举例来说,终端设备当前缓存区的缓存时长为Q,计算出的平滑码率为3兆比特每秒(英文全称:Million bits per second,英文简称:Mbps),终端设备当前下载分片的平均速率为P字节/秒,视频片源支持的码率分别为1Mbps,2Mbps,4Mbps。那么该视频片源中满足终端设备流畅播放的码率有1Mbps,2Mbps,其中最接近平滑码率的码率是2Mbps,那么可选择2Mbps作为目标码率。然后,终端设备根据分片信息集合查询到2Mbps对应的分片大小为X,那么终端设备计算的分片1的预测下载时长为T,T=X/P。如果T≤Q,即表示终端设备下载该分片的过程中,其缓存区的缓存不会被耗尽,那么终端设备可下载该分片。如果T≥Q,即表示终端设备下载该分片的过程中,其缓存区的缓存会被耗尽,那么终端设备不下载该分片,再重新回到选择候选码率,以及判断T是否小于Q的操作,后面每次选择的码率都要低于上一次所选择的候选码率,直至找到满足T≤Q的分片。For example, the cache duration of the current buffer area of the terminal device is Q, the calculated smooth code rate is 3 megabits per second (full name in English: Million bits per second, English abbreviation: Mbps), and the average The rate is Pbytes/second, and the bit rates supported by the video source are 1Mbps, 2Mbps, and 4Mbps. Then the bit rate that meets the smooth playback of the terminal equipment in the video source is 1Mbps, 2Mbps, and the bit rate closest to the smooth bit rate is 2Mbps, so you can choose 2Mbps as the target bit rate. Then, the terminal device inquires according to the fragmentation information set that the fragmentation size corresponding to 2 Mbps is X, then the predicted download time of fragment 1 calculated by the terminal device is T, and T=X/P. If T≤Q, it means that the cache in the buffer area of the terminal device will not be exhausted during the process of downloading the segment, and the terminal device can download the segment. If T≥Q, it means that the cache in the buffer area of the terminal device will be exhausted during the process of downloading the segment, then the terminal device will not download the segment, and then return to the selection of candidate code rates, and determine whether T is less than For the operation of Q, the code rate selected each time will be lower than the candidate code rate selected last time until a fragment satisfying T≤Q is found.

为便于理解,本申请的图5还提供一种详细的流程图,具体如下操作:For ease of understanding, Figure 5 of the present application also provides a detailed flow chart, specifically as follows:

在终端设备侧,终端设备从服务器下载视频片源对应的分片信息集合,计算平滑码率,然后从分片信息集合中选择一个最接近平滑码率的码率作为候选码率(也就是计算下一个待播放分片的码率)。On the terminal device side, the terminal device downloads the fragmentation information set corresponding to the video source from the server, calculates the smooth code rate, and then selects a code rate closest to the smooth code rate from the fragmentation information set as the candidate code rate (that is, calculates The bitrate of the next segment to be played).

然后,终端设备根据候选码率从分片信息集合中找到要下载的分片的大小X,再根据平均速率P和分片的大小X计算出该分片的预测下载时长T,T=X/P。Then, the terminal device finds the size X of the fragment to be downloaded from the fragment information set according to the candidate code rate, and then calculates the predicted download time T of the fragment according to the average rate P and the fragment size X, T=X/ p.

在计算出T后,再将T与终端设备当前的缓存数据量Q进行比较,若T≤Q,那么,表示当前选择的分片能保证终端设备流畅的播放,所以终端设备可以直接将该分片的码率发送给服务器,以下载该分片,从而保证播放分片的连续性。After calculating T, compare T with the current cached data volume Q of the terminal device. If T≤Q, it means that the currently selected segment can ensure the smooth playback of the terminal device, so the terminal device can directly use the segment The code rate of the piece is sent to the server to download the piece, so as to ensure the continuity of playing the pieces.

若T≥Q,那么,表示当前选择的分片并不能保证终端设备流畅的播放,所以终端设备需要再从码率列表中选择比之前选择的码率低一级的码率,再重新计算一次预测下载时长,以及判断T与Q的大小关系,直到找到T≤Q的分片后,再将满足流畅播放的分片的码率发送给服务器,以下载该分片。If T≥Q, then it means that the currently selected segment cannot guarantee the smooth playback of the terminal device, so the terminal device needs to select a code rate one level lower than the previously selected code rate from the code rate list, and then recalculate Predict the download time, and judge the relationship between T and Q, until you find a segment with T≤Q, then send the code rate of the segment that satisfies smooth playback to the server to download the segment.

可选的,在一些发明实施例中,除了终端设备自行确定目标分片,还可以由服务器来确定,那么,终端设备就需要为服务器提供与确定目标分片相关的参数。具体来说,所述终端设备在从分片信息集合中选择小于所述平滑码率的码率之后,可向所述服务器发送另一资源请求,所述另一资源请求可包括所述平滑码率和所述终端设备缓存区的缓存时长。Optionally, in some embodiments of the invention, in addition to determining the target segment by the terminal device itself, it may also be determined by the server. Then, the terminal device needs to provide the server with parameters related to determining the target segment. Specifically, after the terminal device selects a code rate smaller than the smooth code rate from the slice information set, it may send another resource request to the server, and the other resource request may include the smooth code rate rate and the cache duration of the terminal device cache.

之后,所述服务器在接收到上述另一资源请求后,从分片信息集合中选择小于所述平滑码率的码率,当确定选中的码率对应的分片的预测下载时长小于所述终端设备缓存区当前的缓存时长时,所述服务器将预测下载时长小于所述缓存时长的分片发送给所述终端设备。Afterwards, after receiving the above-mentioned another resource request, the server selects a code rate smaller than the smooth code rate from the fragment information set, and when it is determined that the predicted download duration of the fragment corresponding to the selected code rate is shorter than the terminal When the current cache duration in the device cache area is lower than the cache duration, the server sends the fragments whose download duration is predicted to be shorter than the cache duration to the terminal device.

对服务器来说,如何根据终端设备发送的另一资源请求来确定目标分片的具体操作可参考上述第一方面所述的技术方案,此处不作赘述。For the specific operation of how to determine the target segment according to another resource request sent by the terminal device, for the server, reference may be made to the technical solution described in the first aspect above, which will not be repeated here.

需要说明的是,对于是否由终端设备来确定目标分片,还是由服务器来确定目标分片,可以优先由终端设备来确定目标分片,这样可以有效的降低服务器的运算负荷,也能提高确定与实际下载速率匹配的目标分片的准确率。终端设备可以主动执行确定目标码率的操作;也可以是在用户关闭了码率动态切换的功能时,为服务器提供运算的参数,最终由服务器来确定目标分片;还可以是,不考虑用户是否关闭码率动态切换的功能,终端设备都可主动为服务器提供运算的参数,最终由服务器来确定目标分片;当然也可以是在终端设备无法正确的确定目标码率时,向服务器发出上述另一资源请求。It should be noted that, as to whether the target slice is determined by the terminal device or the server determines the target slice, the target slice can be determined by the terminal device first, which can effectively reduce the computing load of the server and improve the determination of the target slice. Accuracy of target shards matched to actual download rate. The terminal device can actively perform the operation of determining the target code rate; it can also provide calculation parameters for the server when the user turns off the dynamic switching function of the code rate, and finally the server determines the target fragmentation; it can also be that the user is not considered Whether to disable the function of dynamic code rate switching, the terminal device can actively provide computing parameters for the server, and finally the server determines the target fragmentation; of course, when the terminal device cannot correctly determine the target code rate, it can send the above-mentioned Another resource request.

可选的,为了减少服务器的运算,终端设备还可在所述另一资源请求携带用于指示所述分片信息集合中低于所述平滑码率的码率集合的信息,使得服务器可以小范围的去确定候选码率、减少判断候选分片的预测下载时长是否小于缓存时长的次数等操作,最终使得服务器能够快速的定位到目标分片。Optionally, in order to reduce the calculation of the server, the terminal device may also carry information indicating a code rate set in the fragmentation information set that is lower than the smooth code rate in the another resource request, so that the server can reduce A wide range of operations such as determining the candidate code rate and reducing the number of times to judge whether the predicted download duration of the candidate segment is less than the cache duration will ultimately enable the server to quickly locate the target segment.

可选的,所述另一资源请求还包括所述终端设备当前下载分片的平均速率,所述平均速率用于所述服务器计算分片的预测下载时长。Optionally, the other resource request further includes an average rate at which the terminal device currently downloads segments, and the average rate is used by the server to calculate a predicted download duration of segments.

可选的,考虑到终端设备发出上述另一资源请求至服务器计算候选分片的预测下载时长期间,终端设备的缓存区的缓存会存在一些消耗,所以,为提高服务器侧确定目标分片的准确度,还需要考虑该期间终端设备缓存区的缓存消耗量。由此,终端设备可在上述另一资源请求携带指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送上述另一资源请求到所述服务器接收到所述另一资源请求期间,所述终端设备缓存区的缓存消耗的估计值。该估计值可以是经验值,也可是终端设备根据当前的播放速率动态计算出,具体本申请不作限定,这样服务器在比较预测下载时长与缓存时长时,减去该缓存偏移量即可。Optionally, considering that during the period from the terminal device sending the above another resource request to the server calculating the predicted download duration of the candidate segment, there will be some consumption in the cache area of the terminal device, so in order to improve the accuracy of determining the target segment on the server side In this period, the buffer consumption of the terminal device buffer area also needs to be considered. Therefore, the terminal device may carry a field indicating a cache offset in the above-mentioned another resource request, and the cache offset refers to the time when the terminal device sends the above-mentioned another resource request to the time when the server receives the other resource request. The estimated value of the buffer consumption of the terminal device buffer during the resource request. The estimated value can be an empirical value, or it can be dynamically calculated by the terminal device according to the current playback rate, which is not limited in this application. In this way, when the server compares the predicted download duration with the cache duration, it only needs to subtract the cache offset.

上述图2-图5中任意所述的平滑码率、平均速率、缓存时长、预测下载时长和资源请求等特征,以及与这些特征相关的任何描述也同样适用于本申请中的图6所对应的各实施例,后续类似之处不再赘述。The smooth code rate, average rate, cache duration, predicted download duration, resource request and other features described in any of the above-mentioned Figures 2-5, as well as any descriptions related to these features, are also applicable to Figure 6 in this application. The various embodiments of the following similarities will not be repeated here.

以上对本申请中一种调整流媒体码率的方法进行说明,以下对用于调整流媒体码率的装置(包括服务器和终端设备)进行描述,服务器和终端设备均有如图6所示的结构,下面分别进行说明。A method for adjusting the streaming code rate in the present application is described above, and the device (including server and terminal equipment) for adjusting the streaming media code rate is described below. Both the server and the terminal equipment have a structure as shown in Figure 6. Each will be described below.

一、参照图6,所述服务器可包括:1. Referring to Figure 6, the server may include:

收发模块,用于接收终端设备的资源请求,所述资源请求包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率。A transceiver module, configured to receive a resource request from a terminal device, where the resource request includes a smoothed code rate and a cache duration of the buffer area of the terminal device, and the smoothed code rate is the same as the download rate of the currently downloaded video source of the terminal device Matching bitrate.

处理模块,用于从所述终端设备当前待播放的视频片源中确定目标分片,通过所述收发模块将所述目标分片发送至所述终端设备,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。A processing module, configured to determine a target segment from the video source currently to be played by the terminal device, and send the target segment to the terminal device through the transceiver module, and the code rate of the target segment is less than In the smooth code rate, the predicted download duration of the target segment is less than the cache duration.

本发明实施例中,在所述收发模块接收终端设备发送的包括平滑码率和缓存时长的资源请求后,从视频片源中确定目标分片,然后所述处理模块将该目标分片发送给所述终端设备。可见,由于服务器发送给终端设备的目标分片的码率小于所述平滑码率,并且该目标分片的预测下载时长小于所述缓存时长,所以最终发送给终端设备的目标分片是满足当前流畅播放的条件的,能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题。In the embodiment of the present invention, after the transceiver module receives the resource request sent by the terminal device including the smooth code rate and the cache duration, it determines the target fragment from the video source, and then the processing module sends the target fragment to the terminal device. It can be seen that since the code rate of the target segment sent by the server to the terminal device is lower than the smoothed code rate, and the predicted download duration of the target segment is shorter than the cache duration, the target segment finally sent to the terminal device meets the current The conditions for smooth playback can provide the terminal equipment with fragments adapted to the terminal equipment in real time, ensure the continuity of streaming media playback, and also reduce the playback freeze caused by dynamic bit rate switching during streaming media playback question.

可选的,所述处理模块具体用于:Optionally, the processing module is specifically used for:

从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;Select a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes fragments of at least two fragments information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes the code rate of fragmentation size and fragmentation;

根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率;Obtain the predicted download duration of the candidate fragment according to the fragment size of the target fragment corresponding to the average rate and the candidate code rate, and the average rate is the average rate of the terminal device currently downloading the fragment;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration is greater than the cache duration, select a code rate lower than the code rate of the candidate fragment from the code rate set As the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则通过所述收发模块将所述候选分片作为所述目标分片发送至所述终端设备。If the predicted download duration of the candidate segment is less than the buffer duration, the candidate segment is sent to the terminal device as the target segment by the transceiver module.

可选的,所述码率集合由所述资源请求携带的指示信息指示,或者所述码率集合由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。Optionally, the code rate set is indicated by the indication information carried in the resource request, or the code rate set is a code rate set selected by the server from the slice information set according to the smoothed code rate.

可选的,所述平均速率在所述资源请求携带,或者由所述服务器统计得到。Optionally, the average rate is carried in the resource request, or obtained by statistics of the server.

可选的,所述处理模块还用于:Optionally, the processing module is also used for:

若所述候选分片的预测下载时长大于所述缓存时长,则通过所述收发模块将请求响应发送至所述终端设备,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址。If the predicted download duration of the candidate segment is longer than the buffer duration, the request response is sent to the terminal device through the transceiver module, and the request response carries the same video source as the candidate segment and the code The download address of the segment whose rate is lower than the candidate segment.

可选的,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,和/或,所述资源请求还包括指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。Optionally, the resource request further includes a field for indicating whether the server switches to a code rate adaptive mode, and/or, the resource request further includes a field indicating a cache offset, and the cache offset The amount refers to an estimated value of cache consumption of the cache area of the terminal device during the period from when the terminal device sends the resource request to when the server receives the resource request.

二、参照图6,所述终端设备可包括:2. Referring to Figure 6, the terminal equipment may include:

收发模块,用于获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The transceiver module is used to obtain the current smooth code rate and fragmentation information set, the smooth code rate matches the code rate of the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two The fragmentation information of fragments, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;

处理模块,用于从所述收发模块获取的所述分片信息集合中确定目标码率,通过所述收发模块将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。a processing module, configured to determine a target code rate from the fragmentation information set acquired by the transceiver module, and send a resource request to the server through the transceiver module, where the target code rate is less than the smoothed code rate, The predicted download duration of the target segment corresponding to the target code rate is less than the current buffer duration of the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.

本发明实施例中,在通过收发模块获取平滑码率和分片信息集合后,处理模块可从分片信息集合中选择小于所述平滑码率的目标码率,当处理模块确定选中的目标码率对应的目标分片的预测下载时长小于当前的缓存时长时,就表示该目标码率适应当前的带宽,所以,处理模块可通过收发模块将该目标码率携带在资源请求中发送给服务器,最终得到合适的目标分片。可见终端设备通过将目标分片的预测下载时长与缓存时长进行比较,能够准确的判断自身计算出的目标码率所对应的目标分片是否满足当前流畅播放的条件,以便服务器能够实时为终端设备提供与终端设备适应的分片,保证流媒体的播放连续性,也能减少在流媒体播放过程中进行动态码率切换时所引发的播放卡顿的问题。In the embodiment of the present invention, after the smooth code rate and fragmentation information set are obtained by the transceiver module, the processing module may select a target code rate smaller than the smooth code rate from the fragmentation information set. When the processing module determines the selected target code rate When the predicted download time of the target segment corresponding to the rate is less than the current cache time, it means that the target code rate is suitable for the current bandwidth. Therefore, the processing module can carry the target code rate in the resource request and send it to the server through the transceiver module. Finally, a suitable target shard is obtained. It can be seen that by comparing the predicted download duration of the target segment with the cache duration, the terminal device can accurately judge whether the target segment corresponding to the target bit rate calculated by itself satisfies the current smooth playback conditions, so that the server can provide real-time information for the terminal device. Provide fragments adapted to the terminal equipment to ensure the continuity of streaming media playback, and also reduce the problem of playback stuttering caused by dynamic bit rate switching during streaming media playback.

可选的,所述处理模块在所述收发模块获取当前的平滑码率和分片信息集合之后,在从所述分片信息集合中确定目标码率之前,还用于:Optionally, the processing module is further configured to: after the transceiver module obtains the current smooth code rate and fragmentation information set, and before determining the target code rate from the fragmentation information set:

从所述分片信息集合中确定低于所述平滑码率的码率集合。Determining a code rate set lower than the smoothed code rate from the slice information set.

可选的,所述处理模块具体用于:Optionally, the processing module is specifically used for:

从所述码率集合中选择候选码率;Select a candidate code rate from the code rate set;

根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长;Obtaining the predicted download duration of the candidate fragments according to the fragment size of the candidate fragments corresponding to the candidate code rate and the average rate;

判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration of the candidate fragment is greater than the cache duration, then select the candidate fragment lower than the candidate fragment from the fragment set The code rate is used as the candidate code rate;

若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,通过所述收发模块将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, then use the candidate code rate as the target code rate, and send the resource request to the server through the transceiver module, and the resource request It is used to request to download the target segment corresponding to the target code rate.

需要说明的是,在本申请图6所对应的各实施例中的收发模块对应的实体设备可以为收发器,处理模块对应的实体设备可以为处理器。图6所示的各装置均可以具有如图7所示的结构,当其中一种装置具有如图7所示的结构时,图7中的处理器和收发器实现前述对应该装置的装置实施例提供的处理模块和收发模块相同或相似的功能,图7中的存储器存储处理器执行上述调整流媒体码率的方法时需要调用的程序代码。其中,处理器可用于执行上述图2对应的实施例中的步骤201-步骤204中所描述的操作,以及执行图3对应的实施例中所描述的操作,还可用于执行图4所对应的实施例中步骤401-步骤404中所描述的操作,以及执行图5对应的实施例中所描述的操作,具体可参考前述图2-图5所示的任意实施例。.It should be noted that, in each embodiment corresponding to FIG. 6 of the present application, the physical device corresponding to the transceiver module may be a transceiver, and the physical device corresponding to the processing module may be a processor. Each of the devices shown in Figure 6 can have the structure shown in Figure 7, and when one of the devices has the structure shown in Figure 7, the processor and transceiver in Figure 7 implement the aforementioned device implementation corresponding to the device The processing module provided by the example has the same or similar functions as the transceiver module, and the memory in FIG. 7 stores the program code that needs to be called when the processor executes the above-mentioned method for adjusting the bit rate of the streaming media. Wherein, the processor can be used to execute the operations described in steps 201-step 204 in the above embodiment corresponding to FIG. 2, as well as the operations described in the embodiment corresponding to FIG. For the operations described in steps 401 to 404 in the embodiment, and the operations described in the embodiment corresponding to FIG. 5 , refer to any embodiment shown in FIGS. 2 to 5 for details. .

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the foregoing embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and module can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or modules may be in electrical, mechanical or other forms.

所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or may be distributed to multiple network modules. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。In addition, each functional module in each embodiment of the present application may be integrated into one processing module, each module may exist separately physically, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules. If the integrated modules are realized in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium.

在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product.

所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present invention will be generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server, or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a server or a data center integrated with one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).

以上对本申请所提供的技术方案进行了详细介绍,本申请中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The technical solutions provided by this application have been introduced in detail above. In this application, specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only used to help understand the methods and core ideas of this application. At the same time, for those skilled in the art, based on the idea of this application, there will be changes in the specific implementation and application scope. In summary, the content of this specification should not be construed as limiting the application.

Claims (18)

Translated fromChinese
1.一种调整流媒体码率的方法,其特征在于,所述方法包括:1. a method for adjusting streaming media code rate, is characterized in that, described method comprises:服务器接收终端设备的资源请求,所述资源请求包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率;The server receives the resource request of the terminal device, the resource request includes a smooth code rate and the cache duration of the buffer area of the terminal device, and the smooth code rate matches the download rate of the video source currently downloaded by the terminal device ;所述服务器从所述终端设备当前待播放的视频片源中确定目标分片,将所述目标分片发送至所述终端设备,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。The server determines the target segment from the video source currently to be played by the terminal device, and sends the target segment to the terminal device, the code rate of the target segment is smaller than the smoothed code rate, so The predicted download duration of the target segment is less than the cache duration.2.根据权利要求1所述的方法,其特征在于,所述服务器从所述终端设备当前待播放的视频片源中确定目标分片,将所述目标分片发送给所述终端设备,包括:2. The method according to claim 1, wherein the server determines the target segment from the video source currently to be played by the terminal device, and sends the target segment to the terminal device, including :所述服务器从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The server selects a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes at least two fragments Fragmentation information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;所述服务器根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率;The server obtains the predicted download duration of the candidate fragment according to the average rate and the fragment size of the target fragment corresponding to the candidate code rate, and the average rate is the average rate of the terminal device currently downloading the fragment;所述服务器判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率;The server judges whether the predicted download duration of the candidate fragment is greater than the cache duration, and if the predicted download duration is greater than the cache duration, selects a code rate lower than the candidate fragment from the code rate set The code rate of is used as the candidate code rate;若所述候选分片的预测下载时长小于所述缓存时长,则所述服务器将所述候选分片作为所述目标分片发送至所述终端设备。If the predicted download duration of the candidate segment is less than the cache duration, the server sends the candidate segment as the target segment to the terminal device.3.根据权利要求2所述的方法,其特征在于,所述码率集合由所述资源请求携带的指示信息指示,或者所述码率集合由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。3. The method according to claim 2, wherein the code rate set is indicated by the indication information carried in the resource request, or the code rate set is selected by the server according to the smoothed code rate from the A set of code rates selected by the slice information set.4.根据权利要求2或3所述的方法,其特征在于,所述平均速率在所述资源请求携带,或者由所述服务器统计得到。4. The method according to claim 2 or 3, wherein the average rate is carried in the resource request, or is obtained by statistics of the server.5.根据权利要求2-4任一所述的方法,其特征在于,所述方法还包括:5. The method according to any one of claims 2-4, wherein the method further comprises:若所述候选分片的预测下载时长大于所述缓存时长,则所述服务器将请求响应发送至所述终端设备,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址。If the predicted download duration of the candidate fragment is longer than the cache duration, the server sends a request response to the terminal device, and the request response carries the same video source as the candidate fragment and has a low code rate. The download address of the segment of the candidate segment.6.根据权利要求1或2所述的方法,其特征在于,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,和/或,所述资源请求还包括指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。6. The method according to claim 1 or 2, wherein the resource request further includes a field for indicating whether the server switches to a code rate adaptive mode, and/or, the resource request further includes A field indicating a cache offset, where the cache offset refers to an estimated value of the cache consumption of the terminal device's cache area during the period from when the terminal device sends the resource request to when the server receives the resource request .7.一种调整流媒体码率的方法,其特征在于,所述方法包括:7. A method for adjusting the bit rate of streaming media, characterized in that the method comprises:终端设备获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The terminal device acquires the current smoothed code rate and fragmentation information set, the smoothed code rate is a code rate that matches the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two fragments Fragmentation information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;所述终端设备从所述分片信息集合中确定目标码率,将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。The terminal device determines a target code rate from the fragmentation information set, and sends a resource request to the server, the target code rate is less than the smoothed code rate, and the prediction of the target fragment corresponding to the target code rate The download duration is shorter than the current cache duration in the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.8.根据权利要求7所述的方法,其特征在于,在所述终端设备获取当前的平滑码率和分片信息集合之后,所述终端设备从所述分片信息集合中确定目标码率之前,所述方法还包括:8. The method according to claim 7, characterized in that, after the terminal device obtains the current smooth code rate and fragmentation information set, before the terminal device determines the target code rate from the fragmentation information set , the method also includes:所述终端设备从所述分片信息集合中确定低于所述平滑码率的码率集合。The terminal device determines a code rate set lower than the smoothed code rate from the slice information set.9.根据权利要求8所述的方法,其特征在于,所述终端设备从所述分片信息集合中确定目标码率,将资源请求发送至所述服务器,包括:9. The method according to claim 8, wherein the terminal device determines the target code rate from the fragmentation information set, and sends the resource request to the server, comprising:所述终端设备从所述码率集合中选择候选码率;The terminal device selects a candidate code rate from the code rate set;所述终端设备根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长;The terminal device obtains the predicted download duration of the candidate segment according to the segment size of the candidate segment corresponding to the candidate code rate and the average rate;所述终端设备判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率;The terminal device judges whether the predicted download duration of the candidate fragment is greater than the cache duration, and if the predicted download duration of the candidate fragment is greater than the cache duration, then selects from the fragment set that is lower than the cache duration. The code rate of the candidate slice is used as the candidate code rate;若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, the candidate code rate is used as the target code rate, and the resource request is sent to the server, and the resource request is used to request to download the The target slice corresponding to the target code rate.10.一种服务器,其特征在于,所述服务器包括:10. A server, characterized in that the server comprises:收发模块,用于接收终端设备的资源请求,所述资源请求包括平滑码率和所述终端设备缓存区的缓存时长,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率;A transceiver module, configured to receive a resource request from a terminal device, where the resource request includes a smoothed code rate and a cache duration of the buffer area of the terminal device, and the smoothed code rate is the same as the download rate of the currently downloaded video source of the terminal device matching code rate;处理模块,用于从所述终端设备当前待播放的视频片源中确定目标分片,通过所述收发模块将所述目标分片发送至所述终端设备,所述目标分片的码率小于所述平滑码率,所述目标分片的预测下载时长小于所述缓存时长。A processing module, configured to determine a target segment from the video source currently to be played by the terminal device, and send the target segment to the terminal device through the transceiver module, and the code rate of the target segment is less than In the smooth code rate, the predicted download duration of the target segment is less than the cache duration.11.根据权利要求10所述的服务器,其特征在于,所述处理模块具体用于:11. The server according to claim 10, wherein the processing module is specifically configured to:从码率集合中选择候选码率,所述码率集合是指分片信息集合中低于所述平滑码率的码率的集合,所述分片信息集合包括至少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;Select a candidate code rate from a code rate set, the code rate set refers to a set of code rates lower than the smooth code rate in the fragmentation information set, and the fragmentation information set includes fragments of at least two fragments information, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes the code rate of fragmentation size and fragmentation;根据平均速率和所述候选码率对应的目标分片的分片大小得到所述候选分片的预测下载时长,所述平均速率为所述终端设备当前下载分片的平均速率;Obtain the predicted download duration of the candidate fragment according to the fragment size of the target fragment corresponding to the average rate and the candidate code rate, and the average rate is the average rate of the terminal device currently downloading the fragment;判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述预测下载时长大于所述缓存时长,则从所述码率集合中选择码率低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration is greater than the cache duration, select a code rate lower than the code rate of the candidate fragment from the code rate set As the candidate code rate;若所述候选分片的预测下载时长小于所述缓存时长,则通过所述收发模块将所述候选分片作为所述目标分片发送至所述终端设备。If the predicted download duration of the candidate segment is less than the buffer duration, the candidate segment is sent to the terminal device as the target segment by the transceiver module.12.根据权利要求11所述的服务器,其特征在于,所述码率集合由所述资源请求携带的指示信息指示,或者所述码率集合由所述服务器根据所述平滑码率从所述分片信息集合选择的码率的集合。12. The server according to claim 11, wherein the code rate set is indicated by the indication information carried in the resource request, or the code rate set is determined by the server according to the smoothed code rate from the A collection of code rates selected by the fragmentation information collection.13.根据权利要求11或12所述的服务器,其特征在于,所述平均速率在所述资源请求携带,或者由所述服务器统计得到。13. The server according to claim 11 or 12, wherein the average rate is carried in the resource request, or obtained by statistics of the server.14.根据权利要求11-13任一所述的服务器,其特征在于,所述处理模块还用于:14. The server according to any one of claims 11-13, wherein the processing module is further configured to:若所述候选分片的预测下载时长大于所述缓存时长,则通过所述收发模块将请求响应发送至所述终端设备,所述请求响应携带与所述候选分片属于相同视频片源且码率低于所述候选分片的分片的下载地址。If the predicted download duration of the candidate segment is longer than the buffer duration, the request response is sent to the terminal device through the transceiver module, and the request response carries the same video source as the candidate segment and the code The download address of the segment whose rate is lower than the candidate segment.15.根据权利要求10或11所述的服务器,其特征在于,所述资源请求还包括用于指示所述服务器是否切换到码率自适应模式的字段,和/或,所述资源请求还包括指示缓存偏移量的字段,所述缓存偏移量是指自所述终端设备发送所述资源请求到所述服务器接收到所述资源请求期间,所述终端设备缓存区的缓存消耗的估计值。15. The server according to claim 10 or 11, wherein the resource request further includes a field for indicating whether the server switches to a code rate adaptive mode, and/or, the resource request further includes A field indicating a cache offset, where the cache offset refers to an estimated value of the cache consumption of the terminal device's cache area during the period from when the terminal device sends the resource request to when the server receives the resource request .16.一种终端设备,其特征在于,所述终端设备包括:16. A terminal device, characterized in that the terminal device comprises:收发模块,用于获取当前的平滑码率和分片信息集合,所述平滑码率为与所述终端设备当前下载视频片源的下载速率匹配的码率,所述分片信息集合包括少两个分片的分片信息,所述至少两个分片属于当前待播放的相同视频片源,分片信息包括分片大小和分片的码率;The transceiver module is used to obtain the current smooth code rate and fragmentation information set, the smooth code rate matches the code rate of the download rate of the video source currently downloaded by the terminal device, and the fragmentation information set includes at least two The fragmentation information of fragments, the at least two fragments belong to the same video source to be played currently, and the fragmentation information includes fragmentation size and code rate of fragmentation;处理模块,用于从所述收发模块获取的所述分片信息集合中确定目标码率,通过所述收发模块将资源请求发送至所述服务器,所述目标码率小于所述平滑码率,所述目标码率对应的目标分片的预测下载时长小于所述终端设备缓存区当前的缓存时长,所述资源请求用于请求下载所述目标码率对应的目标分片。a processing module, configured to determine a target code rate from the fragmentation information set acquired by the transceiver module, and send a resource request to the server through the transceiver module, where the target code rate is less than the smoothed code rate, The predicted download duration of the target segment corresponding to the target code rate is less than the current buffer duration of the buffer area of the terminal device, and the resource request is used to request to download the target segment corresponding to the target code rate.17.根据权利要求16所述的终端设备,其特征在于,所述处理模块在所述收发模块获取当前的平滑码率和分片信息集合之后,在从所述分片信息集合中确定目标码率之前,还用于:17. The terminal device according to claim 16, wherein the processing module determines the target code from the fragmentation information set after the transceiver module obtains the current smooth code rate and the fragmentation information set Before rate, also used for:从所述分片信息集合中确定低于所述平滑码率的码率集合。Determining a code rate set lower than the smoothed code rate from the slice information set.18.根据权利要求17所述的终端设备,其特征在于,所述处理模块具体用于:18. The terminal device according to claim 17, wherein the processing module is specifically used for:从所述码率集合中选择候选码率;selecting a candidate code rate from the code rate set;根据所述候选码率对应的候选分片的分片大小和所述平均速率得到所述候选分片的预测下载时长;Obtaining the predicted download duration of the candidate fragments according to the fragment size of the candidate fragments corresponding to the candidate code rate and the average rate;判断所述候选分片的预测下载时长是否大于所述缓存时长,若所述候选分片的预测下载时长大于所述缓存时长,则从所述分片集合中选择低于所述候选分片的码率作为所述候选码率;Judging whether the predicted download duration of the candidate fragment is greater than the cache duration, if the predicted download duration of the candidate fragment is greater than the cache duration, then select the candidate fragment lower than the candidate fragment from the fragment set The code rate is used as the candidate code rate;若所述候选分片的预测下载时长小于所述缓存时长,则将所述候选码率作为所述目标码率,通过所述收发模块将所述资源请求发送至所述服务器,所述资源请求用于请求下载所述目标码率对应的所述目标分片。If the predicted download duration of the candidate segment is less than the cache duration, then use the candidate code rate as the target code rate, and send the resource request to the server through the transceiver module, and the resource request It is used to request to download the target segment corresponding to the target code rate.
CN201710190142.2A2017-03-272017-03-27 A method and device for adjusting streaming media bit rateActiveCN108668146B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201710190142.2ACN108668146B (en)2017-03-272017-03-27 A method and device for adjusting streaming media bit rate

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201710190142.2ACN108668146B (en)2017-03-272017-03-27 A method and device for adjusting streaming media bit rate

Publications (2)

Publication NumberPublication Date
CN108668146Atrue CN108668146A (en)2018-10-16
CN108668146B CN108668146B (en)2021-07-16

Family

ID=63786362

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201710190142.2AActiveCN108668146B (en)2017-03-272017-03-27 A method and device for adjusting streaming media bit rate

Country Status (1)

CountryLink
CN (1)CN108668146B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110149560A (en)*2019-06-052019-08-20亦非云互联网技术(上海)有限公司Player optimization method and system, storage medium and terminal based on HLS protocol
CN110267100A (en)*2019-07-122019-09-20北京达佳互联信息技术有限公司Code rate switching method, device, electronic equipment and the storage medium of FLV video
CN110460875A (en)*2019-08-052019-11-15北京达佳互联信息技术有限公司A kind of switching method of video code rate, device, electronic equipment and storage medium
CN110996038A (en)*2019-11-192020-04-10清华大学Adaptive code rate adjusting method for multi-person interactive live broadcast
CN111787336A (en)*2019-04-042020-10-16杭州海康威视数字技术股份有限公司Code rate switching method and device
CN112153428A (en)*2020-11-042020-12-29上海连尚网络科技有限公司 Video processing method and device
CN112637631A (en)*2020-12-172021-04-09清华大学Code rate determining method and device, electronic equipment and storage medium
CN113316005A (en)*2021-04-202021-08-27新华三技术有限公司Method for adjusting video code rate and communication system
CN113573062A (en)*2020-04-292021-10-29华为技术有限公司 Traffic shaping method, device and electronic device

Citations (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1670256A2 (en)*2004-12-102006-06-14Microsoft CorporationA system and process for controlling the coding bit rate of streaming media data
CN104320424A (en)*2014-11-202015-01-28三星电子(中国)研发中心Streaming media fragmentation downloading method and device
CN105100876A (en)*2015-08-282015-11-25北京奇艺世纪科技有限公司Streaming media playing method and device
CN105744342A (en)*2016-01-282016-07-06腾讯科技(深圳)有限公司Data transmission method and device for mobile terminal
CN106028085A (en)*2016-06-142016-10-12浙江工业大学DASH-based multi-client-side code rate self-adaption and oscillation compensation method
CN106162229A (en)*2015-04-102016-11-23北京大学Improve smooth code check adaptive approach and the device of fairness
CN106303704A (en)*2016-08-192017-01-04上海交通大学A kind of DASH flow medium live system based on proxy server and method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP1670256A2 (en)*2004-12-102006-06-14Microsoft CorporationA system and process for controlling the coding bit rate of streaming media data
CN104320424A (en)*2014-11-202015-01-28三星电子(中国)研发中心Streaming media fragmentation downloading method and device
CN106162229A (en)*2015-04-102016-11-23北京大学Improve smooth code check adaptive approach and the device of fairness
CN105100876A (en)*2015-08-282015-11-25北京奇艺世纪科技有限公司Streaming media playing method and device
CN105744342A (en)*2016-01-282016-07-06腾讯科技(深圳)有限公司Data transmission method and device for mobile terminal
CN106028085A (en)*2016-06-142016-10-12浙江工业大学DASH-based multi-client-side code rate self-adaption and oscillation compensation method
CN106303704A (en)*2016-08-192017-01-04上海交通大学A kind of DASH flow medium live system based on proxy server and method

Cited By (14)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111787336A (en)*2019-04-042020-10-16杭州海康威视数字技术股份有限公司Code rate switching method and device
CN110149560A (en)*2019-06-052019-08-20亦非云互联网技术(上海)有限公司Player optimization method and system, storage medium and terminal based on HLS protocol
CN110149560B (en)*2019-06-052021-11-16亦非云互联网技术(上海)有限公司Player optimization method and system based on HLS protocol, storage medium and terminal
CN110267100A (en)*2019-07-122019-09-20北京达佳互联信息技术有限公司Code rate switching method, device, electronic equipment and the storage medium of FLV video
CN110267100B (en)*2019-07-122022-01-25北京达佳互联信息技术有限公司Code rate switching method and device for FLV (flash video), electronic equipment and storage medium
CN110460875A (en)*2019-08-052019-11-15北京达佳互联信息技术有限公司A kind of switching method of video code rate, device, electronic equipment and storage medium
CN110996038A (en)*2019-11-192020-04-10清华大学Adaptive code rate adjusting method for multi-person interactive live broadcast
CN110996038B (en)*2019-11-192020-11-10清华大学 An adaptive bit rate adjustment method for multi-person interactive live broadcast
CN113573062A (en)*2020-04-292021-10-29华为技术有限公司 Traffic shaping method, device and electronic device
CN113573062B (en)*2020-04-292023-12-29华为技术有限公司Traffic shaping method and device and electronic equipment
CN112153428A (en)*2020-11-042020-12-29上海连尚网络科技有限公司 Video processing method and device
CN112637631A (en)*2020-12-172021-04-09清华大学Code rate determining method and device, electronic equipment and storage medium
CN112637631B (en)*2020-12-172022-04-26清华大学 Code rate determination method, device, electronic device and storage medium
CN113316005A (en)*2021-04-202021-08-27新华三技术有限公司Method for adjusting video code rate and communication system

Also Published As

Publication numberPublication date
CN108668146B (en)2021-07-16

Similar Documents

PublicationPublication DateTitle
CN108668146B (en) A method and device for adjusting streaming media bit rate
US10455404B2 (en)Quality of experience aware multimedia adaptive streaming
US9401968B2 (en)Method and apparatus for enabling pre-fetching of media
CN102843351B (en)A kind of processing method of streaming media service, streaming media server and system
CN102006368B (en)Streaming media audio file play method based on mobile terminal memory card cache technology
CN101917742B (en)Data transmission method, equipment and system
CN110933517B (en) Rate switching method, client and computer-readable storage medium
CN106688239A (en)Video downloading method, apparatus, and system
WO2011054319A1 (en)Method, device and system for realizing hierarchically requesting content in http streaming system
WO2014121685A1 (en)Streaming media request method and controller
US10856015B2 (en)Method for operating a cache arranged along a transmission path between client terminals and at least one server, and corresponding cache
CN105245562A (en) Method for operating cache and corresponding cache
CN106658067A (en)Cache setting method and apparatus
CN104641655A (en)Terminal cache method, terminal and server
WO2013097184A1 (en)Service distribution method, device and system
CN102217278B (en) A method and device for online adaptation of media content
TW201501526A (en)Method for providing a content part of a multimedia content to a client terminal, corresponding cache
CN104066015A (en) Streaming media playback method and device for mobile terminal
KR102237900B1 (en)Method for retrieving, by a client terminal, a content part of a multimedia content
KR20130134911A (en)Method for providing content caching service in adapted streaming service and local caching device thereof
KR20130048457A (en)Server and method for managing contents to be distributed to cache device, and the cache device
TW201542013A (en)Method for obtaining network information by a client terminal configured for receiving a multimedia content divided into segments
WO2016172967A1 (en)Media stream transmission method and device
Mubarok et al.Dynamic Adaptive Video Streaming: A Comparative Examination of NDN and IP Architectures in Real-world Scenarios
TW201542014A (en)Method for obtaining network information by a client terminal configured for receiving a multimedia content divided into segments

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp