WO2016101240A1 - Media data playing method and terminal - Google Patents

Media data playing method and terminal Download PDF

Info

Publication number
WO2016101240A1
WO2016101240A1 PCT/CN2014/095063 CN2014095063W WO2016101240A1 WO 2016101240 A1 WO2016101240 A1 WO 2016101240A1 CN 2014095063 W CN2014095063 W CN 2014095063W WO 2016101240 A1 WO2016101240 A1 WO 2016101240A1
Authority
WO
WIPO (PCT)
Prior art keywords
code rate
media data
rate
buffer
client
Prior art date
Application number
PCT/CN2014/095063
Other languages
French (fr)
Chinese (zh)
Inventor
王文标
Original Assignee
深圳Tcl数字技术有限公司
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 深圳Tcl数字技术有限公司 filed Critical 深圳Tcl数字技术有限公司
Publication of WO2016101240A1 publication Critical patent/WO2016101240A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/437Interfacing the upstream path of the transmission network, e.g. for transmitting client requests to a VOD server
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/442Monitoring of processes or resources, e.g. detecting the failure of a recording device, monitoring the downstream bandwidth, the number of times a movie has been viewed, the storage space available from the internal hard disk

Definitions

  • the present invention relates to the field of media playback technologies, and in particular, to a method and a terminal for playing media data.
  • the terminal's playback system supports high and low bit rate switching.
  • a chat system with video, audio and subtitles can directly discard the video part and even remove the video and audio parts in the case of insufficient bandwidth. Leave the display of subtitles.
  • the speed of restarting playback after switching the code rate is slow.
  • a playback source with video, audio and subtitles due to insufficient bandwidth, the amount of data acquired from the server per unit time will be reduced, the playback system retrieves the source from the server, and then removes the video portion, according to the existing If the cache policy is used to start playback, it will take a long time to cache the original amount of data. After the code rate is switched, the playback speed is slower.
  • the main object of the present invention is to provide a method and a terminal for playing media data, aiming at solving the technical problem that the speed of restarting playback after switching the code rate is slow.
  • the present invention provides a method for playing media data, and the method for playing media data includes the following steps:
  • the media data buffered by the client is cleared and a request for acquiring new media data is sent to the server;
  • the buffered new media data is sent to the player for playback.
  • the step of obtaining the current code rate, and calculating the current data volume buffer rate Rs and the average code rate buffer time ratio Rt according to the code rate includes:
  • Calculating a current data volume buffer ratio Rs according to the code rate and the set buffer data maximum value Ms calculating an average code rate buffer time ratio Rt according to the code rate and the set cache maximum time Mt, wherein The S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
  • the receiving and buffering the new media data sent by the server determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
  • the steps include:
  • the receiving and buffering the new media data sent by the server determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
  • the steps include:
  • the step of clearing the media data buffered by the client and sending the request for acquiring new media data to the server further includes:
  • the client detects whether the bandwidth changes or detects whether the rate switching instruction sent by the player is received.
  • the player is a gstreamer player.
  • the present invention further provides a terminal, where the terminal includes:
  • the clearing module is configured to: when the client of the terminal detects that the code rate switching is required, clear the media data buffered by the client and send a request for acquiring new media data to the server;
  • a calculation module configured to obtain a current code rate, and calculate a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
  • a judging module configured to receive and cache new media data sent by the server, and determine, according to the current data volume caching rate Rs and the average bit rate buffering time ratio Rt, whether the new media data buffered by the client reaches a preset value.
  • the sending module is configured to send the buffered new media data to the player for playing if the current data volume buffer rate Rs reaches 1 or the average time rate buffer time ratio Rt reaches 1.
  • the calculation module comprises:
  • a first obtaining unit configured to acquire a current code rate, a set cache data amount maximum value Ms, and a set cache maximum time Mt;
  • a calculating unit configured to calculate a current data volume buffer rate Rs according to the code rate and the set buffer data maximum value Ms: and calculate an average bit rate buffer time ratio according to the code rate and the set cache maximum time Mt Rt:, wherein S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
  • the determining module comprises:
  • a comparing unit configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
  • a second acquiring unit configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
  • the determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  • the determining module comprises:
  • a comparing unit configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
  • a second acquiring unit configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
  • the determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  • the terminal further includes:
  • the detecting module is configured to: during the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
  • the player is a gstreamer player.
  • the method and terminal for playing media data of the present invention when the client detects that a code rate switching is required, confirms whether the high code rate is switched to a low code rate or a low code rate to a high code rate, and then according to the current
  • the code rate calculates the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, that is, whether the amount of new media data buffered by the client reaches a preset value by using the buffer amount or the buffer time, as long as one of them reaches the preset value. If the value is set, the client is considered to be cached and the player can restart the playback.
  • the present invention is based on the cache amount or cache time of the client, and can be quickly restarted regardless of insufficient bandwidth or insufficient playback performance of the terminal. To make the playback better.
  • FIG. 1 is a schematic flowchart of a first embodiment of a method for playing media data according to the present invention
  • FIG. 2 is a schematic diagram of a refinement process of step S102 in FIG. 1;
  • step S103 in FIG. 1 is a schematic diagram showing the refinement process of step S103 in FIG. 1;
  • FIG. 4 is a schematic flowchart diagram of a second embodiment of a method for playing media data according to the present invention.
  • FIG. 5 is a schematic diagram of functional modules of a first embodiment of a terminal according to the present invention.
  • FIG. 6 is a schematic diagram of a refinement function module of the calculation module in FIG. 5;
  • FIG. 7 is a schematic diagram of a refinement function module of the judging module in FIG. 5;
  • FIG. 8 is a schematic diagram of functional modules of a second embodiment of a terminal according to the present invention.
  • the present invention provides a method for playing media data.
  • the method for playing media data includes:
  • Step S101 when the client of the terminal detects that the code rate switching needs to be performed, clearing the media data buffered by the client and sending a request for acquiring new media data to the server;
  • the terminal may be a television, a computer, a tablet computer, a mobile phone, or the like.
  • the client of the terminal acquires media data from the server and caches the data, and then sends the cached media data to the player for playing.
  • the client responds to the user's operation, creates a play instance and requests media data from the server, and the server responds to the client request to media data in the elementary stream (Elementary Streams, ES) is sent to the client, and the elementary stream may contain one or more of video, audio, subtitles, and the like.
  • the elementary stream may contain one or more of video, audio, subtitles, and the like.
  • the client when the client detects that code rate switching is required, for example, when the current bandwidth is insufficient or the playback performance of the terminal is insufficient, rate switching is required.
  • the client empties the media data currently cached by itself to re-receive the media data sent by the server.
  • the client when detecting whether the rate switching needs to be performed, the client can detect whether to switch from a high code rate to a low code rate or a low code rate to a high code rate. A request to obtain corresponding media data is then sent to the server.
  • Step S102 obtaining a current code rate, and calculating a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
  • the current data buffer rate Rs refers to the ratio of the currently buffered data amount S to the set cache data amount maximum value Ms:
  • the current network speed is faster, the larger the current cached data amount S is, the larger the current data buffer rate Rs is, and the currently buffered data amount S is proportional to the current code rate, and therefore, according to the current The code rate is calculated to obtain the current buffered data amount S.
  • the average bit rate buffer time ratio Rt refers to the ratio of the buffer data average code rate time T to the set cache maximum time Mt:
  • the buffer data average code rate time T is inversely proportional to the current code rate, that is, the buffer data average code rate time T is smaller, and thus the average bit rate is The smaller the cache time ratio Rt.
  • the buffering strategy of this embodiment is based on the ratio of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
  • Step S103 receiving and buffering new media data sent by the server, and determining, according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, whether the new media data buffered by the client reaches a preset value;
  • the client receives the new media data sent by the server and caches it, and the client caches the new media data in a specific sample format, and each sample is independent, including descriptions of the new media data and the new media data. Dts, duration and other information.
  • the client receives the new media data sent by the server, and then determines the new media cached by the client according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt calculated above. Whether the data reaches the preset value.
  • Step S104 If the current data volume buffer rate Rs reaches 1 or the average code rate buffer time ratio Rt reaches 1, the buffered new media data is sent to the player for playing.
  • the player is preferably a gstreamer player
  • the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video.
  • the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video.
  • you can also create many multimedia applications such as video editors, streaming media and media players.
  • one of the current data volume buffer rate Rs or the average code rate buffer time ratio Rt reaches 100% first, then the client cache is completed, and the client sends the play information to the player to notify the player to restart. Play, the player creates a pipe and starts playback, and requests new media data from the client.
  • media data of different sources is divided.
  • the player requests media data from the client in a special request format, and the request format specification section contains the media data that needs to be requested and the number of media data requested. Regardless of whether it is a client or a player, media data of different sources are independently requested and independently stored, so that media data of different sources can be processed separately.
  • the player side saves the media data of different sources in different queues in a specific format, and sequentially obtains media data from the data queues in order according to the order of the media data requests, keeps the data synchronized and does not cause a certain way. The accumulation of media data.
  • the acknowledgment is whether the high code rate is switched to the low code rate or the low code rate is switched to the high code rate, and then according to the current code rate.
  • Calculating the current data volume buffer rate Rs and the average bit rate buffer time ratio Rt that is, whether the amount of new media data buffered by the client reaches a preset value by using the buffer amount or the buffer time, as long as one of them reaches the preset value
  • the player can restart the playback.
  • the cache policy is used according to the cache amount or the cache time of the client. Whether the bandwidth is insufficient or the playback performance of the terminal is insufficient, the playback can be restarted quickly. Make the playback better.
  • the foregoing step S102 includes:
  • Step S1021 acquiring the current code rate, the set cache data amount maximum value Ms, and the set cache maximum time Mt;
  • Step S1022 Calculate a current data volume buffer rate Rs according to the code rate and the set cache data amount maximum value Ms: and calculate an average code rate buffer time ratio Rt according to the code rate and the set cache maximum time Mt: .
  • the current data buffer rate Rs:;S is the current buffered data amount
  • Ms is the set cache data amount maximum, wherein the currently buffered data amount S is the current code rate A and the buffer time x.
  • Product of: S A*x.
  • the set cache maximum time Mt is the cache data average code rate time, and Mt is the set cache maximum time.
  • the average code rate A is the average of the code rate per unit time and the old average code rate v, wherein the code rate per unit time refers to the ratio of the received media data to the reception time in the set unit time:
  • the old average code rate v refers to the average code rate value calculated in the previous period of time. This period is set to N.
  • the average code rate A formula is:
  • the foregoing step S103 includes:
  • Step S1031 comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
  • Step S1032 when the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one reaching 1;
  • Step S1033 Determine whether the time of the new media data buffered by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  • a buffer time x is preset, and then the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are calculated, when the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are two ratios.
  • one of the first reaches 100%, it is considered that the new media data cached by the client reaches the condition for restarting playback.
  • the maximum amount of cached data set by the client is 2M, and the cache time is x (the client clears the cache and sends a request for obtaining new media data to the server for the cache time).
  • the current code rate is 1.5M (for the convenience of calculation, assuming that the code rate does not fluctuate)
  • the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are respectively in the buffer time x after the code rate is switched.
  • the current data volume buffer rate Rs will be the first to be cached up to 100% before the rate change, and the time when the current data volume buffer rate Rs reaches 100% is the time of the new media data cached by the client. At this time, the playback is restarted, and the playback can be started quickly after the bit rate is switched;
  • the buffer time ratio Rt at the average bit rate first reaches 100%, and the time when the buffer time ratio Rt reaches 100% at the average code rate is the time of the new media data buffered by the client, when the time is reached. , restart playback, you can quickly start playback after the bit rate is switched.
  • the method includes:
  • Step S100 During the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
  • the playback performance of the terminal is sufficient, and the client detects whether the bandwidth changes, that is, whether the bandwidth is changed from large to small or from small to large.
  • the client initiates the code. Rate switching.
  • the client clears the cache and requests new media data from the server, while sending a pause play command to the player.
  • the performance of the CPU may be sufficient but the performance of the decoder is insufficient, resulting in a high-rate video cannot be played.
  • the player Sending a code rate switching instruction to notify the client that the playback performance of the player is insufficient.
  • the client determines that the code rate switching is because the code rate is too high but the playback performance of the terminal is insufficient, causing the playback to fail, and then The client initiates the entire bit rate switch.
  • the terminal considering that there are many cases where rate switching occurs, it is impossible for the terminal to define a caching policy for each case, which will become complicated.
  • the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are the basis of the client cache policy, and the problem can be solved simply and reasonably.
  • the present invention further provides a terminal.
  • the terminal includes:
  • the clearing module 101 is configured to: when the client of the terminal detects that the code rate switching is required, clear the media data buffered by the client and send a request for acquiring new media data to the server;
  • the terminal may be a television, a computer, a tablet computer, a mobile phone, or the like.
  • the client of the terminal acquires media data from the server and caches the data, and then sends the cached media data to the player for playing.
  • the client responds to the user's operation, creates a play instance and requests media data from the server, and the server responds to the client request to media data in the elementary stream (Elementary Streams, ES) is sent to the client, and the elementary stream may contain one or more of video, audio, subtitles, and the like.
  • the elementary stream may contain one or more of video, audio, subtitles, and the like.
  • the client when the client detects that code rate switching is required, for example, when the current bandwidth is insufficient or the playback performance of the terminal is insufficient, rate switching is required.
  • the client empties the media data currently cached by itself to re-receive the media data sent by the server.
  • the client when detecting whether the rate switching needs to be performed, the client can detect whether to switch from a high code rate to a low code rate or a low code rate to a high code rate. A request to obtain corresponding media data is then sent to the server.
  • the calculating module 102 is configured to obtain a current code rate, and calculate a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
  • the current data buffer rate Rs refers to the ratio of the currently buffered data amount S to the set cache data amount maximum value Ms:
  • the current network speed is faster, the larger the current cached data amount S is, the larger the current data buffer rate Rs is, and the currently buffered data amount S is proportional to the current code rate, and therefore, according to the current The code rate is calculated to obtain the current buffered data amount S.
  • the average bit rate buffer time ratio Rt refers to the ratio of the buffer data average code rate time T to the set cache maximum time Mt:
  • the buffer data average code rate time T is inversely proportional to the current code rate, that is, the buffer data average code rate time T is smaller, and thus the average bit rate is The smaller the cache time ratio Rt.
  • the buffering strategy of this embodiment is based on the ratio of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
  • the judging module 103 is configured to receive and cache new media data sent by the server, and determine, according to the current data volume caching rate Rs and the average bit rate buffering time ratio Rt, whether the new media data cached by the client reaches a preset. value;
  • the client receives the new media data sent by the server and caches it, and the client caches the new media data in a specific sample format, and each sample is independent, including descriptions of the new media data and the new media data. Dts, duration and other information.
  • the client receives the new media data sent by the server, and then determines the new media cached by the client according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt calculated above. Whether the data reaches the preset value.
  • the sending module 104 is configured to send the buffered new media data to the player for playing if the current data volume buffer rate Rs reaches 1 or the average time rate buffer time ratio Rt reaches 1.
  • the player is preferably a gstreamer player
  • the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video.
  • the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video.
  • you can also create many multimedia applications such as video editors, streaming media and media players.
  • one of the current data volume buffer rate Rs or the average code rate buffer time ratio Rt reaches 100% first, then the client cache is completed, and the client sends the play information to the player to notify the player to restart. Play, the player creates a pipe and starts playback, and requests new media data from the client.
  • media data of different sources is divided.
  • the player requests media data from the client in a special request format, and the request format specification section contains the media data that needs to be requested and the number of media data requested. Regardless of whether it is a client or a player, media data of different sources are independently requested and independently stored, so that media data of different sources can be processed separately.
  • the player side saves the media data of different sources in different queues in a specific format, and sequentially obtains media data from the data queues in order according to the order of the media data requests, keeps the data synchronized and does not cause a certain way. The accumulation of media data.
  • the computing module 102 includes:
  • the first obtaining unit 1021 is configured to acquire a current code rate, a set cache data amount maximum value Ms, and a set cache maximum time Mt;
  • the calculating unit 1022 is configured to calculate a current data volume buffer rate Rs according to the code rate and the set buffer data maximum value Ms, and calculate an average bit rate buffer time according to the code rate and the set cache maximum time Mt. Ratio Rt:.
  • the current data buffer rate Rs:;S is the current buffered data amount
  • Ms is the set cache data amount maximum, wherein the currently buffered data amount S is the current code rate A and the buffer time x.
  • Product of: S A*x.
  • the set cache maximum time Mt is the cache data average code rate time, and Mt is the set cache maximum time.
  • the average code rate A is the average of the code rate per unit time and the old average code rate v, wherein the code rate per unit time refers to the ratio of the received media data to the reception time in the set unit time:
  • the old average code rate v refers to the average code rate value calculated in the previous period of time. This period is set to N.
  • the average code rate A formula is:
  • the determining module 103 includes:
  • the comparing unit 1031 is configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt. ;
  • the second obtaining unit 1032 is configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
  • the determining unit 1033 is configured to determine whether the time of the new media data buffered by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  • a buffer time x is preset, and then the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are calculated, when the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are two ratios.
  • one of the first reaches 100%, it is considered that the new media data cached by the client reaches the condition for restarting playback.
  • the maximum amount of cached data set by the client is 2M, and the cache time is x (the client clears the cache and sends a request for obtaining new media data to the server for the cache time).
  • the current code rate is 1.5M (for the convenience of calculation, assuming that the code rate does not fluctuate)
  • the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are respectively in the buffer time x after the code rate is switched.
  • the current data volume buffer rate Rs will be the first to be cached up to 100% before the rate change, and the time when the current data volume buffer rate Rs reaches 100% is the time of the new media data cached by the client. At this time, the playback is restarted, and the playback can be started quickly after the bit rate is switched;
  • the buffer time ratio Rt at the average bit rate first reaches 100%, and the time when the buffer time ratio Rt reaches 100% at the average code rate is the time of the new media data buffered by the client, when the time is reached. , restart playback, you can quickly start playback after the bit rate is switched.
  • the terminal further includes:
  • the detecting module 100 is configured to: during the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
  • the playback performance of the terminal is sufficient, and the client detects whether the bandwidth changes, that is, whether the bandwidth is changed from large to small or from small to large.
  • the client initiates the code. Rate switching.
  • the client clears the cache and requests new media data from the server, while sending a pause play command to the player.
  • the performance of the CPU may be sufficient but the performance of the decoder is insufficient, resulting in a high-rate video cannot be played.
  • the player Sending a code rate switching instruction to notify the client that the playback performance of the player is insufficient.
  • the client determines that the code rate switching is because the code rate is too high but the playback performance of the terminal is insufficient, causing the playback to fail, and then The client initiates the entire bit rate switch.
  • the terminal considering that there are many cases where rate switching occurs, it is impossible for the terminal to define a caching policy for each case, which will become complicated.
  • the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are the basis of the client cache policy, and the problem can be solved simply and reasonably.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Databases & Information Systems (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

Disclosed in the present invention are a media data playing method and terminal, and the media data playing method comprises the following steps: when the client of the terminal detects that code rate switch is required, emptying the media data cached in the client and sending a request for obtaining new media data to a server; obtaining the current code rate, and calculating a current data amount cache ratio Rs and the cache time ratio RT under an average code rate according to the code rate; receiving and caching the new media data sent by the server, and determining whether the new media data cached in the client reaches a preset value or not according to the current data amount cache ratio Rs and the cache time ratio RT under the average code rate; if the current data amount cache ratio Rs reaches 1 or the cache time ratio RT under the average code rate reaches 1, then sending the cached new media data to a player for playing. The playing can be restarted quickly during code rate switch with the present invention.

Description

媒体数据播放的方法及终端  Media data playing method and terminal
技术领域Technical field
本发明涉及媒体播放技术领域,尤其涉及一种媒体数据播放的方法及终端。The present invention relates to the field of media playback technologies, and in particular, to a method and a terminal for playing media data.
背景技术Background technique
目前,终端的播放系统支持进行高低码率的切换,例如,一个同时带视频、音频和字幕的聊天系统,在带宽不足的情况下,可直接舍弃视频部分,甚至同时去掉视频和音频部分,只留下字幕的显示。At present, the terminal's playback system supports high and low bit rate switching. For example, a chat system with video, audio and subtitles can directly discard the video part and even remove the video and audio parts in the case of insufficient bandwidth. Leave the display of subtitles.
当进行码率切换时,不论是舍弃部分的资源或者切换播放源,都可能导致另一个问题:切换码率后重新启动播放的速度变慢。例如,一个带视频、音频和字幕的播放源,由于带宽不足,则此时单位时间内从服务器获取的数据量就会减少,播放系统从服务器获取播放源,然后去掉视频部分,按照现有的缓存策略来启动播放,则要缓存原来预定的数据量就需要等待较长的时间,导致码率切换后,重新启动播放的速度较慢。另外,即使在相同的网络环境下,不同的终端的CPU或者解码器等的性能存在差异,特别是终端上述的这些性能较差时,根据带宽来确定播放系统的码率,同样也会导致重新启动播放的速度较慢的问题。When performing rate switching, whether to discard part of the resources or switch the source, another problem may occur: the speed of restarting playback after switching the code rate is slow. For example, a playback source with video, audio and subtitles, due to insufficient bandwidth, the amount of data acquired from the server per unit time will be reduced, the playback system retrieves the source from the server, and then removes the video portion, according to the existing If the cache policy is used to start playback, it will take a long time to cache the original amount of data. After the code rate is switched, the playback speed is slower. In addition, even in the same network environment, the performance of CPUs or decoders of different terminals is different, especially when the above-mentioned performances of the terminal are poor, determining the code rate of the playback system according to the bandwidth also leads to re The problem of slower playback is started.
上述内容仅用于辅助理解本发明的技术方案,并不代表承认上述内容是现有技术。The above content is only used to assist in understanding the technical solutions of the present invention, and does not constitute an admission that the above is prior art.
发明内容Summary of the invention
本发明的主要目的在于提供一种媒体数据播放的方法及终端,旨在解决切换码率后重新启动播放的速度变慢的技术问题。The main object of the present invention is to provide a method and a terminal for playing media data, aiming at solving the technical problem that the speed of restarting playback after switching the code rate is slow.
为实现上述目的,本发明提供一种媒体数据播放的方法,所述媒体数据播放的方法包括以下步骤:To achieve the above objective, the present invention provides a method for playing media data, and the method for playing media data includes the following steps:
当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;When the client of the terminal detects that the code rate switching needs to be performed, the media data buffered by the client is cleared and a request for acquiring new media data is sent to the server;
获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;Obtaining a current code rate, and calculating a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;Receiving and buffering new media data sent by the server, determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。If the current data volume buffer rate Rs reaches 1 or the buffer rate ratio Rt reaches 1 at the average code rate, the buffered new media data is sent to the player for playback.
优选地,所述获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt的步骤包括:Preferably, the step of obtaining the current code rate, and calculating the current data volume buffer rate Rs and the average code rate buffer time ratio Rt according to the code rate includes:
获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;Obtaining the current code rate, the set cache data amount maximum value Ms, and the set cache maximum time Mt;
根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:,其中,所述S为当前缓存的数据量,Ms为设定的缓存数据量最大值,T为缓存数据平均码率时间,Mt为设定的缓存最大时间。Calculating a current data volume buffer ratio Rs according to the code rate and the set buffer data maximum value Ms: calculating an average code rate buffer time ratio Rt according to the code rate and the set cache maximum time Mt, wherein The S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
优选地,所述接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值的步骤包括:Preferably, the receiving and buffering the new media data sent by the server, determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt. The steps include:
比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;Comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;When the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one;
判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。Determining whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
优选地,所述接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值的步骤包括:Preferably, the receiving and buffering the new media data sent by the server, determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt. The steps include:
比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;Comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;When the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one;
判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。Determining whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
优选地,所述当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求的步骤之前还包括:Preferably, when the client of the terminal detects that the code rate switching needs to be performed, the step of clearing the media data buffered by the client and sending the request for acquiring new media data to the server further includes:
在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。During the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the rate switching instruction sent by the player is received.
优选地,所述播放器为gstreamer播放器。Preferably, the player is a gstreamer player.
此外,为实现上述目的,本发明还提供一种终端,所述终端包括:In addition, to achieve the above object, the present invention further provides a terminal, where the terminal includes:
清空模块,用于当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;The clearing module is configured to: when the client of the terminal detects that the code rate switching is required, clear the media data buffered by the client and send a request for acquiring new media data to the server;
计算模块,用于获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;a calculation module, configured to obtain a current code rate, and calculate a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
判断模块,用于接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;a judging module, configured to receive and cache new media data sent by the server, and determine, according to the current data volume caching rate Rs and the average bit rate buffering time ratio Rt, whether the new media data buffered by the client reaches a preset value. ;
发送模块,用于若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。The sending module is configured to send the buffered new media data to the player for playing if the current data volume buffer rate Rs reaches 1 or the average time rate buffer time ratio Rt reaches 1.
优选地,所述计算模块包括:Preferably, the calculation module comprises:
第一获取单元,用于获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;a first obtaining unit, configured to acquire a current code rate, a set cache data amount maximum value Ms, and a set cache maximum time Mt;
计算单元,用于根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:,其中,所述S为当前缓存的数据量,Ms为设定的缓存数据量最大值,T为缓存数据平均码率时间,Mt为设定的缓存最大时间。a calculating unit, configured to calculate a current data volume buffer rate Rs according to the code rate and the set buffer data maximum value Ms: and calculate an average bit rate buffer time ratio according to the code rate and the set cache maximum time Mt Rt:, wherein S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
优选地,所述判断模块包括:Preferably, the determining module comprises:
比较单元,用于比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;a comparing unit, configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
第二获取单元,用于当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;a second acquiring unit, configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
判断单元,用于判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。The determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
优选地,所述判断模块包括:Preferably, the determining module comprises:
比较单元,用于比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;a comparing unit, configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
第二获取单元,用于当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;a second acquiring unit, configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
判断单元,用于判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。The determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
优选地,所述终端还包括:Preferably, the terminal further includes:
检测模块,用于在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。The detecting module is configured to: during the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
优选地,所述播放器为gstreamer播放器。Preferably, the player is a gstreamer player.
本发明一种媒体数据播放的方法及终端,当客户端检测到需要进行码率切换时,确认是由高码率切换为低码率还是由低码率切换为高码率,然后根据当前的码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt,即以缓存量或缓存时间来对客户端缓存的新媒体数据的量是否达到预设值进行判断,只要其中一个达到预设值,则认为客户端缓存完成,播放器可以重新启动播放,本发明根据客户端的缓存量或缓存时间为缓存策略的依据,无论是带宽不足或终端的播放性能不足,均能够快速重新启动播放,使播放的效果更佳。The method and terminal for playing media data of the present invention, when the client detects that a code rate switching is required, confirms whether the high code rate is switched to a low code rate or a low code rate to a high code rate, and then according to the current The code rate calculates the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, that is, whether the amount of new media data buffered by the client reaches a preset value by using the buffer amount or the buffer time, as long as one of them reaches the preset value. If the value is set, the client is considered to be cached and the player can restart the playback. The present invention is based on the cache amount or cache time of the client, and can be quickly restarted regardless of insufficient bandwidth or insufficient playback performance of the terminal. To make the playback better.
附图说明DRAWINGS
图1为本发明媒体数据播放的方法第一实施例的流程示意图;1 is a schematic flowchart of a first embodiment of a method for playing media data according to the present invention;
图2为图1中步骤S102的细化流程示意图;2 is a schematic diagram of a refinement process of step S102 in FIG. 1;
图3为图1中步骤S103的细化流程示意图;3 is a schematic diagram showing the refinement process of step S103 in FIG. 1;
图4为本发明媒体数据播放的方法第二实施例的流程示意图;4 is a schematic flowchart diagram of a second embodiment of a method for playing media data according to the present invention;
图5为本发明终端第一实施例的功能模块示意图;FIG. 5 is a schematic diagram of functional modules of a first embodiment of a terminal according to the present invention; FIG.
图6为图5中计算模块的细化功能模块示意图;6 is a schematic diagram of a refinement function module of the calculation module in FIG. 5;
图7为图5中判断模块的细化功能模块示意图;7 is a schematic diagram of a refinement function module of the judging module in FIG. 5;
图8为本发明终端第二实施例的功能模块示意图。FIG. 8 is a schematic diagram of functional modules of a second embodiment of a terminal according to the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features, and advantages of the present invention will be further described in conjunction with the embodiments.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
本发明提供一种媒体数据播放的方法,参照图1,在一实施例中,该媒体数据播放的方法包括:The present invention provides a method for playing media data. Referring to FIG. 1, in an embodiment, the method for playing media data includes:
步骤S101,当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;Step S101, when the client of the terminal detects that the code rate switching needs to be performed, clearing the media data buffered by the client and sending a request for acquiring new media data to the server;
本实施例中,终端可以是电视、电脑、平板电脑或者手机等等。In this embodiment, the terminal may be a television, a computer, a tablet computer, a mobile phone, or the like.
本实施例中,终端的客户端从服务器上获取媒体数据并进行缓存,然后将缓存的媒体数据发送给播放器进行播放。In this embodiment, the client of the terminal acquires media data from the server and caches the data, and then sends the cached media data to the player for playing.
本实施例中,客户端响应用户的操作,创建播放实例并向服务器请求媒体数据,服务器端响应客户端的请求,将媒体数据以基本码流(Elementary Streams,ES)的形式发送给客户端,基本码流可能包含视频、音频、字幕等的其中一个或多个。In this embodiment, the client responds to the user's operation, creates a play instance and requests media data from the server, and the server responds to the client request to media data in the elementary stream (Elementary Streams, ES) is sent to the client, and the elementary stream may contain one or more of video, audio, subtitles, and the like.
本实施例中,当客户端检测到需要进行码率切换时,例如,当前的带宽不足或者终端的播放性能不足时,需要进行码率切换。客户端将自身当前缓存的媒体数据清空,以重新接收服务器发送的媒体数据。In this embodiment, when the client detects that code rate switching is required, for example, when the current bandwidth is insufficient or the playback performance of the terminal is insufficient, rate switching is required. The client empties the media data currently cached by itself to re-receive the media data sent by the server.
本实施例中,客户端在检测是否需要进行码率切换时,能够检测到是由高码率切换为低码率还是由低码率切换为高码率。然后向服务器发送获取对应的媒体数据的请求。In this embodiment, when detecting whether the rate switching needs to be performed, the client can detect whether to switch from a high code rate to a low code rate or a low code rate to a high code rate. A request to obtain corresponding media data is then sent to the server.
步骤S102,获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;Step S102, obtaining a current code rate, and calculating a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
本实施例中,当前数据缓存量率Rs是指当前缓存的数据量S和设定的缓存数据量最大值Ms的比值:In this embodiment, the current data buffer rate Rs refers to the ratio of the currently buffered data amount S to the set cache data amount maximum value Ms:
,
如果当前的网速越快,累积的当前缓存的数据量S越大,当前数据缓存量率Rs就越大,而当前缓存的数据量S与当前的码率成正比关系,因此,可以根据当前的码率计算得到当前缓存的数据量S。If the current network speed is faster, the larger the current cached data amount S is, the larger the current data buffer rate Rs is, and the currently buffered data amount S is proportional to the current code rate, and therefore, according to the current The code rate is calculated to obtain the current buffered data amount S.
本实施例中,平均码率下缓存时间比率Rt是指缓存数据平均码率时间T和设定的缓存最大时间Mt的比值:In this embodiment, the average bit rate buffer time ratio Rt refers to the ratio of the buffer data average code rate time T to the set cache maximum time Mt:
,
如果当前的网速越快,累积一定的缓存数据量越快,而缓存数据平均码率时间T与当前的码率成反比关系,即缓存数据平均码率时间T越小,从而平均码率下缓存时间比率Rt越小。If the current network speed is faster, the accumulated buffer data amount is faster, and the buffer data average code rate time T is inversely proportional to the current code rate, that is, the buffer data average code rate time T is smaller, and thus the average bit rate is The smaller the cache time ratio Rt.
本实施例的缓存策略以当前数据量缓存率Rs及平均码率下缓存时间比率Rt这两个比值为依据。The buffering strategy of this embodiment is based on the ratio of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
步骤S103,接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;Step S103, receiving and buffering new media data sent by the server, and determining, according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, whether the new media data buffered by the client reaches a preset value;
本实施例中,客户端接收服务器端的发送的新媒体数据并进行缓存,客户端以特定的样本形式缓存新媒体数据,每个样本都是独立的,包括新媒体数据及新媒体数据的说明如dts、duration等信息。In this embodiment, the client receives the new media data sent by the server and caches it, and the client caches the new media data in a specific sample format, and each sample is independent, including descriptions of the new media data and the new media data. Dts, duration and other information.
本实施例中,在当前的码率下,客户端接收服务器发送的新媒体数据,然后根据上述计算得到的当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断客户端缓存的新媒体数据是否达到预设值。In this embodiment, at the current code rate, the client receives the new media data sent by the server, and then determines the new media cached by the client according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt calculated above. Whether the data reaches the preset value.
本实施例中,如果当前数据量缓存率Rs达到100%或者平均码率下缓存时间比率Rt达到100%均认为客户端缓存的新媒体数据已经达到预设值,可以重新启动播放。In this embodiment, if the current data volume buffer rate Rs reaches 100% or the average code rate buffer time ratio Rt reaches 100%, it is considered that the new media data buffered by the client has reached the preset value, and the playback can be restarted.
步骤S104,若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。Step S104: If the current data volume buffer rate Rs reaches 1 or the average code rate buffer time ratio Rt reaches 1, the buffered new media data is sent to the player for playing.
本实施例中,播放器优选地为gstreamer播放器,gstreamer是一个用于创建流媒体应用程序的多媒体框架库,其可以提供构建各种媒体功能组件的功能,包括简单的音频回放、音频和视频播放、录音、流媒体和音频编辑等,还可以创建诸如视频编辑器、流媒体广播和媒体播放器等等的很多多媒体应用等。In this embodiment, the player is preferably a gstreamer player, and the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video. For playback, recording, streaming and audio editing, you can also create many multimedia applications such as video editors, streaming media and media players.
本实施例中,当前数据量缓存率Rs或平均码率下缓存时间比率Rt两者中的一个先达到100%,则客户端缓存完成,客户端发送播放信息给播放器,通知播放器重新启动播放,播放器创建管道并开始启动播放,并从客户端请求新媒体数据。In this embodiment, one of the current data volume buffer rate Rs or the average code rate buffer time ratio Rt reaches 100% first, then the client cache is completed, and the client sends the play information to the player to notify the player to restart. Play, the player creates a pipe and starts playback, and requests new media data from the client.
本实施例中,对不同源的媒体数据进行划分。播放器以特殊的请求格式向客户端请求媒体数据,请求格式说明部分包含需要请求哪一路媒体数据及请求的媒体数据的个数。无论是客户端还是播放器,对不同源的媒体数据都是独立请求和独立保存的,这样就可以做到对不同源的媒体数据有分别的进行处理。播放器端将不同源的媒体数据以特定的格式保存在不同的队列中,按媒体数据请求的先后顺序,从这些数据队列中有序获取媒体数据进行播放,保持数据的同步并且不造成某一路媒体数据的堆积。In this embodiment, media data of different sources is divided. The player requests media data from the client in a special request format, and the request format specification section contains the media data that needs to be requested and the number of media data requested. Regardless of whether it is a client or a player, media data of different sources are independently requested and independently stored, so that media data of different sources can be processed separately. The player side saves the media data of different sources in different queues in a specific format, and sequentially obtains media data from the data queues in order according to the order of the media data requests, keeps the data synchronized and does not cause a certain way. The accumulation of media data.
与现有技术相比,本实施例当客户端检测到需要进行码率切换时,确认是由高码率切换为低码率还是由低码率切换为高码率,然后根据当前的码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt,即以缓存量或缓存时间来对客户端缓存的新媒体数据的量是否达到预设值进行判断,只要其中一个达到预设值,则认为客户端缓存完成,播放器可以重新启动播放,本实施例根据客户端的缓存量或缓存时间为缓存策略的依据,无论是带宽不足或终端的播放性能不足,均能够快速重新启动播放,使播放的效果更佳。Compared with the prior art, when the client detects that the code rate switching needs to be performed, the acknowledgment is whether the high code rate is switched to the low code rate or the low code rate is switched to the high code rate, and then according to the current code rate. Calculating the current data volume buffer rate Rs and the average bit rate buffer time ratio Rt, that is, whether the amount of new media data buffered by the client reaches a preset value by using the buffer amount or the buffer time, as long as one of them reaches the preset value If the client cache is completed, the player can restart the playback. In this embodiment, according to the cache amount or the cache time of the client, the cache policy is used. Whether the bandwidth is insufficient or the playback performance of the terminal is insufficient, the playback can be restarted quickly. Make the playback better.
在一优选的实施例中,如图2所示,在上述图1的实施例的基础上,上述步骤S102包括:In a preferred embodiment, as shown in FIG. 2, based on the foregoing embodiment of FIG. 1, the foregoing step S102 includes:
步骤S1021,获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;Step S1021, acquiring the current code rate, the set cache data amount maximum value Ms, and the set cache maximum time Mt;
步骤S1022,根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:。Step S1022: Calculate a current data volume buffer rate Rs according to the code rate and the set cache data amount maximum value Ms: and calculate an average code rate buffer time ratio Rt according to the code rate and the set cache maximum time Mt: .
本实施例中,当前数据缓存量率Rs:;S为当前缓存的数据量,Ms为设定的缓存数据量最大值,其中,当前缓存的数据量S为当前的码率A与缓存时间x的乘积:S=A*x。In this embodiment, the current data buffer rate Rs:;S is the current buffered data amount, and Ms is the set cache data amount maximum, wherein the currently buffered data amount S is the current code rate A and the buffer time x. Product of: S=A*x.
本实施例中,设定的缓存最大时间Mt:;T为缓存数据平均码率时间,Mt为设定的缓存最大时间。In this embodiment, the set cache maximum time Mt:; T is the cache data average code rate time, and Mt is the set cache maximum time.
优选地,缓存数据平均码率时间T是当前缓存的数据量S和平均码率A的比值:T=S/A。Preferably, the buffered data average code rate time T is the ratio of the currently buffered data amount S to the average code rate A: T=S/A.
其中,平均码率A是单位时间的码率与旧平均码率v的均值,其中单位时间的码率是指设定的单位时间内接收媒体数据与接收时间的比值:。The average code rate A is the average of the code rate per unit time and the old average code rate v, wherein the code rate per unit time refers to the ratio of the received media data to the reception time in the set unit time:
旧平均码率v是指之前的一段时间计算的平均码率值,这一段时间定为N个,当缓存时间超过N个时的平均码率A公式为:The old average code rate v refers to the average code rate value calculated in the previous period of time. This period is set to N. When the buffer time exceeds N, the average code rate A formula is:
.
在一优选的实施例中,如图3所示,在上述图1的实施例的基础上,上述步骤S103包括:In a preferred embodiment, as shown in FIG. 3, based on the foregoing embodiment of FIG. 1, the foregoing step S103 includes:
步骤S1031,比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;Step S1031, comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
步骤S1032,当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;Step S1032, when the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one reaching 1;
步骤S1033,判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。Step S1033: Determine whether the time of the new media data buffered by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
本实施例中,预设一缓存时间x,然后计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt,当当前数据量缓存率Rs及平均码率下缓存时间比率Rt这两个比值中的一个先达到100%时,则认为客户端缓存的新媒体数据达到重新启动播放的条件。In this embodiment, a buffer time x is preset, and then the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are calculated, when the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are two ratios. When one of the first reaches 100%, it is considered that the new media data cached by the client reaches the condition for restarting playback.
例如,假设是一个音视频混合播放的场景,客户端设定的缓存数据量最大值Ms为2M,缓存时间为x(以客户端清空缓存并向服务器发送获取新媒体数据的请求为缓存时间的起点),当前的码率为1.5M(为计算方便,假设码率没有波动),则码率发生切换后的缓存时间x内当前数据量缓存率Rs及平均码率下缓存时间比率Rt分别为:For example, suppose that it is a scene of mixed audio and video playback. The maximum amount of cached data set by the client is 2M, and the cache time is x (the client clears the cache and sends a request for obtaining new media data to the server for the cache time). Starting point), the current code rate is 1.5M (for the convenience of calculation, assuming that the code rate does not fluctuate), the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are respectively in the buffer time x after the code rate is switched. :
;
;
此时如果当前的码率降为0.2M(假设码率没有波动),此时两者为:At this time, if the current code rate is reduced to 0.2M (assuming the code rate does not fluctuate), then both are:
以上数据可以看出,码率变化前当前数据量缓存率Rs会率先缓存达到100%,则以当前数据量缓存率Rs达到100%时的时间为客户端缓存的新媒体数据的时间,当达到该时间时,重新启动播放,可以在码率切换后快速启动播放;The above data can be seen that the current data volume buffer rate Rs will be the first to be cached up to 100% before the rate change, and the time when the current data volume buffer rate Rs reaches 100% is the time of the new media data cached by the client. At this time, the playback is restarted, and the playback can be started quickly after the bit rate is switched;
码率下降后平均码率下缓存时间比率Rt则首先达到100%,则以平均码率下缓存时间比率Rt达到100%时的时间为客户端缓存的新媒体数据的时间,当达到该时间时,重新启动播放,可以在码率切换后快速启动播放。After the bit rate is decreased, the buffer time ratio Rt at the average bit rate first reaches 100%, and the time when the buffer time ratio Rt reaches 100% at the average code rate is the time of the new media data buffered by the client, when the time is reached. , restart playback, you can quickly start playback after the bit rate is switched.
在一优选的实施例中,如图4所示,在上述图1的实施例的基础上,在上述步骤S101之前包括:In a preferred embodiment, as shown in FIG. 4, on the basis of the foregoing embodiment of FIG. 1, before the step S101, the method includes:
步骤S100,在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。Step S100: During the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
本实施例中,对于终端的播放性能足够,由客户端检测带宽是否发生变化,即带宽由大变小还是由小变大,对于带宽发生变化而进行码率切换的情况,由客户端发起码率切换。在码率切换时,客户端清空缓存并向服务器请求新媒体数据,同时向播放器发送暂停播放指令。In this embodiment, the playback performance of the terminal is sufficient, and the client detects whether the bandwidth changes, that is, whether the bandwidth is changed from large to small or from small to large. When the bandwidth is changed and the rate is switched, the client initiates the code. Rate switching. At the rate switching, the client clears the cache and requests new media data from the server, while sending a pause play command to the player.
当网络的带宽充足,但是终端的播放性能不足时,例如手机客户端,可能cpu的性能足够但是解码器的性能不足,导致的高码率的视频无法播放时,对于这种情况,由播放器发送码率切换指令,通知客户端播放器的播放性能不足,客户端收到码率切换指令后,判断码率切换是因为码率过高但是终端的播放性能不足而导致播放失败,然后还是由客户端发起整个码率切换。When the bandwidth of the network is sufficient, but the playback performance of the terminal is insufficient, such as a mobile phone client, the performance of the CPU may be sufficient but the performance of the decoder is insufficient, resulting in a high-rate video cannot be played. For this case, by the player Sending a code rate switching instruction to notify the client that the playback performance of the player is insufficient. After receiving the code rate switching instruction, the client determines that the code rate switching is because the code rate is too high but the playback performance of the terminal is insufficient, causing the playback to fail, and then The client initiates the entire bit rate switch.
本实施例中,考虑到发生码率切换的情况较多,终端不可能为每一种情况均定义一种缓存策略,这样将变得复杂。本实施例以当前数据量缓存率Rs及平均码率下缓存时间比率Rt为客户端缓存策略的依据,能够简单并合理地解决该问题。In this embodiment, considering that there are many cases where rate switching occurs, it is impossible for the terminal to define a caching policy for each case, which will become complicated. In this embodiment, the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are the basis of the client cache policy, and the problem can be solved simply and reasonably.
本发明还提供一种终端,如图5所示,在一实施例中,终端包括:The present invention further provides a terminal. As shown in FIG. 5, in an embodiment, the terminal includes:
清空模块101,用于当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;The clearing module 101 is configured to: when the client of the terminal detects that the code rate switching is required, clear the media data buffered by the client and send a request for acquiring new media data to the server;
本实施例中,终端可以是电视、电脑、平板电脑或者手机等等。In this embodiment, the terminal may be a television, a computer, a tablet computer, a mobile phone, or the like.
本实施例中,终端的客户端从服务器上获取媒体数据并进行缓存,然后将缓存的媒体数据发送给播放器进行播放。In this embodiment, the client of the terminal acquires media data from the server and caches the data, and then sends the cached media data to the player for playing.
本实施例中,客户端响应用户的操作,创建播放实例并向服务器请求媒体数据,服务器端响应客户端的请求,将媒体数据以基本码流(Elementary Streams,ES)的形式发送给客户端,基本码流可能包含视频、音频、字幕等的其中一个或多个。In this embodiment, the client responds to the user's operation, creates a play instance and requests media data from the server, and the server responds to the client request to media data in the elementary stream (Elementary Streams, ES) is sent to the client, and the elementary stream may contain one or more of video, audio, subtitles, and the like.
本实施例中,当客户端检测到需要进行码率切换时,例如,当前的带宽不足或者终端的播放性能不足时,需要进行码率切换。客户端将自身当前缓存的媒体数据清空,以重新接收服务器发送的媒体数据。In this embodiment, when the client detects that code rate switching is required, for example, when the current bandwidth is insufficient or the playback performance of the terminal is insufficient, rate switching is required. The client empties the media data currently cached by itself to re-receive the media data sent by the server.
本实施例中,客户端在检测是否需要进行码率切换时,能够检测到是由高码率切换为低码率还是由低码率切换为高码率。然后向服务器发送获取对应的媒体数据的请求。In this embodiment, when detecting whether the rate switching needs to be performed, the client can detect whether to switch from a high code rate to a low code rate or a low code rate to a high code rate. A request to obtain corresponding media data is then sent to the server.
计算模块102,用于获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;The calculating module 102 is configured to obtain a current code rate, and calculate a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
本实施例中,当前数据缓存量率Rs是指当前缓存的数据量S和设定的缓存数据量最大值Ms的比值:In this embodiment, the current data buffer rate Rs refers to the ratio of the currently buffered data amount S to the set cache data amount maximum value Ms:
,
如果当前的网速越快,累积的当前缓存的数据量S越大,当前数据缓存量率Rs就越大,而当前缓存的数据量S与当前的码率成正比关系,因此,可以根据当前的码率计算得到当前缓存的数据量S。If the current network speed is faster, the larger the current cached data amount S is, the larger the current data buffer rate Rs is, and the currently buffered data amount S is proportional to the current code rate, and therefore, according to the current The code rate is calculated to obtain the current buffered data amount S.
本实施例中,平均码率下缓存时间比率Rt是指缓存数据平均码率时间T和设定的缓存最大时间Mt的比值:In this embodiment, the average bit rate buffer time ratio Rt refers to the ratio of the buffer data average code rate time T to the set cache maximum time Mt:
,
如果当前的网速越快,累积一定的缓存数据量越快,而缓存数据平均码率时间T与当前的码率成反比关系,即缓存数据平均码率时间T越小,从而平均码率下缓存时间比率Rt越小。If the current network speed is faster, the accumulated buffer data amount is faster, and the buffer data average code rate time T is inversely proportional to the current code rate, that is, the buffer data average code rate time T is smaller, and thus the average bit rate is The smaller the cache time ratio Rt.
本实施例的缓存策略以当前数据量缓存率Rs及平均码率下缓存时间比率Rt这两个比值为依据。The buffering strategy of this embodiment is based on the ratio of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt.
判断模块103,用于接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;The judging module 103 is configured to receive and cache new media data sent by the server, and determine, according to the current data volume caching rate Rs and the average bit rate buffering time ratio Rt, whether the new media data cached by the client reaches a preset. value;
本实施例中,客户端接收服务器端的发送的新媒体数据并进行缓存,客户端以特定的样本形式缓存新媒体数据,每个样本都是独立的,包括新媒体数据及新媒体数据的说明如dts、duration等信息。In this embodiment, the client receives the new media data sent by the server and caches it, and the client caches the new media data in a specific sample format, and each sample is independent, including descriptions of the new media data and the new media data. Dts, duration and other information.
本实施例中,在当前的码率下,客户端接收服务器发送的新媒体数据,然后根据上述计算得到的当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断客户端缓存的新媒体数据是否达到预设值。In this embodiment, at the current code rate, the client receives the new media data sent by the server, and then determines the new media cached by the client according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt calculated above. Whether the data reaches the preset value.
本实施例中,如果当前数据量缓存率Rs达到100%或者平均码率下缓存时间比率Rt达到100%均认为客户端缓存的新媒体数据已经达到预设值,可以重新启动播放。In this embodiment, if the current data volume buffer rate Rs reaches 100% or the average code rate buffer time ratio Rt reaches 100%, it is considered that the new media data buffered by the client has reached the preset value, and the playback can be restarted.
发送模块104,用于若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。The sending module 104 is configured to send the buffered new media data to the player for playing if the current data volume buffer rate Rs reaches 1 or the average time rate buffer time ratio Rt reaches 1.
本实施例中,播放器优选地为gstreamer播放器,gstreamer是一个用于创建流媒体应用程序的多媒体框架库,其可以提供构建各种媒体功能组件的功能,包括简单的音频回放、音频和视频播放、录音、流媒体和音频编辑等,还可以创建诸如视频编辑器、流媒体广播和媒体播放器等等的很多多媒体应用等。In this embodiment, the player is preferably a gstreamer player, and the gstreamer is a multimedia framework library for creating streaming media applications, which can provide functions for constructing various media function components, including simple audio playback, audio and video. For playback, recording, streaming and audio editing, you can also create many multimedia applications such as video editors, streaming media and media players.
本实施例中,当前数据量缓存率Rs或平均码率下缓存时间比率Rt两者中的一个先达到100%,则客户端缓存完成,客户端发送播放信息给播放器,通知播放器重新启动播放,播放器创建管道并开始启动播放,并从客户端请求新媒体数据。In this embodiment, one of the current data volume buffer rate Rs or the average code rate buffer time ratio Rt reaches 100% first, then the client cache is completed, and the client sends the play information to the player to notify the player to restart. Play, the player creates a pipe and starts playback, and requests new media data from the client.
本实施例中,对不同源的媒体数据进行划分。播放器以特殊的请求格式向客户端请求媒体数据,请求格式说明部分包含需要请求哪一路媒体数据及请求的媒体数据的个数。无论是客户端还是播放器,对不同源的媒体数据都是独立请求和独立保存的,这样就可以做到对不同源的媒体数据有分别的进行处理。播放器端将不同源的媒体数据以特定的格式保存在不同的队列中,按媒体数据请求的先后顺序,从这些数据队列中有序获取媒体数据进行播放,保持数据的同步并且不造成某一路媒体数据的堆积。In this embodiment, media data of different sources is divided. The player requests media data from the client in a special request format, and the request format specification section contains the media data that needs to be requested and the number of media data requested. Regardless of whether it is a client or a player, media data of different sources are independently requested and independently stored, so that media data of different sources can be processed separately. The player side saves the media data of different sources in different queues in a specific format, and sequentially obtains media data from the data queues in order according to the order of the media data requests, keeps the data synchronized and does not cause a certain way. The accumulation of media data.
在一优选的实施例中,如图6所示,在上述图5的实施例的基础上,所述计算模块102包括:In a preferred embodiment, as shown in FIG. 6, on the basis of the foregoing embodiment of FIG. 5, the computing module 102 includes:
第一获取单元1021,用于获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;The first obtaining unit 1021 is configured to acquire a current code rate, a set cache data amount maximum value Ms, and a set cache maximum time Mt;
计算单元1022,用于根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:。The calculating unit 1022 is configured to calculate a current data volume buffer rate Rs according to the code rate and the set buffer data maximum value Ms, and calculate an average bit rate buffer time according to the code rate and the set cache maximum time Mt. Ratio Rt:.
本实施例中,当前数据缓存量率Rs:;S为当前缓存的数据量,Ms为设定的缓存数据量最大值,其中,当前缓存的数据量S为当前的码率A与缓存时间x的乘积:S=A*x。In this embodiment, the current data buffer rate Rs:;S is the current buffered data amount, and Ms is the set cache data amount maximum, wherein the currently buffered data amount S is the current code rate A and the buffer time x. Product of: S=A*x.
本实施例中,设定的缓存最大时间Mt:;T为缓存数据平均码率时间,Mt为设定的缓存最大时间。In this embodiment, the set cache maximum time Mt:; T is the cache data average code rate time, and Mt is the set cache maximum time.
优选地,缓存数据平均码率时间T是当前缓存的数据量S和平均码率A的比值:T=S/A。Preferably, the buffered data average code rate time T is the ratio of the currently buffered data amount S to the average code rate A: T=S/A.
其中,平均码率A是单位时间的码率与旧平均码率v的均值,其中单位时间的码率是指设定的单位时间内接收媒体数据与接收时间的比值:。The average code rate A is the average of the code rate per unit time and the old average code rate v, wherein the code rate per unit time refers to the ratio of the received media data to the reception time in the set unit time:
旧平均码率v是指之前的一段时间计算的平均码率值,这一段时间定为N个,当缓存时间超过N个时的平均码率A公式为:The old average code rate v refers to the average code rate value calculated in the previous period of time. This period is set to N. When the buffer time exceeds N, the average code rate A formula is:
.
在一优选的实施例中,如图7所示,在上述图5的实施例的基础上,所述判断模块103包括:In a preferred embodiment, as shown in FIG. 7, on the basis of the foregoing embodiment of FIG. 5, the determining module 103 includes:
比较单元1031,用于比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;The comparing unit 1031 is configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt. ;
第二获取单元1032,用于当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;The second obtaining unit 1032 is configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
判断单元1033,用于判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。The determining unit 1033 is configured to determine whether the time of the new media data buffered by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
本实施例中,预设一缓存时间x,然后计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt,当当前数据量缓存率Rs及平均码率下缓存时间比率Rt这两个比值中的一个先达到100%时,则认为客户端缓存的新媒体数据达到重新启动播放的条件。In this embodiment, a buffer time x is preset, and then the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are calculated, when the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are two ratios. When one of the first reaches 100%, it is considered that the new media data cached by the client reaches the condition for restarting playback.
例如,假设是一个音视频混合播放的场景,客户端设定的缓存数据量最大值Ms为2M,缓存时间为x(以客户端清空缓存并向服务器发送获取新媒体数据的请求为缓存时间的起点),当前的码率为1.5M(为计算方便,假设码率没有波动),则码率发生切换后的缓存时间x内当前数据量缓存率Rs及平均码率下缓存时间比率Rt分别为:For example, suppose that it is a scene of mixed audio and video playback. The maximum amount of cached data set by the client is 2M, and the cache time is x (the client clears the cache and sends a request for obtaining new media data to the server for the cache time). Starting point), the current code rate is 1.5M (for the convenience of calculation, assuming that the code rate does not fluctuate), the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are respectively in the buffer time x after the code rate is switched. :
;
;
此时如果当前的码率降为0.2M(假设码率没有波动),此时两者为:At this time, if the current code rate is reduced to 0.2M (assuming the code rate does not fluctuate), then both are:
以上数据可以看出,码率变化前当前数据量缓存率Rs会率先缓存达到100%,则以当前数据量缓存率Rs达到100%时的时间为客户端缓存的新媒体数据的时间,当达到该时间时,重新启动播放,可以在码率切换后快速启动播放;The above data can be seen that the current data volume buffer rate Rs will be the first to be cached up to 100% before the rate change, and the time when the current data volume buffer rate Rs reaches 100% is the time of the new media data cached by the client. At this time, the playback is restarted, and the playback can be started quickly after the bit rate is switched;
码率下降后平均码率下缓存时间比率Rt则首先达到100%,则以平均码率下缓存时间比率Rt达到100%时的时间为客户端缓存的新媒体数据的时间,当达到该时间时,重新启动播放,可以在码率切换后快速启动播放。After the bit rate is decreased, the buffer time ratio Rt at the average bit rate first reaches 100%, and the time when the buffer time ratio Rt reaches 100% at the average code rate is the time of the new media data buffered by the client, when the time is reached. , restart playback, you can quickly start playback after the bit rate is switched.
在一优选的实施例中,如图8所示,在上述图5的实施例的基础上,所述终端还包括:In a preferred embodiment, as shown in FIG. 8, on the basis of the foregoing embodiment of FIG. 5, the terminal further includes:
检测模块100,用于在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。The detecting module 100 is configured to: during the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
本实施例中,对于终端的播放性能足够,由客户端检测带宽是否发生变化,即带宽由大变小还是由小变大,对于带宽发生变化而进行码率切换的情况,由客户端发起码率切换。在码率切换时,客户端清空缓存并向服务器请求新媒体数据,同时向播放器发送暂停播放指令。In this embodiment, the playback performance of the terminal is sufficient, and the client detects whether the bandwidth changes, that is, whether the bandwidth is changed from large to small or from small to large. When the bandwidth is changed and the rate is switched, the client initiates the code. Rate switching. At the rate switching, the client clears the cache and requests new media data from the server, while sending a pause play command to the player.
当网络的带宽充足,但是终端的播放性能不足时,例如手机客户端,可能cpu的性能足够但是解码器的性能不足,导致的高码率的视频无法播放时,对于这种情况,由播放器发送码率切换指令,通知客户端播放器的播放性能不足,客户端收到码率切换指令后,判断码率切换是因为码率过高但是终端的播放性能不足而导致播放失败,然后还是由客户端发起整个码率切换。When the bandwidth of the network is sufficient, but the playback performance of the terminal is insufficient, such as a mobile phone client, the performance of the CPU may be sufficient but the performance of the decoder is insufficient, resulting in a high-rate video cannot be played. For this case, by the player Sending a code rate switching instruction to notify the client that the playback performance of the player is insufficient. After receiving the code rate switching instruction, the client determines that the code rate switching is because the code rate is too high but the playback performance of the terminal is insufficient, causing the playback to fail, and then The client initiates the entire bit rate switch.
本实施例中,考虑到发生码率切换的情况较多,终端不可能为每一种情况均定义一种缓存策略,这样将变得复杂。本实施例以当前数据量缓存率Rs及平均码率下缓存时间比率Rt为客户端缓存策略的依据,能够简单并合理地解决该问题。In this embodiment, considering that there are many cases where rate switching occurs, it is impossible for the terminal to define a caching policy for each case, which will become complicated. In this embodiment, the current data volume buffer rate Rs and the average code rate buffer time ratio Rt are the basis of the client cache policy, and the problem can be solved simply and reasonably.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only the preferred embodiments of the present invention, and are not intended to limit the scope of the invention, and the equivalent structure or equivalent process transformations made by the description of the present invention and the drawings are directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of the present invention.

Claims (12)

  1. 一种媒体数据播放的方法,其特征在于,所述媒体数据播放的方法包括以下步骤: A method for playing media data, characterized in that the method for playing media data comprises the following steps:
    当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;When the client of the terminal detects that the code rate switching needs to be performed, the media data buffered by the client is cleared and a request for acquiring new media data is sent to the server;
    获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;Obtaining a current code rate, and calculating a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
    接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;Receiving and buffering new media data sent by the server, determining whether the new media data buffered by the client reaches a preset value according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
    若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。 If the current data volume buffer rate Rs reaches 1 or the buffer rate ratio Rt reaches 1 at the average code rate, the buffered new media data is sent to the player for playback.
  2. 如权利要求1所述的媒体数据播放的方法,其特征在于,所述获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt的步骤包括:The method for playing media data according to claim 1, wherein the step of obtaining a current code rate, and calculating a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate comprises:
    获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;Obtaining the current code rate, the set cache data amount maximum value Ms, and the set cache maximum time Mt;
    根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:,其中,所述S为当前缓存的数据量,Ms为设定的缓存数据量最大值,T为缓存数据平均码率时间,Mt为设定的缓存最大时间。Calculating a current data volume buffer ratio Rs according to the code rate and the set buffer data maximum value Ms: calculating an average code rate buffer time ratio Rt according to the code rate and the set cache maximum time Mt, wherein The S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
  3. 如权利要求1所述的媒体数据播放的方法,其特征在于,所述接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值的步骤包括:The method for playing media data according to claim 1, wherein the receiving and buffering the new media data sent by the server is determined according to the current data volume buffer rate Rs and the average code rate buffer time ratio Rt. The step of whether the new media data buffered by the client reaches a preset value includes:
    比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;Comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
    当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;When the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one;
    判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。Determining whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  4. 如权利要求2所述的媒体数据播放的方法,其特征在于,所述接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值的步骤包括:The method for playing media data according to claim 2, wherein the receiving and buffering the new media data sent by the server is determined according to the current data volume buffer rate Rs and the average bit rate buffer time ratio Rt The step of whether the new media data buffered by the client reaches a preset value includes:
    比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;Comparing the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtaining the larger of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
    当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;When the value of the larger one reaches 1, obtaining a time value corresponding to the value of the larger one;
    判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。Determining whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  5. 如权利要求1所述的媒体数据播放的方法,其特征在于,所述当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求的步骤之前还包括:The method for playing media data according to claim 1, wherein when the client of the terminal detects that code rate switching is required, the media data buffered by the client is cleared and the new media data is sent to the server. The steps of the request also include:
    在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。During the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the rate switching instruction sent by the player is received.
  6. 如权利要求1所述的媒体数据播放的方法,其特征在于,所述播放器为gstreamer播放器。The method of playing media data according to claim 1, wherein the player is a gstreamer player.
  7. 一种终端,其特征在于,所述终端包括:A terminal, wherein the terminal comprises:
    清空模块,用于当终端的客户端检测到需要进行码率切换时,清空所述客户端缓存的媒体数据并向服务器发送获取新媒体数据的请求;The clearing module is configured to: when the client of the terminal detects that the code rate switching is required, clear the media data buffered by the client and send a request for acquiring new media data to the server;
    计算模块,用于获取当前的码率,根据所述码率计算当前数据量缓存率Rs及平均码率下缓存时间比率Rt;a calculation module, configured to obtain a current code rate, and calculate a current data volume buffer rate Rs and an average code rate buffer time ratio Rt according to the code rate;
    判断模块,用于接收并缓存所述服务器发送的新媒体数据,根据所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt判断所述客户端缓存的新媒体数据是否达到预设值;a judging module, configured to receive and cache new media data sent by the server, and determine, according to the current data volume caching rate Rs and the average bit rate buffering time ratio Rt, whether the new media data buffered by the client reaches a preset value. ;
    发送模块,用于若当前数据量缓存率Rs达到1或者平均码率下缓存时间比率Rt达到1,则将所缓存的新媒体数据发送至所述播放器进行播放。The sending module is configured to send the buffered new media data to the player for playing if the current data volume buffer rate Rs reaches 1 or the average time rate buffer time ratio Rt reaches 1.
  8. 如权利要求6所述的终端,其特征在于,所述计算模块包括:The terminal according to claim 6, wherein the calculation module comprises:
    第一获取单元,用于获取当前的码率、设定的缓存数据量最大值Ms及设定的缓存最大时间Mt;a first obtaining unit, configured to acquire a current code rate, a set cache data amount maximum value Ms, and a set cache maximum time Mt;
    计算单元,用于根据所述码率及设定的缓存数据量最大值Ms计算当前数据量缓存率Rs:,根据所述码率及设定的缓存最大时间Mt计算平均码率下缓存时间比率Rt:,其中,所述S为当前缓存的数据量,Ms为设定的缓存数据量最大值,T为缓存数据平均码率时间,Mt为设定的缓存最大时间。a calculating unit, configured to calculate a current data volume buffer rate Rs according to the code rate and the set buffer data maximum value Ms: and calculate an average bit rate buffer time ratio according to the code rate and the set cache maximum time Mt Rt:, wherein S is the current buffered data amount, Ms is the set cache data amount maximum value, T is the cache data average code rate time, and Mt is the set cache maximum time.
  9. 如权利要求6所述的终端,其特征在于,所述判断模块包括:The terminal according to claim 6, wherein the determining module comprises:
    比较单元,用于比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;a comparing unit, configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
    第二获取单元,用于当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;a second acquiring unit, configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
    判断单元,用于判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。The determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  10. 如权利要求7所述的终端,其特征在于,所述判断模块包括:The terminal according to claim 7, wherein the determining module comprises:
    比较单元,用于比较所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt的大小,获取所述当前数据量缓存率Rs及平均码率下缓存时间比率Rt中的较大者;a comparing unit, configured to compare the current data volume buffer rate Rs and the average code rate buffer time ratio Rt, and obtain a larger one of the current data volume buffer rate Rs and the average code rate buffer time ratio Rt;
    第二获取单元,用于当所述较大者的值到达1时,获取所述较大者的值到达1对应的时间值;a second acquiring unit, configured to: when the value of the larger one reaches 1, acquire a time value corresponding to the value of the larger one reaching 1;
    判断单元,用于判断所述客户端缓存的新媒体数据的时间是否达到所述时间值,以判断所述客户端缓存的新媒体数据是否达到预设值。The determining unit is configured to determine whether the time of the new media data cached by the client reaches the time value, to determine whether the new media data buffered by the client reaches a preset value.
  11. 如权利要求7所述的终端,其特征在于,所述终端还包括:The terminal according to claim 7, wherein the terminal further comprises:
    检测模块,用于在所述播放器播放媒体数据的过程中,客户端检测带宽是否发生变化或者检测是否接收到所述播放器发送的码率切换指令。The detecting module is configured to: during the playing of the media data by the player, the client detects whether the bandwidth changes or detects whether the code rate switching instruction sent by the player is received.
  12. 如权利要求7所述的终端,其特征在于,所述播放器为gstreamer播放器。The terminal of claim 7 wherein said player is a gstreamer player.
PCT/CN2014/095063 2014-12-23 2014-12-26 Media data playing method and terminal WO2016101240A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410812144.7A CN105791987B (en) 2014-12-23 2014-12-23 media data playing method and terminal
CN201410812144.7 2014-12-23

Publications (1)

Publication Number Publication Date
WO2016101240A1 true WO2016101240A1 (en) 2016-06-30

Family

ID=56148969

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/095063 WO2016101240A1 (en) 2014-12-23 2014-12-26 Media data playing method and terminal

Country Status (2)

Country Link
CN (1) CN105791987B (en)
WO (1) WO2016101240A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110460875A (en) * 2019-08-05 2019-11-15 北京达佳互联信息技术有限公司 A kind of switching method of video code rate, device, electronic equipment and storage medium
CN114640886A (en) * 2022-02-28 2022-06-17 深圳市宏电技术股份有限公司 Bandwidth-adaptive audio and video transmission method and device, computer equipment and medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111479171B (en) * 2019-01-23 2022-05-20 上海哔哩哔哩科技有限公司 Pseudo seamless switching method, device and medium among different video sources played by Web
CN109547846B (en) * 2019-01-31 2021-08-24 海信视像科技股份有限公司 HLS code stream switching method, device and equipment
CN112702620A (en) * 2020-12-29 2021-04-23 四川长虹电器股份有限公司 Method for realizing multi-screen synchronous playing of player based on gstreamer

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242359A (en) * 2008-02-27 2008-08-13 华为技术有限公司 Dynamic code rate allocation method and packet domain stream media server
US20120179833A1 (en) * 2010-06-02 2012-07-12 Onmobile Global Limited Method and apparatus for adapting media
CN103442293A (en) * 2013-08-30 2013-12-11 武汉眸博科技有限公司 Method and system for quickly starting playing of network multimedia files

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8566879B2 (en) * 2004-09-28 2013-10-22 Sony Corporation Method and apparatus for navigating video content
CN102110459B (en) * 2009-12-24 2013-01-16 Tcl集团股份有限公司 Playing terminal and multimedia file playing method and device thereof
CN104038846B (en) * 2013-03-05 2018-03-09 华为技术有限公司 Buffer status method of estimation and equipment
CN103260053B (en) * 2013-04-15 2016-12-28 威盛电子股份有限公司 Dynamically adjust the system of multimedia data code rate, media playing apparatus and method
CN103841456A (en) * 2013-12-10 2014-06-04 珠海全志科技股份有限公司 Webcast data buffering method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242359A (en) * 2008-02-27 2008-08-13 华为技术有限公司 Dynamic code rate allocation method and packet domain stream media server
US20120179833A1 (en) * 2010-06-02 2012-07-12 Onmobile Global Limited Method and apparatus for adapting media
CN103442293A (en) * 2013-08-30 2013-12-11 武汉眸博科技有限公司 Method and system for quickly starting playing of network multimedia files

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110460875A (en) * 2019-08-05 2019-11-15 北京达佳互联信息技术有限公司 A kind of switching method of video code rate, device, electronic equipment and storage medium
CN114640886A (en) * 2022-02-28 2022-06-17 深圳市宏电技术股份有限公司 Bandwidth-adaptive audio and video transmission method and device, computer equipment and medium
CN114640886B (en) * 2022-02-28 2023-09-15 深圳市宏电技术股份有限公司 Self-adaptive bandwidth audio/video transmission method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN105791987A (en) 2016-07-20
CN105791987B (en) 2018-11-02

Similar Documents

Publication Publication Date Title
WO2016101240A1 (en) Media data playing method and terminal
WO2019114269A1 (en) Method for resuming playing program, television device, and computer readable storage medium
WO2017107378A1 (en) Accelerated video data downloading method and device based on hls stream media
WO2017113614A1 (en) Method and device for intercut playing of advertisement during video playing
WO2018166224A1 (en) Target tracking display method and apparatus for panoramic video, and storage medium
WO2017107388A1 (en) Hdmi version switching method and display device
WO2018032680A1 (en) Method and system for playing audio and video
WO2016052973A1 (en) Streaming service data receiving device and method in mobile communication system for supporting plurality of radio access interfaces
WO2014187158A1 (en) Method, server, and terminal for controlling cloud sharing of terminal data
WO2018032679A1 (en) Setting method and device for timed startup and shutoff of television
WO2018223607A1 (en) Television terminal, method for converting hdr image into sdr image, and computer readable storage medium
WO2017045441A1 (en) Smart television-based audio playback method and apparatus
WO2017201899A1 (en) Method and apparatus for connecting to bluetooth device
WO2017084302A1 (en) Method for playing boot video of a display terminal and display terminal
WO2017020649A1 (en) Audio/video playback control method and device thereof
WO2017088427A1 (en) Audio output control method and device
WO2018233221A1 (en) Multi-window sound output method, television, and computer-readable storage medium
WO2018036057A1 (en) Method and device for background adaptive upgrading of software
WO2016101702A1 (en) Program recording method and device
WO2017024876A1 (en) Television program broadcast method and device
WO2017032122A1 (en) Method and apparatus for detecting digital television set
WO2018090461A1 (en) Method and system for synchronizing data between multichannel wireless speakers
WO2018000856A1 (en) Method implementing sdn overlay network message forwarding, terminal, apparatus, and computer readable storage medium
WO2016101305A1 (en) Video file processing method and display device
WO2017185480A1 (en) Multi-screen interaction connection method, device and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14908808

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 06/11/2017)

122 Ep: pct application non-entry in european phase

Ref document number: 14908808

Country of ref document: EP

Kind code of ref document: A1