WO2020238065A1 - Media file downloading method and apparatus, and terminal and medium - Google Patents

Media file downloading method and apparatus, and terminal and medium Download PDF

Info

Publication number
WO2020238065A1
WO2020238065A1 PCT/CN2019/118543 CN2019118543W WO2020238065A1 WO 2020238065 A1 WO2020238065 A1 WO 2020238065A1 CN 2019118543 W CN2019118543 W CN 2019118543W WO 2020238065 A1 WO2020238065 A1 WO 2020238065A1
Authority
WO
WIPO (PCT)
Prior art keywords
network
speed
download
data packets
instant
Prior art date
Application number
PCT/CN2019/118543
Other languages
French (fr)
Chinese (zh)
Inventor
马潜
许可
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020238065A1 publication Critical patent/WO2020238065A1/en

Links

Images

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/438Interfacing the downstream path of the transmission network originating from a server, e.g. retrieving MPEG packets from an IP network
    • 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
    • H04N21/44209Monitoring of downstream path of the transmission network originating from a server, e.g. bandwidth variations of a wireless network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/647Control signaling between network components and server or clients; Network processes for video distribution between server and clients, e.g. controlling the quality of the video stream, by dropping packets, protecting content from unauthorised alteration within the network, monitoring of network load, bridging between two different networks, e.g. between IP and wireless
    • H04N21/64723Monitoring of network processes or resources, e.g. monitoring of network load
    • H04N21/64738Monitoring network characteristics, e.g. bandwidth, congestion level
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/83Generation or processing of protective or descriptive data associated with content; Content structuring
    • H04N21/845Structuring of content, e.g. decomposing content into time segments
    • H04N21/8456Structuring of content, e.g. decomposing content into time segments by decomposing the content in the time domain, e.g. in time segments

Definitions

  • This application belongs to the field of computer technology, and in particular relates to a method, device, terminal and medium for downloading media files.
  • the audio file or video file is continuously and real-time transmitted from the server to the terminal.
  • the user does not have to wait for the entire media file to be downloaded before playing the media. It only takes a few seconds Or media playback can be performed with a startup delay of more than ten seconds, which effectively shortens the startup delay and saves the buffer capacity of the terminal.
  • the server generally provides multiple media files of different qualities to adapt to downloading and playing under different network conditions.
  • Each media file corresponds to a bit rate, and each media file contains multiple fragments.
  • One fragment is divided into several data packets. After the terminal downloads the data packet corresponding to each fragment, the fragment is the basic playback unit. Audio and video playback.
  • the terminal When the terminal downloads fragments, it generally calculates the network speed of the network, and selects a media file whose bit rate corresponds to the network speed of the network to download.
  • the terminal based on the current streaming media transmission protocol, when the network speed fluctuates greatly, the terminal generally cannot switch to the download of media files corresponding to the bit rate and the changed network speed in time, causing the terminal's audio and video playback to be prone to freezes Or it takes a long time to enter the best playback state.
  • the embodiments of the present application provide a method, device, terminal, and medium for downloading media files, which can solve the problem that when the network speed fluctuates greatly, the terminal cannot switch to the code rate corresponding to the changed network speed in time.
  • the downloading of media files causes technical problems in which audio and video playback may freeze or enter the optimal playback state for a long time.
  • the first aspect of the embodiments of the present application provides a method for downloading media files, including:
  • the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  • the acquisition unit is used to acquire the instantaneous speed and average speed of the network
  • a judging unit configured to judge whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed
  • the downloading unit is configured to select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading if the network speed of the network rises or drops steeply.
  • a third aspect of the embodiments of the present application provides a terminal, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the computer-readable instructions When implementing the following steps:
  • the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  • the fourth aspect of the embodiments of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions implement the following steps when executed by at least one processor:
  • the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  • the terminal obtains the instantaneous speed and average speed of the network, and judges whether the network speed of the network has a steep rise or drop according to the instantaneous speed and the average speed, instead of judging the network speed only according to the average speed.
  • the media with the bit rate corresponding to the instant speed can be selected in time according to the pre-stored media configuration file
  • the file is downloaded, without downloading at least one fragmented data packet after the network speed of the network has a steep rise or fall, in order to calculate the changed network speed, which prevents the terminal from being unable to switch to the code rate and changing in time
  • the download of media files corresponding to the speed of the network causes the audio and video playback to freeze or enter the optimal playback state for a long time.
  • FIG. 1 is a schematic diagram of the implementation process of a method for downloading media files provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a specific implementation flow of step 101 of a method for downloading media files provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of a specific implementation process of calculating the current instantaneous speed of the network provided by an embodiment of the present application;
  • FIG. 4 is a schematic diagram of a data package downloaded by a terminal according to an embodiment of the present application.
  • step 102 is a schematic diagram of a specific implementation flow of step 102 of a method for downloading media files provided by an embodiment of the present application
  • FIG. 6 is a schematic diagram of a first specific implementation flow of step 103 of a method for downloading media files provided by an embodiment of the present application;
  • FIG. 7 is a schematic diagram of a second specific implementation flow of step 103 of a method for downloading media files provided by an embodiment of the present application;
  • FIG. 8 is a schematic structural diagram of a media file downloading device provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
  • the HLS client When using streaming technology (HTTP Live Streaming, HLS) to download media files such as audio or video on the network, the HLS client first receives the configuration file in the m3u8 format issued by the audio and video server, and then calculates the network speed according to the The network speed selects the media file corresponding to the bandwidth (code rate) to download, so that the terminal can play audio and video smoothly.
  • HTTP Live Streaming HTTP Live Streaming
  • the current method of calculating the network speed of the network is calculated based on the number of bytes of the downloaded 50 data packets divided by the download time. Usually there are less than 50 data packets in a fragment. Therefore, when the network speed fluctuates greatly, it is necessary to download the data of at least one fragment after the network speed fluctuates greatly in order to calculate a more accurate network speed, which leads to the terminal It will not be able to switch to the download of media files corresponding to the bit rate and the changed network speed in time, resulting in the problem that the audio and video playback of the terminal is prone to freeze or enter the optimal playback state for a long time.
  • the corresponding network speed when downloading each data packet is 350KBps, that is, the network speed is stabilized at 350KBps.
  • the network speed corresponding to the first data packet is 140KBps
  • the network speed corresponding to the second data packet downloaded is 160KBps
  • the network speed corresponding to the third data packet downloaded is 150KBps
  • the average speed of these three data packets is 150KBps .
  • the terminal obtains the instantaneous speed and average speed of the network, and judges whether the network speed of the network rises or drops steeply according to the instant speed and the average speed, instead of just judging the network speed of the network based on the average speed Whether there is a steep rise or fall, therefore, when the network speed of the network rises or falls steeply, the media file with the bit rate corresponding to the instant speed can be selected for download in time according to the pre-stored media configuration file, and there is no need to download After the network speed of the network rises or drops steeply, download at least one fragmented data packet to calculate the changed network speed, which prevents the terminal from being unable to switch to the media file corresponding to the changed network speed in time. Download, causing the audio and video playback to freeze or enter the optimal playback state for a long time.
  • FIG. 1 shows a schematic diagram of the implementation process of a method for downloading media files provided by an embodiment of the present application, including step 101 to step 103.
  • Step 101 Obtain the instantaneous speed and average speed of the network.
  • the terminal When using the HLS client to play audio and video, the terminal first receives the configuration file in m3u8 format issued by the audio and video server, and stores it, and then uses streaming technology to download media files such as audio or video on the network , Obtain the network speed of the terminal, and select the media file of the corresponding bit rate to download according to the network speed, so that the terminal can play audio and video smoothly.
  • acquiring the network speed of the terminal includes acquiring the instantaneous speed and the average speed of the network.
  • the obtaining the instantaneous speed and average speed of the network may include: step 201 to step 202.
  • Step 201 Obtain the number of bytes and download time of each of the newly downloaded m data packets, and obtain the total number of bytes and total download time of the newly downloaded n data packets; n and m are greater than or equal to 1. An integer of and n is greater than m.
  • Step 202 Calculate m instantaneous speeds of the network using the number of bytes of each data packet in the m data packets and the download time; use the total number of bytes and the total download time of the n data packets The average speed of the network is calculated.
  • n and m can be selected according to actual application scenarios. This application does not impose any restriction on this. It is only necessary to ensure that n and m are integers greater than or equal to 1, and n is greater than m.
  • the value of n can be 50
  • the value of m can be 3, then the number of bytes and download time of each data packet in the 50 latest downloaded data packets is obtained, and the 3 newly downloaded data packets are obtained
  • the three instantaneous speeds of the network can be calculated using the number of bytes of each of the three data packets and the download time; The total number of bytes and the total download time are calculated to get the average speed of the network.
  • step 202 calculating the m instantaneous speeds of the network by using the number of bytes of each of the m data packets and the download time may specifically include: step 301 or step 302.
  • Step 301 Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two downloaded data packets among the m data packets. The total number of bytes of each data packet and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained.
  • data package 1, data package 2, and data package 3 are the three most recently downloaded data packages, and data package 1 is the last downloaded data package.
  • data package 1 is used. Divide the number of bytes by its download time to get the first instant speed of the network; use the total number of bytes of packet 1 and packet 2 divided by the download time of both to get the second instant speed of the network; use data The total number of bytes of packet 1, data packet 2, and data packet 3 is divided by the download time of the three to obtain the third instantaneous speed of the network, and the instantaneous speed of 3 networks is obtained in total.
  • Step 302 Use the number of bytes and download time of each data packet in the m data packets to respectively calculate an instant speed of the network, and obtain a total of m instant speeds of the network.
  • data package 1, data package 2, and data package 3 are the three newly downloaded data packages, and data package 1 is the last downloaded data package.
  • data package 1 is used Divide the number of bytes by its download time to get the first instant speed of the network; divide the number of bytes in packet 2 by its download time to get the second instant speed of the network; divide the number of bytes in packet 3 by it The download time gets the third instant speed of the network, and a total of 3 instant speeds of the network.
  • Step 102 Judging whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed.
  • the network speed of the network After obtaining the instantaneous speed and average speed of the network, it can be determined whether the network speed of the network has a steep rise or drop according to the instant speed and the average speed.
  • judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed may include: step 501 to step 502.
  • Step 501 If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply.
  • Step 502 If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
  • the average speed is calculated based on more data packets, it can reflect the overall speed level of the network, while the instantaneous speed of the network is the speed calculated based on fewer data packets, which can reflect the latest speed changes of the network Therefore, by comparing the instantaneous speed with the average speed, it can be reasonably judged whether the network speed of the network has a steep rise or a steep drop.
  • the values of the first multiple and the second multiple may be set according to actual application scenarios, which is not limited in this application.
  • the first multiple is 2-5
  • the double multiple is 0.7-0.1.
  • the m instant speeds of the network are compared with the average speed of the first multiple and/or the average speed of the second multiple, and the m instant speeds of the network are all greater than the first multiple.
  • the average speed is one multiple, it is determined that the network speed has a steep rise; when the m instantaneous speeds of the network are all less than the average speed of the second multiple, it is determined that the network speed of the network drops sharply, which can make the network It is more accurate to judge whether the network speed has a steep rise or fall.
  • the judging whether the network speed of the network has a steep rise or fall according to the real-time speed and the average speed may also include: if one of the m real-time speeds of the network is preset If the instantaneous speeds of the number are greater than the average speed of the first multiple, it is determined that the network speed has risen sharply; if the preset number of instantaneous speeds in the m instant speeds of the network are all less than the average speed of the second multiple , It is determined that the network speed has dropped sharply.
  • the preset number may be a number of m greater than the set multiple.
  • the set multiple may be 0.9, 0.85, or 0.8.
  • the network speed of the network has a steep rise or fall based on the instant speed and the average speed, it may not be necessary for the m instant speeds of the network to be all greater than the first multiple or less than the second multiple. It is determined that the network speed has a steep rise or fall, and only a part of the m real-time speeds of the network need to be greater than the first multiple or less than the second multiple of the average speed, It can be determined that the network speed has a steep rise or fall, so that there is a certain degree of redundancy in the judgment of whether the network speed has a steep rise or fall.
  • Step 103 If the network speed of the network rises or drops sharply, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
  • the pre-stored media configuration file stores audio and video stream information
  • the audio and video stream information may include: a correspondence between a bit rate and a media file, and content type information of the media file.
  • the corresponding relationship between the code rate stored in the pre-stored media configuration file and the media file, and the content type information of the media file are:
  • Audio and video stream 00 40Kbps; there is audio stream, no video stream, there is 1 JPEG picture;
  • Audio and video stream 01 120Kbps; there is audio stream, there is video stream (video stream resolution 176x144);
  • Audio and video stream 02 300Kbps; there is audio stream and video stream (video stream resolution 320x180);
  • Audio and video stream 03 500Kbps; there is audio stream, there is video stream (video stream resolution 400x224);
  • Audio and video stream 04 800Kbps; there is audio stream and video stream (video stream resolution 480x270);
  • Audio and video stream 05 1300Kbps; there is audio stream and video stream (video stream resolution 640x360);
  • Audio and video stream 06 2200Kbps; there is audio stream and video stream (video stream resolution 1024x576).
  • the media file with the bit rate corresponding to the instant speed can be selected for downloading according to the pre-stored media configuration file, which avoids the network speed
  • the terminal cannot switch to the download of media files corresponding to the bit rate and the changed network speed in time, resulting in a problem that audio and video playback is stuck or it takes a long time to enter the optimal playback state.
  • the selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download includes: selecting a code rate according to the pre-stored media configuration file and The media file corresponding to the average speed of the instant speed is downloaded.
  • the currently playing audio and video stream is 300KBps audio and video stream 02
  • the average network speed is 350KBps
  • the second multiple is 0.5
  • the calculated average speed of the three instant speeds is 150KBps, where the first instant speed is 150KBps; the second instantaneous speed is 160KBps; the third instantaneous speed is 140KBps; because the three instantaneous speeds of the network are all less than the second multiple of the average speed, it can be determined that the network speed has dropped sharply.
  • the media file audio and video stream 01 with a bit rate corresponding to the average speed of 150KBps of the instant speed can be selected according to the pre-stored media configuration file for download.
  • step 103 if the network speed of the network rises sharply, the bit rate and the bit rate are selected according to the pre-stored media configuration file.
  • the downloading of the media file corresponding to the instant speed may include: step 601 to step 603.
  • Step 601 If the network speed of the network rises sharply, it is determined whether the proportion of the downloaded segments of the media file that have been downloaded is greater than a first preset threshold.
  • Step 602 If it is less than the first preset threshold, directly select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download.
  • Step 603 If it is greater than or equal to the first preset threshold, after the download of the segment of the media file being downloaded is completed, select a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file. download.
  • fragments are the most basic playback unit. For a fragment, there are only two options: either download it completely and play it, or not download it or discard a part after downloading it. Therefore, when the network speed of the network rises sharply and it is necessary to switch to the download of a higher bit rate audio and video stream, it can be judged whether the proportion of the completed fragments of the media file being downloaded is greater than the preset threshold, if it is greater than , The download of the audio and video stream with a higher bit rate will be switched to after the download of the segment of the media file being downloaded is completed, so as to avoid switching to the download of the audio and video stream with a higher bit rate when the cache is insufficient. Fragments that have not been downloaded are discarded, causing a freeze.
  • the value of the first preset threshold may be determined according to actual application scenarios, which is not limited in this application.
  • the first preset threshold may be 95% or 90%.
  • step 103 when the network speed fluctuates frequently, in order to avoid switching audio and video streams too frequently, in step 103, if the network speed of the network When a steep rise or fall occurs, the selection of a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download may further include: step 701 to step 703.
  • step 701 if the network speed of the network rises or drops sharply, obtain the time interval between the steep rise and the steep drop in the network speed within a preset time period.
  • Step 702 If the number of times the time interval is less than the second preset threshold is less than the preset number of times, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
  • Step 703 If the number of times that the time interval is less than the second preset threshold is greater than or equal to the preset number of times, when the network speed rises sharply, the download of the media file of the current bit rate is maintained.
  • the preset time period is 2 minutes. If the network speed of the network rises and drops continuously for 5 times within 2 minutes, it means that the network speed stability of the network is poor, and the network speed needs to be When the speed rises sharply, the download of the media file with the current bit rate is maintained to avoid frequent switching of audio and video streams, which may cause the video playback to freeze.
  • an apparatus 800 for downloading media files including:
  • the obtaining unit 801 is configured to obtain the instantaneous speed and average speed of the network.
  • the judging unit 802 is configured to judge whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed.
  • the downloading unit 803 is configured to select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download if the network speed of the network rises or drops steeply.
  • the obtaining unit 801 is further specifically configured to:
  • n and m are integers greater than or equal to 1, And n is greater than m;
  • the m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
  • the obtaining unit 801 is further specifically configured to:
  • the number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
  • the determining unit 802 is further specifically configured to:
  • the download unit 803 is also specifically configured to:
  • a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
  • the download unit 803 is also specifically configured to:
  • the download of the media file of the current bit rate is maintained when the network speed rises sharply.
  • FIG. 9 is a schematic diagram of a terminal provided by an embodiment of the present application.
  • the terminal 9 includes a processor 90, a memory 91, and computer-readable instructions 92 stored in the memory 91 and running on the processor 90, such as a media file download program.
  • the processor 90 executes the computer-readable instructions 92, the steps in the above embodiments of the method for downloading various media files, such as steps 101 to 103 shown in FIG. 1, are implemented.
  • the processor 90 executes the computer-readable instructions 92
  • the functions of the modules/units in the foregoing device embodiments are implemented, for example, the functions of the modules 801 to 803 shown in FIG. 8.
  • the computer-readable instructions may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 91 and executed by the processor 90 to complete the application.
  • the one or more modules/units may be a series of computer-readable instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer-readable instructions in the terminal.
  • the computer-readable instructions can be divided into an acquisition unit, a judgment unit, and a download unit.
  • each unit is used to obtain the instantaneous speed and average speed of the network; The speed and the average speed determine whether the network speed of the network has a steep rise or fall; the download unit is used to select the bit rate and the bit rate according to the pre-stored media configuration file if the network speed of the network rises or falls steeply The media file corresponding to the instant speed is downloaded.
  • the terminal may be a mobile terminal such as a smart phone, or a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal may include, but is not limited to, a processor 90 and a memory 91.
  • FIG. 9 is only an example of a terminal, and does not constitute a limitation on the terminal. It may include more or less components than those shown in the figure, or a combination of certain components, or different components, such as the
  • the terminal may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 90 may be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (ASIC), Ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 91 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal.
  • the memory 91 may also be an external storage device of the terminal, for example, a plug-in hard disk equipped on the terminal, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, and a flash memory card. (Flash Card) etc.
  • the memory 91 may also include both an internal storage unit of the terminal and an external storage device.
  • the memory 91 is used to store the computer-readable instructions and other programs and data required by the terminal.
  • the memory 91 can also be used to temporarily store data that has been output or will be output.
  • the disclosed apparatus/terminal and method may be implemented in other ways.
  • the device/terminal embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or Components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory.
  • the non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Abstract

Provided are a media file downloading method and apparatus, and a terminal and a medium. The method comprises: acquiring an instant speed and an average speed of a network; determining, according to the instant speed and the average speed, whether a network speed of the network is sharply increased or sharply decreased; and if the network speed of the network is sharply increased or sharply decreased, selecting, according to a pre-stored media configuration file, a media file corresponding to a code rate and the instant speed to perform downloading. The problem of audio and videos lagging during playing or taking a relatively long time to enter an optimal playing state due to the fact that a user terminal cannot be switched, in a timely manner, to downloading of a media file corresponding to a code rate and a changed network speed when the network speed fluctuates greatly is solved.

Description

媒体文件的下载方法、装置、终端和介质Method, device, terminal and medium for downloading media files
本申请要求于2019年05月28日提交中国专利局、申请号为201910461908.5、发明名称为“媒体文件的下载方法、装置、终端和计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910461908.5, and the invention title is "media file download method, device, terminal and computer readable storage medium" on May 28, 2019, all of which The content is incorporated in this application by reference.
技术领域Technical field
本申请属于计算机技术领域,尤其涉及一种媒体文件的下载方法、装置、终端和介质。This application belongs to the field of computer technology, and in particular relates to a method, device, terminal and medium for downloading media files.
背景技术Background technique
利用流式传输技术在网络上下载音频或视频等媒体文件时,音频文件或视频文件由服务器向终端连续、实时传送,用户不必等到整个媒体文件全部下载完毕才进行媒体播放,只需经过几秒或十几秒的启动延时即可进行媒体播放,有效缩短了启动延时,节省了终端的缓存容量。When using streaming technology to download media files such as audio or video on the network, the audio file or video file is continuously and real-time transmitted from the server to the terminal. The user does not have to wait for the entire media file to be downloaded before playing the media. It only takes a few seconds Or media playback can be performed with a startup delay of more than ten seconds, which effectively shortens the startup delay and saves the buffer capacity of the terminal.
对于同一个音视频节目,服务器端一般会提供不同质量的多个媒体文件以适应不同网络条件下的下载与播放。每个媒体文件对应一种码率,每个媒体文件包含多个分片,一个分片分为若干个数据包,终端下载每个分片对应的数据包之后,以分片为基本播放单位进行音视频播放。For the same audio and video program, the server generally provides multiple media files of different qualities to adapt to downloading and playing under different network conditions. Each media file corresponds to a bit rate, and each media file contains multiple fragments. One fragment is divided into several data packets. After the terminal downloads the data packet corresponding to each fragment, the fragment is the basic playback unit. Audio and video playback.
终端在进行分片下载时,一般是通过计算网络的网络速度,并选择码率与所述网络的网络速度对应的媒体文件进行下载。然而,基于目前的流媒体传输协议,在网络速度发生较大波动时,终端一般无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,造成终端的音视频播放容易出现卡顿或者进入最佳播放状态的时间较长的问题。When the terminal downloads fragments, it generally calculates the network speed of the network, and selects a media file whose bit rate corresponds to the network speed of the network to download. However, based on the current streaming media transmission protocol, when the network speed fluctuates greatly, the terminal generally cannot switch to the download of media files corresponding to the bit rate and the changed network speed in time, causing the terminal's audio and video playback to be prone to freezes Or it takes a long time to enter the best playback state.
发明概述Summary of the invention
技术问题technical problem
有鉴于此,本申请实施例提供了一种媒体文件的下载方法、装置、终端和介质,可以解决在网络速度发生较大波动时,终端无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,导致音视频播放出现卡顿或者进入最佳播放 状态的时间较长的技术问题。In view of this, the embodiments of the present application provide a method, device, terminal, and medium for downloading media files, which can solve the problem that when the network speed fluctuates greatly, the terminal cannot switch to the code rate corresponding to the changed network speed in time. The downloading of media files causes technical problems in which audio and video playback may freeze or enter the optimal playback state for a long time.
问题的解决方案The solution to the problem
技术解决方案Technical solutions
本申请实施例第一方面提供一种媒体文件的下载方法,包括:The first aspect of the embodiments of the present application provides a method for downloading media files, including:
获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
本申请实施例第二方面提供的一种媒体文件的下载装置,包括:A device for downloading media files provided in the second aspect of the embodiments of the present application includes:
获取单元,用于获取网络的即时速度和平均速度;The acquisition unit is used to acquire the instantaneous speed and average speed of the network;
判断单元,用于根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;A judging unit, configured to judge whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed;
下载单元,用于若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。The downloading unit is configured to select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading if the network speed of the network rises or drops steeply.
本申请实施例第三方面提供一种终端,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A third aspect of the embodiments of the present application provides a terminal, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the computer-readable instructions When implementing the following steps:
获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
本申请实施例第四方面提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被至少一个处理器执行时实现如下步骤:The fourth aspect of the embodiments of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions implement the following steps when executed by at least one processor:
获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
发明的有益效果The beneficial effects of the invention
有益效果Beneficial effect
本申请实施例中,终端通过获取网络的即时速度和平均速度,并根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降,而不是仅仅根据平均速度判断所述网络的网络速度是否发生陡升或陡降,因此,在所述网络的网络速度发生陡升或陡降时,可以及时地根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,无需在所述网络的网络速度发生陡升或陡降之后下载至少一个分片的数据包,才能测算出变化后的网络速度,避免了终端出现无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,导致音视频播放出现卡顿或者进入最佳播放状态的时间较长的问题。In the embodiment of the present application, the terminal obtains the instantaneous speed and average speed of the network, and judges whether the network speed of the network has a steep rise or drop according to the instantaneous speed and the average speed, instead of judging the network speed only according to the average speed. Whether the network speed of the network has a steep rise or fall, therefore, when the network speed of the network rises or falls steeply, the media with the bit rate corresponding to the instant speed can be selected in time according to the pre-stored media configuration file The file is downloaded, without downloading at least one fragmented data packet after the network speed of the network has a steep rise or fall, in order to calculate the changed network speed, which prevents the terminal from being unable to switch to the code rate and changing in time The download of media files corresponding to the speed of the network causes the audio and video playback to freeze or enter the optimal playback state for a long time.
对附图的简要说明Brief description of the drawings
附图说明Description of the drawings
为了更清楚地说明本申请实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the following will briefly introduce the accompanying drawings needed in the description of the embodiments or the prior art. It should be understood that the following drawings only show some of the present application. The embodiments should not be regarded as a limitation of the scope. For those of ordinary skill in the art, without creative work, other related drawings can be obtained from these drawings.
图1是本申请实施例提供的一种媒体文件的下载方法的实现流程示意图;FIG. 1 is a schematic diagram of the implementation process of a method for downloading media files provided by an embodiment of the present application;
图2是本申请实施例提供的一种媒体文件的下载方法步骤101的具体实现流程示意图;2 is a schematic diagram of a specific implementation flow of step 101 of a method for downloading media files provided by an embodiment of the present application;
图3是本申请实施例提供的计算网络当前的即时速度的具体实现流程示意图;FIG. 3 is a schematic diagram of a specific implementation process of calculating the current instantaneous speed of the network provided by an embodiment of the present application;
图4是本申请实施例提供的终端下载好的数据包的示意图;4 is a schematic diagram of a data package downloaded by a terminal according to an embodiment of the present application;
图5是本申请实施例提供的一种媒体文件的下载方法步骤102的具体实现流程示意图;5 is a schematic diagram of a specific implementation flow of step 102 of a method for downloading media files provided by an embodiment of the present application;
图6是本申请实施例提供的一种媒体文件的下载方法步骤103的第一具体实现流程示意图;6 is a schematic diagram of a first specific implementation flow of step 103 of a method for downloading media files provided by an embodiment of the present application;
图7是本申请实施例提供的一种媒体文件的下载方法步骤103的第二具体实现流程示意图;FIG. 7 is a schematic diagram of a second specific implementation flow of step 103 of a method for downloading media files provided by an embodiment of the present application;
图8是本申请实施例提供的媒体文件的下载装置的结构示意图;FIG. 8 is a schematic structural diagram of a media file downloading device provided by an embodiment of the present application;
图9是本申请实施例提供的终端的结构示意图。FIG. 9 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
发明实施例Invention embodiment
本发明的实施方式Embodiments of the invention
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work shall fall within the protection scope of the present application.
利用流式传输技术(HTTP Live Streaming,HLS)在网络上下载音频或视频等媒体文件时,HLS客户端首先接收音视频服务器下发的m3u8格式的配置文件,然后计算网络的网络速度,并根据该网络速度选择对应带宽(码率)的媒体文件进行下载,以使终端能够流畅地进行音视频播放。When using streaming technology (HTTP Live Streaming, HLS) to download media files such as audio or video on the network, the HLS client first receives the configuration file in the m3u8 format issued by the audio and video server, and then calculates the network speed according to the The network speed selects the media file corresponding to the bandwidth (code rate) to download, so that the terminal can play audio and video smoothly.
然而,目前计算网络的网络速度的方法中,是根据下载的50个数据包的字节数除以下载时间的方式进行计算。通常一个分片少于50个数据包,因此,在网络速度发生较大波动时,需要在网络速度发生较大波动之后下载至少一个分片的数据,才能测算出较准确的网络速度,导致终端将无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,造成终端的音视频播放容易出现卡顿或者进入最佳播放状态的时间较长的问题。However, the current method of calculating the network speed of the network is calculated based on the number of bytes of the downloaded 50 data packets divided by the download time. Usually there are less than 50 data packets in a fragment. Therefore, when the network speed fluctuates greatly, it is necessary to download the data of at least one fragment after the network speed fluctuates greatly in order to calculate a more accurate network speed, which leads to the terminal It will not be able to switch to the download of media files corresponding to the bit rate and the changed network speed in time, resulting in the problem that the audio and video playback of the terminal is prone to freeze or enter the optimal playback state for a long time.
例如,根据网络速度发生较大波动前下载的50个数据包中每个数据包下载时对应的网络速度均为350KBps,即,网络速度稳定在350KBps,在网络速度发生较大波动后,下载的第一个数据包对应的网络速度为140KBps,下载的第二个数据包对应的网络速度为160KBps,下载的第三个数据包对应的网络速度为150KBps,这三个数据包的平均速度为150KBps,约为350KBps的0.42倍,即,此时,网络速度已经发生较大波动。但是,若继续根据下载的50个数据包的字节数除以总下载时间的方式计算网络速度,则计算出来的网络速度为(350KBps*47+140KBps+160KBps+150KBps)/50=338KBps,然而338KBps相对于350KBps来说,并不能判断出网络速度发生较大波动,因此,需要在网络速度发生较大波动之后下载至少一个分片的数据包,才能测算出变化后的网络速度,导致终端将无 法及时切换到码率与变化后的网络速度对应的媒体文件的下载,造成终端的音视频播放容易出现卡顿或者进入最佳播放状态的时间较长的问题。For example, according to the 50 data packets downloaded before large fluctuations in network speed, the corresponding network speed when downloading each data packet is 350KBps, that is, the network speed is stabilized at 350KBps. The network speed corresponding to the first data packet is 140KBps, the network speed corresponding to the second data packet downloaded is 160KBps, the network speed corresponding to the third data packet downloaded is 150KBps, and the average speed of these three data packets is 150KBps , About 0.42 times of 350KBps, that is, at this time, the network speed has already fluctuated greatly. However, if you continue to calculate the network speed based on the number of bytes of the downloaded 50 data packets divided by the total download time, the calculated network speed is (350KBps*47+140KBps+160KBps+150KBps)/50=338KBps, however Compared with 350KBps, 338KBps cannot determine that the network speed fluctuates greatly. Therefore, it is necessary to download at least one fragmented data packet after the network speed fluctuates greatly in order to calculate the changed network speed. It is impossible to switch to the download of the media file corresponding to the bit rate and the changed network speed in time, which causes the problem that the audio and video playback of the terminal is prone to freeze or enter the optimal playback state for a long time.
本申请实施例中,终端通过获取网络的即时速度和平均速度,并根据所述即时速度和平均速度判断网络的网络速度是否发生陡升或陡降,而不是仅仅根据平均速度判断网络的网络速度是否发生陡升或陡降,因此,在网络的网络速度发生陡升或陡降时,可以及时地根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,无需在网络的网络速度发生陡升或陡降之后下载至少一个分片的数据包,才能测算出变化后的网络速度,避免了终端出现无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,导致音视频播放出现卡顿或者进入最佳播放状态的时间较长的问题。In the embodiment of the present application, the terminal obtains the instantaneous speed and average speed of the network, and judges whether the network speed of the network rises or drops steeply according to the instant speed and the average speed, instead of just judging the network speed of the network based on the average speed Whether there is a steep rise or fall, therefore, when the network speed of the network rises or falls steeply, the media file with the bit rate corresponding to the instant speed can be selected for download in time according to the pre-stored media configuration file, and there is no need to download After the network speed of the network rises or drops steeply, download at least one fragmented data packet to calculate the changed network speed, which prevents the terminal from being unable to switch to the media file corresponding to the changed network speed in time. Download, causing the audio and video playback to freeze or enter the optimal playback state for a long time.
如图1示出了本申请实施例提供的一种媒体文件的下载方法的实现流程示意图,包括步骤101至步骤103。FIG. 1 shows a schematic diagram of the implementation process of a method for downloading media files provided by an embodiment of the present application, including step 101 to step 103.
步骤101,获取网络的即时速度和平均速度。Step 101: Obtain the instantaneous speed and average speed of the network.
在利用HLS客户端进行音视频播放时,终端先接收音视频服务器下发的m3u8格式的配置文件,并对其进行存储,接着在利用流式传输技术在网络上下载音频或视频等媒体文件时,获取终端的网络速度,并根据该网络速度选择对应码率的媒体文件进行下载,以使终端能够流畅地进行音视频播放。When using the HLS client to play audio and video, the terminal first receives the configuration file in m3u8 format issued by the audio and video server, and stores it, and then uses streaming technology to download media files such as audio or video on the network , Obtain the network speed of the terminal, and select the media file of the corresponding bit rate to download according to the network speed, so that the terminal can play audio and video smoothly.
本申请实施例中,获取终端的网络速度包括获取网络的即时速度和平均速度。In the embodiment of the present application, acquiring the network speed of the terminal includes acquiring the instantaneous speed and the average speed of the network.
可选的,如图2所示,所述获取网络的即时速度和平均速度可以包括:步骤201至步骤202。Optionally, as shown in FIG. 2, the obtaining the instantaneous speed and average speed of the network may include: step 201 to step 202.
步骤201,获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m。Step 201: Obtain the number of bytes and download time of each of the newly downloaded m data packets, and obtain the total number of bytes and total download time of the newly downloaded n data packets; n and m are greater than or equal to 1. An integer of and n is greater than m.
步骤202,利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。Step 202: Calculate m instantaneous speeds of the network using the number of bytes of each data packet in the m data packets and the download time; use the total number of bytes and the total download time of the n data packets The average speed of the network is calculated.
其中,上述n、m的取值可以根据实际应用场景进行取值,本申请对此不做限制,只需保证n和m为大于等于1的整数,且n大于m。Wherein, the above-mentioned values of n and m can be selected according to actual application scenarios. This application does not impose any restriction on this. It is only necessary to ensure that n and m are integers greater than or equal to 1, and n is greater than m.
例如,n的取值可以为50,m的取值可以为3,则在获取最新下载的50个数据包中每个数据包的字节数和下载时间,以及获取最新下载的3个数据包的总字节数和总下载时间之后,即可利用所述3个数据包中的每个数据包的字节数和下载时间计算得到网络的3个即时速度;利用所述50个数据包的总字节数和总下载时间计算得到网络的平均速度。For example, the value of n can be 50, the value of m can be 3, then the number of bytes and download time of each data packet in the 50 latest downloaded data packets is obtained, and the 3 newly downloaded data packets are obtained After the total number of bytes and the total download time of the three data packets, the three instantaneous speeds of the network can be calculated using the number of bytes of each of the three data packets and the download time; The total number of bytes and the total download time are calculated to get the average speed of the network.
其中,如图3所示,步骤202中,利用所述m个数据包中的每个数据包的字节数和下载时间计算得到网络的m个即时速度可以具体包括:步骤301或者步骤302。Wherein, as shown in FIG. 3, in step 202, calculating the m instantaneous speeds of the network by using the number of bytes of each of the m data packets and the download time may specifically include: step 301 or step 302.
步骤301,利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度。Step 301: Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two downloaded data packets among the m data packets. The total number of bytes of each data packet and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained.
例如,如图4所示,数据包1、数据包2和数据包3为最新连续下载的三个数据包,数据包1为最后完成下载的一个数据包,本实施例中,利用数据包1的字节数除以其下载时间得到网络的第一个即时速度;利用数据包1和数据包2的总字节数除以其两者的下载时间得到网络的第二个即时速度;利用数据包1、数据包2和数据包3的总字节数除以其三者的下载时间得到网络的第三个即时速度,总共得到3个网络的即时速度。For example, as shown in Figure 4, data package 1, data package 2, and data package 3 are the three most recently downloaded data packages, and data package 1 is the last downloaded data package. In this embodiment, data package 1 is used. Divide the number of bytes by its download time to get the first instant speed of the network; use the total number of bytes of packet 1 and packet 2 divided by the download time of both to get the second instant speed of the network; use data The total number of bytes of packet 1, data packet 2, and data packet 3 is divided by the download time of the three to obtain the third instantaneous speed of the network, and the instantaneous speed of 3 networks is obtained in total.
步骤302,利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。Step 302: Use the number of bytes and download time of each data packet in the m data packets to respectively calculate an instant speed of the network, and obtain a total of m instant speeds of the network.
例如,如图4所示,数据包1、数据包2和数据包3为最新下载的三个数据包,数据包1为最后完成下载的一个数据包,本实施例中,利用数据包1的字节数除以其下载时间得到网络的第一个即时速度;利用数据包2的字节数除以其下载时间得到网络的第二个即时速度;利用数据包3的字节数除以其下载时间得到网络的第三个即时速度,总共得到网络的3个即时速度。For example, as shown in Figure 4, data package 1, data package 2, and data package 3 are the three newly downloaded data packages, and data package 1 is the last downloaded data package. In this embodiment, data package 1 is used Divide the number of bytes by its download time to get the first instant speed of the network; divide the number of bytes in packet 2 by its download time to get the second instant speed of the network; divide the number of bytes in packet 3 by it The download time gets the third instant speed of the network, and a total of 3 instant speeds of the network.
步骤102,根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降。Step 102: Judging whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed.
在获取了网络的即时速度和平均速度之后,即可根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降。After obtaining the instantaneous speed and average speed of the network, it can be determined whether the network speed of the network has a steep rise or drop according to the instant speed and the average speed.
可选的,如图5所示,所述根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降,可以包括:步骤501至步骤502。Optionally, as shown in FIG. 5, judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed may include: step 501 to step 502.
步骤501,若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确定所述网络的网络速度发生陡升。Step 501: If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply.
步骤502,若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。Step 502: If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
由于所述平均速度为根据较多数据包计算得到的速度,能够反映出网络整体的速度水平,而网络的即时速度为根据较少的数据包计算得到的速度,能够反映出网络最新的速度变化情况,因此,通过将所述即时速度同所述平均速度进行比较,可以较合理地判断出网络的网络速度是否发生陡升或发生陡降。Since the average speed is calculated based on more data packets, it can reflect the overall speed level of the network, while the instantaneous speed of the network is the speed calculated based on fewer data packets, which can reflect the latest speed changes of the network Therefore, by comparing the instantaneous speed with the average speed, it can be reasonably judged whether the network speed of the network has a steep rise or a steep drop.
本申请实施例中,所述第一倍数与所述第二倍数的取值可以根据实际应用场景进行设置,本申请对此不做限制。例如,所述第一倍数为2~5,所述二倍数为0.7~0.1。In the embodiment of the present application, the values of the first multiple and the second multiple may be set according to actual application scenarios, which is not limited in this application. For example, the first multiple is 2-5, and the double multiple is 0.7-0.1.
本申请实施例中,通过将所述网络的m个即时速度与第一倍数的所述平均速度和/或第二倍数的平均速度进行比较,并在所述网络的m个即时速度均大于第一倍数的所述平均速度时,确定网络速度发生陡升;在所述网络的m个即时速度均小于第二倍数的所述平均速度,确定所述网络的网络速度发生陡降,可以使得网络的网络速度是否发生陡升或陡降的判断更加准确。In the embodiment of this application, the m instant speeds of the network are compared with the average speed of the first multiple and/or the average speed of the second multiple, and the m instant speeds of the network are all greater than the first multiple. When the average speed is one multiple, it is determined that the network speed has a steep rise; when the m instantaneous speeds of the network are all less than the average speed of the second multiple, it is determined that the network speed of the network drops sharply, which can make the network It is more accurate to judge whether the network speed has a steep rise or fall.
在本申请的一些实施方式中,所述根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降还可以包括:若所述网络的m个即时速度中预设个数的即时速度均大于第一倍数的所述平均速度,则确定网络速度发生陡升;若所述网络的m个即时速度中预设个数的即时速度均小于第二倍数的所述平均速度,则确定网络速度发生陡降。其中,预设个数可以为大于设定倍数的m的个数,例如,所述设定倍数可以为0.9、0.85或0.8。In some embodiments of the present application, the judging whether the network speed of the network has a steep rise or fall according to the real-time speed and the average speed may also include: if one of the m real-time speeds of the network is preset If the instantaneous speeds of the number are greater than the average speed of the first multiple, it is determined that the network speed has risen sharply; if the preset number of instantaneous speeds in the m instant speeds of the network are all less than the average speed of the second multiple , It is determined that the network speed has dropped sharply. Wherein, the preset number may be a number of m greater than the set multiple. For example, the set multiple may be 0.9, 0.85, or 0.8.
也就是说,在根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降时,可以不需要所述网络的m个即时速度全部大于第一倍数或小于第二倍数的所述平均速度,才确定网络速度发生陡升或陡降,而只需要所述网络的m个即时速度中部分个数的即时速度大于第一倍数或小于第二倍数的所述平均 速度,就可以确定网络速度发生陡升或陡降,从而使得网络速度是否发生陡升或陡降的判断存在一定的冗余度。That is to say, when judging whether the network speed of the network has a steep rise or fall based on the instant speed and the average speed, it may not be necessary for the m instant speeds of the network to be all greater than the first multiple or less than the second multiple. It is determined that the network speed has a steep rise or fall, and only a part of the m real-time speeds of the network need to be greater than the first multiple or less than the second multiple of the average speed, It can be determined that the network speed has a steep rise or fall, so that there is a certain degree of redundancy in the judgment of whether the network speed has a steep rise or fall.
步骤103,若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。Step 103: If the network speed of the network rises or drops sharply, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
所述预先存储的媒体配置文件存储音视频流信息,所述音视频流信息可以包括:码率与媒体文件之间的对应关系,以及媒体文件的内容类型信息。The pre-stored media configuration file stores audio and video stream information, and the audio and video stream information may include: a correspondence between a bit rate and a media file, and content type information of the media file.
例如,所述预先存储的媒体配置文件存储的码率与媒体文件之间的对应关系,以及媒体文件的内容类型信息为:For example, the corresponding relationship between the code rate stored in the pre-stored media configuration file and the media file, and the content type information of the media file are:
音视频流00:40Kbps;有音频流,无视频流,有1张JPEG图片;Audio and video stream 00: 40Kbps; there is audio stream, no video stream, there is 1 JPEG picture;
音视频流01:120Kbps;有音频流,有视频流(视频流分辨率176x144);Audio and video stream 01: 120Kbps; there is audio stream, there is video stream (video stream resolution 176x144);
音视频流02:300Kbps;有音频流,有视频流(视频流分辨率320x180);Audio and video stream 02: 300Kbps; there is audio stream and video stream (video stream resolution 320x180);
音视频流03:500Kbps;有音频流,有视频流(视频流分辨率400x224);Audio and video stream 03: 500Kbps; there is audio stream, there is video stream (video stream resolution 400x224);
音视频流04:800Kbps;有音频流,有视频流(视频流分辨率480x270);Audio and video stream 04: 800Kbps; there is audio stream and video stream (video stream resolution 480x270);
音视频流05:1300Kbps;有音频流,有视频流(视频流分辨率640x360);Audio and video stream 05: 1300Kbps; there is audio stream and video stream (video stream resolution 640x360);
音视频流06:2200Kbps;有音频流,有视频流(视频流分辨率1024x576)。Audio and video stream 06: 2200Kbps; there is audio stream and video stream (video stream resolution 1024x576).
本申请实施例中,在判断出网络的网络速度发生陡升或陡降时,即可根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,避免了在网络速度发生较大波动时,终端出现无法及时切换到码率与变化后的网络速度对应的媒体文件的下载,导致音视频播放出现卡顿或者进入最佳播放状态的时间较长的问题。In the embodiment of the present application, when it is determined that the network speed of the network has a steep rise or fall, the media file with the bit rate corresponding to the instant speed can be selected for downloading according to the pre-stored media configuration file, which avoids the network speed When large fluctuations occur, the terminal cannot switch to the download of media files corresponding to the bit rate and the changed network speed in time, resulting in a problem that audio and video playback is stuck or it takes a long time to enter the optimal playback state.
其中,在所述即时速度的个数大于2时,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载包括:根据预先存储的媒体配置文件选择码率与所述即时速度的平均速度对应的媒体文件进行下载。Wherein, when the number of instant speeds is greater than 2, the selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download includes: selecting a code rate according to the pre-stored media configuration file and The media file corresponding to the average speed of the instant speed is downloaded.
例如,当前播放的音视频流为300KBps的音视频流02,网络的平均速度为350KBps,第二倍数为0.5,计算出的3个即时速度的平均速度为150KBps,其中,第一个即时速度为150KBps;第二个即时速度为160KBps;第三个即时速度为140KBps;则由于所述网络的3个即时速度均小于第二倍数的所述平均速度,因此,可以确定网络速度发生陡降。此时,可以根据预先存储的媒体配置文件选择码 率与所述即时速度的平均速度150KBps对应的媒体文件音视频流01进行下载。也就是说,可以在所述网络的网络速度发生较大变化之后的第四个数据包开始,即可及时切换到码率与变化后的网络速度对应的媒体文件的下载,避免了终端的音视频播放容易出现卡顿或者进入最佳播放状态的时间较长的问题。For example, the currently playing audio and video stream is 300KBps audio and video stream 02, the average network speed is 350KBps, the second multiple is 0.5, and the calculated average speed of the three instant speeds is 150KBps, where the first instant speed is 150KBps; the second instantaneous speed is 160KBps; the third instantaneous speed is 140KBps; because the three instantaneous speeds of the network are all less than the second multiple of the average speed, it can be determined that the network speed has dropped sharply. At this time, the media file audio and video stream 01 with a bit rate corresponding to the average speed of 150KBps of the instant speed can be selected according to the pre-stored media configuration file for download. That is to say, it is possible to switch to the download of media files corresponding to the bit rate and the changed network speed in time starting from the fourth data packet after the network speed of the network has changed significantly, avoiding the terminal audio Video playback is prone to stalling or a long time to enter the best playback state.
例如,如表一所示,通过测试可以看出,利用本申请的音视频流的下载方法进行音视频文件的下载时,可以有效减少音视频播放的卡顿时间,以及有效缩短了音视频播放进入最佳播放状态的时间,避免了终端的音视频播放容易出现卡顿或者进入最佳播放状态的时间较长的问题。For example, as shown in Table 1, through testing, it can be seen that when using the audio and video stream download method of this application to download audio and video files, the stall time of audio and video playback can be effectively reduced, and the audio and video playback can be effectively shortened The time to enter the best playback state avoids the problem that the terminal's audio and video playback is prone to freeze or enters the best playback state for a long time.
表一:Table I:
Figure PCTCN2019118543-appb-000001
Figure PCTCN2019118543-appb-000001
可选的,在本申请的一些实施方式中,如图6所示,上述步骤103中,若所述网络的网络速度发生陡升,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载可以包括:步骤601至步骤603。Optionally, in some embodiments of the present application, as shown in FIG. 6, in the above step 103, if the network speed of the network rises sharply, the bit rate and the bit rate are selected according to the pre-stored media configuration file. The downloading of the media file corresponding to the instant speed may include: step 601 to step 603.
步骤601,若所述网络的网络速度发生陡升,则判断所述媒体文件正在下载的分片已下载完成的比例是否大于第一预设阈值。Step 601: If the network speed of the network rises sharply, it is determined whether the proportion of the downloaded segments of the media file that have been downloaded is greater than a first preset threshold.
步骤602,若小于所述第一预设阈值,则直接根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。Step 602: If it is less than the first preset threshold, directly select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download.
步骤603,若大于或等于所述第一预设阈值,则在所述媒体文件正在下载的分片下载完成后,根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。Step 603: If it is greater than or equal to the first preset threshold, after the download of the segment of the media file being downloaded is completed, select a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file. download.
由于下载音视频流时,是以分片作为最基本的播放单位,对于一个分片,只有两种选择:要么完全下载并播放,要么不下载或者下载一部分之后丢弃。因此,在所述网络的网络速度发生陡升,需要切换到较高码率的音视频流的下载时,可以先判断媒体文件正在下载的分片已完成的比例是否大于预设阈值,若大于,则在媒体文件正在下载的分片下载完成后切换至较高码率的音视频流的下载,以避免在缓存不足的情况下,因切换至较高码率的音视频流的下载,导致未下载完成的分片被丢弃,出现卡顿的现象。When downloading audio and video streams, fragments are the most basic playback unit. For a fragment, there are only two options: either download it completely and play it, or not download it or discard a part after downloading it. Therefore, when the network speed of the network rises sharply and it is necessary to switch to the download of a higher bit rate audio and video stream, it can be judged whether the proportion of the completed fragments of the media file being downloaded is greater than the preset threshold, if it is greater than , The download of the audio and video stream with a higher bit rate will be switched to after the download of the segment of the media file being downloaded is completed, so as to avoid switching to the download of the audio and video stream with a higher bit rate when the cache is insufficient. Fragments that have not been downloaded are discarded, causing a freeze.
其中,所述第一预设阈值的取值可以根据实际应用场景进行确定,本申请对此不做限制。例如,所述第一预设阈值可以为95%或90%。Wherein, the value of the first preset threshold may be determined according to actual application scenarios, which is not limited in this application. For example, the first preset threshold may be 95% or 90%.
可选的,在本申请的一些实施方式中,如图7所示,在网络速度波动频率较大时,为了避免音视频流的切换过于频繁,上述步骤103中,若所述网络的网络速度发生陡升或陡降,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载还可以包括:步骤701至步骤703。Optionally, in some embodiments of the present application, as shown in FIG. 7, when the network speed fluctuates frequently, in order to avoid switching audio and video streams too frequently, in step 103, if the network speed of the network When a steep rise or fall occurs, the selection of a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download may further include: step 701 to step 703.
步骤701,若所述网络的网络速度发生陡升或陡降,则获取预设时间段内网络速度发生陡升与发生陡降之间的时间间隔。In step 701, if the network speed of the network rises or drops sharply, obtain the time interval between the steep rise and the steep drop in the network speed within a preset time period.
步骤702,若所述时间间隔小于第二预设阈值的次数小于预设次数,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。Step 702: If the number of times the time interval is less than the second preset threshold is less than the preset number of times, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
步骤703,若所述时间间隔小于第二预设阈值的次数大于或等于所述预设次数,则在网络速度发生陡升时,保持当前码率的媒体文件的下载。Step 703: If the number of times that the time interval is less than the second preset threshold is greater than or equal to the preset number of times, when the network speed rises sharply, the download of the media file of the current bit rate is maintained.
例如,所述预设时间段为2分钟,若2分钟内所述网络的网络速度连续5次发生陡升又陡降的情况时,表示所述网络的网络速度稳定性较差,需要在网络速度发生陡升时,保持当前码率的媒体文件的下载,以避免频繁进行音视频流的切换,导致视频播放的卡顿的情况。For example, the preset time period is 2 minutes. If the network speed of the network rises and drops continuously for 5 times within 2 minutes, it means that the network speed stability of the network is poor, and the network speed needs to be When the speed rises sharply, the download of the media file with the current bit rate is maintained to avoid frequent switching of audio and video streams, which may cause the video playback to freeze.
如图8所示,本申请实施例提供一种媒体文件的下载装置800,包括:As shown in FIG. 8, an embodiment of the present application provides an apparatus 800 for downloading media files, including:
获取单元801,用于获取网络的即时速度和平均速度。The obtaining unit 801 is configured to obtain the instantaneous speed and average speed of the network.
判断单元802,用于根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降。The judging unit 802 is configured to judge whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed.
下载单元803,用于若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。The downloading unit 803 is configured to select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download if the network speed of the network rises or drops steeply.
可选的,所述获取单元801,还具体用于:Optionally, the obtaining unit 801 is further specifically configured to:
获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m;Get the number of bytes and download time of each data packet in the latest downloaded m data packets, and get the total number of bytes and total download time of the latest n data packets downloaded; n and m are integers greater than or equal to 1, And n is greater than m;
利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。The m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
可选的,所述获取单元801,还具体用于:Optionally, the obtaining unit 801 is further specifically configured to:
利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度;Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two data packets downloaded in the m data packets The total number of bytes and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained;
或者,or,
利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。The number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
可选的,所述判断单元802,还具体用于:Optionally, the determining unit 802 is further specifically configured to:
若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确定所述网络的网络速度发生陡升;If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply;
若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
可选的,所述下载单元803,还具体用于:Optionally, the download unit 803 is also specifically configured to:
若所述网络的网络速度发生陡升,则判断所述媒体文件正在下载的分片已下载完成的比例是否大于第一预设阈值;If the network speed of the network rises sharply, determining whether the proportion of the downloaded segments of the media file that have been downloaded is greater than a first preset threshold;
若小于所述第一预设阈值,则直接根据预先存储的媒体配置文件选择码率与所 述即时速度对应的媒体文件进行下载;If it is less than the first preset threshold, directly select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for download;
若大于或等于所述第一预设阈值,则在所述媒体文件正在下载的分片下载完成后,根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If it is greater than or equal to the first preset threshold, after the download of the downloading segment of the media file is completed, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
可选的,所述下载单元803,还具体用于:Optionally, the download unit 803 is also specifically configured to:
若所述网络的网络速度发生陡升或陡降,则获取预设时间段内网络速度发生陡升与发生陡降之间的时间间隔;If the network speed of the network rises or drops steeply, the time interval between the steep rise and the steep drop of the network speed within the preset time period is acquired;
若所述时间间隔小于第二预设阈值的次数小于预设次数,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载;If the number of times the time interval is less than the second preset threshold is less than the preset number of times, selecting a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
若所述时间间隔小于第二预设阈值的次数大于或等于所述预设次数,则在网络速度发生陡升时,保持当前码率的媒体文件的下载。If the number of times that the time interval is less than the second preset threshold is greater than or equal to the preset number of times, the download of the media file of the current bit rate is maintained when the network speed rises sharply.
需要说明的是,为描述的方便和简洁,上述描述的媒体文件的下载装置800的具体工作过程,可以参考图1和图7所述方法的对应过程,在此不再赘述。It should be noted that, for the convenience and conciseness of the description, the specific working process of the media file downloading apparatus 800 described above can be referred to the corresponding process of the method described in FIG. 1 and FIG. 7, which will not be repeated here.
图9是本申请实施例提供的终端的示意图。如图9所示,该终端9包括:处理器90、存储器91以及存储在所述存储器91中并可在所述处理器90上运行的计算机可读指令92,例如媒体文件的下载程序。所述处理器90执行所述计算机可读指令92时实现上述各个媒体文件的下载方法实施例中的步骤,例如图1所示的步骤101至103。或者,所述处理器90执行所述计算机可读指令92时实现上述各装置实施例中各模块/单元的功能,例如图8所示模块801至803的功能。FIG. 9 is a schematic diagram of a terminal provided by an embodiment of the present application. As shown in FIG. 9, the terminal 9 includes a processor 90, a memory 91, and computer-readable instructions 92 stored in the memory 91 and running on the processor 90, such as a media file download program. When the processor 90 executes the computer-readable instructions 92, the steps in the above embodiments of the method for downloading various media files, such as steps 101 to 103 shown in FIG. 1, are implemented. Alternatively, when the processor 90 executes the computer-readable instructions 92, the functions of the modules/units in the foregoing device embodiments are implemented, for example, the functions of the modules 801 to 803 shown in FIG. 8.
所述计算机可读指令可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器91中,并由所述处理器90执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机可读指令段,该指令段用于描述所述计算机可读指令在所述终端中的执行过程。例如,所述计算机可读指令可以被分割成获取单元、判断单元和下载单元,各单元具体功能如下:获取单元,用于获取网络的即时速度和平均速度;判断单元,用于根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;下载单元,用于若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。The computer-readable instructions may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 91 and executed by the processor 90 to complete the application. The one or more modules/units may be a series of computer-readable instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer-readable instructions in the terminal. For example, the computer-readable instructions can be divided into an acquisition unit, a judgment unit, and a download unit. The specific functions of each unit are as follows: the acquisition unit is used to obtain the instantaneous speed and average speed of the network; The speed and the average speed determine whether the network speed of the network has a steep rise or fall; the download unit is used to select the bit rate and the bit rate according to the pre-stored media configuration file if the network speed of the network rises or falls steeply The media file corresponding to the instant speed is downloaded.
所述终端可以是智能手机等移动终端,或者是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端可包括,但不仅限于,处理器90、存储器91。本领域技术人员可以理解,图9仅仅是终端的示例,并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端还可以包括输入输出设备、网络接入设备、总线等。The terminal may be a mobile terminal such as a smart phone, or a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art can understand that FIG. 9 is only an example of a terminal, and does not constitute a limitation on the terminal. It may include more or less components than those shown in the figure, or a combination of certain components, or different components, such as the The terminal may also include input and output devices, network access devices, buses, and so on.
所称处理器90可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 90 may be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (ASIC), Ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
所述存储器91可以是所述终端的内部存储单元,例如终端的硬盘或内存。所述存储器91也可以是所述终端的外部存储设备,例如所述终端上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器91还可以既包括所述终端的内部存储单元也包括外部存储设备。所述存储器91用于存储所述计算机可读指令以及所述终端所需的其他程序和数据。所述存储器91还可以用于暂时地存储已经输出或者将要输出的数据。The memory 91 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. The memory 91 may also be an external storage device of the terminal, for example, a plug-in hard disk equipped on the terminal, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, and a flash memory card. (Flash Card) etc. Further, the memory 91 may also include both an internal storage unit of the terminal and an external storage device. The memory 91 is used to store the computer-readable instructions and other programs and data required by the terminal. The memory 91 can also be used to temporarily store data that has been output or will be output.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and conciseness of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned functions can be allocated to different functional units and modules as required. Module completion means dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist alone physically, or two or more units can be integrated into one unit. The above-mentioned integrated units can be hardware-based Formal realization can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only used to facilitate distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working process of the units and modules in the foregoing system, reference may be made to the corresponding process in the foregoing method embodiment, which is not repeated here.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail or recorded in an embodiment, reference may be made to related descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may be aware that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/终端和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the device/terminal embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or Components can be combined or integrated into another system, or some features can be omitted or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, the functional units in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM )、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through computer-readable instructions, which can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. The non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still implement the foregoing The technical solutions recorded in the examples are modified, or some of the technical features are equivalently replaced; these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of protection of this application.

Claims (20)

  1. 一种媒体文件的下载方法,其特征在于,包括:A method for downloading media files, characterized in that it comprises:
    获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
    根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
    若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  2. 如权利要求1所述的下载方法,其特征在于,所述获取网络的即时速度和平均速度包括:The download method according to claim 1, wherein said obtaining the instantaneous speed and average speed of the network comprises:
    获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m;Get the number of bytes and download time of each data packet in the latest downloaded m data packets, and get the total number of bytes and total download time of the latest n data packets downloaded; n and m are integers greater than or equal to 1, And n is greater than m;
    利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。The m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
  3. 如权利要求2所述的下载方法,其特征在于,所述利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度包括:The download method according to claim 2, wherein said calculating the m instant speeds of the network by using the number of bytes of each of the m data packets and the download time comprises:
    利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度;Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two data packets downloaded in the m data packets The total number of bytes and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained;
    或者,or,
    利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。The number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
  4. 如权利要求1-3任意一项所述的下载方法,其特征在于,所述根 据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降,包括:The download method according to any one of claims 1 to 3, wherein the judging whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed comprises:
    若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确定所述网络的网络速度发生陡升;If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply;
    若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
  5. 如权利要求1-3任意一项所述的下载方法,其特征在于,所述若所述网络的网络速度发生陡升,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,包括:The download method according to any one of claims 1-3, wherein if the network speed of the network rises sharply, the code rate corresponding to the instant speed is selected according to the pre-stored media configuration file Media files for download, including:
    若所述网络的网络速度发生陡升,则判断所述媒体文件正在下载的分片已下载完成的比例是否大于第一预设阈值;If the network speed of the network rises sharply, determining whether the proportion of the downloaded segments of the media file that have been downloaded is greater than a first preset threshold;
    若小于所述第一预设阈值,则直接根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载;If it is less than the first preset threshold, directly select a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file to download;
    若大于或等于所述第一预设阈值,则在所述媒体文件正在下载的分片下载完成后,根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If it is greater than or equal to the first preset threshold, after the download of the downloading segment of the media file is completed, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
  6. 如权利要求1-3任意一项所述的下载方法,其特征在于,若所述网络的网络速度发生陡升或陡降,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,包括:The download method according to any one of claims 1-3, wherein if the network speed of the network rises or drops steeply, the code rate and the real-time speed are selected according to a pre-stored media configuration file. Download the corresponding media files, including:
    若所述网络的网络速度发生陡升或陡降,则获取预设时间段内网络速度发生陡升与发生陡降之间的时间间隔;If the network speed of the network rises or drops steeply, the time interval between the steep rise and the steep drop of the network speed within the preset time period is acquired;
    若所述时间间隔小于第二预设阈值的次数小于预设次数,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载;If the number of times the time interval is less than the second preset threshold is less than the preset number of times, selecting a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
    若所述时间间隔小于第二预设阈值的次数大于或等于所述预设次数,则在网络速度发生陡升时,保持当前码率的媒体文件的下载。If the number of times that the time interval is less than the second preset threshold is greater than or equal to the preset number of times, the download of the media file of the current bit rate is maintained when the network speed rises sharply.
  7. 一种媒体文件的下载装置,其特征在于,包括:A device for downloading media files is characterized by comprising:
    获取单元,用于获取网络的即时速度和平均速度;The acquisition unit is used to acquire the instantaneous speed and average speed of the network;
    判断单元,用于根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;A judging unit, configured to judge whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed;
    下载单元,用于若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。The downloading unit is configured to select a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading if the network speed of the network rises or drops steeply.
  8. 如权利要求7所述的下载装置,其特征在于,所述获取单元,还用于:8. The download device of claim 7, wherein the acquiring unit is further configured to:
    获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m;Get the number of bytes and download time of each data packet in the latest downloaded m data packets, and get the total number of bytes and total download time of the latest n data packets downloaded; n and m are integers greater than or equal to 1, And n is greater than m;
    利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。The m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
  9. 如权利要求7所述的下载装置,其特征在于,所述获取单元,还用于:8. The download device of claim 7, wherein the acquiring unit is further configured to:
    利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度;Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two data packets downloaded in the m data packets The total number of bytes and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained;
    或者,or,
    利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。The number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
  10. 如权利要求7-9任意一项所述的下载装置,其特征在于,所述判断单元,还用于:8. The download device according to any one of claims 7-9, wherein the judgment unit is further configured to:
    若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确 定所述网络的网络速度发生陡升;If the m instantaneous speeds of the network are all greater than the first multiple of the average speed, it is determined that the network speed of the network has risen sharply;
    若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
  11. 一种终端,其特征在于,所述终端包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:A terminal, characterized in that the terminal includes a memory and a processor, the memory stores computer-readable instructions that can run on the processor, and the processor executes the computer-readable instructions to implement The following steps:
    获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
    根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
    若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  12. 如权利要求11所述的终端,其特征在于,所述获取网络的即时速度和平均速度包括:The terminal according to claim 11, wherein said obtaining the instantaneous speed and average speed of the network comprises:
    获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m;Get the number of bytes and download time of each data packet in the latest downloaded m data packets, and get the total number of bytes and total download time of the latest n data packets downloaded; n and m are integers greater than or equal to 1, And n is greater than m;
    利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。The m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
  13. 如权利要求12所述的终端,其特征在于,所述利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度包括:The terminal according to claim 12, wherein said calculating the m instant speeds of the network by using the number of bytes of each of the m data packets and the download time comprises:
    利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度;Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two data packets downloaded in the m data packets The total number of bytes and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained;
    或者,or,
    利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。The number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
  14. 如权利要求11-13任意一项所述的终端,其特征在于,所述根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降,包括:The terminal according to any one of claims 11-13, wherein the judging whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed comprises:
    若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确定所述网络的网络速度发生陡升;If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply;
    若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
  15. 如权利要求11-13任意一项所述的终端,其特征在于,所述若所述网络的网络速度发生陡升,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,包括:The terminal according to any one of claims 11-13, wherein if the network speed of the network rises sharply, the code rate corresponding to the instant speed is selected according to a pre-stored media configuration file. Download media files, including:
    若所述网络的网络速度发生陡升,则判断所述媒体文件正在下载的分片已下载完成的比例是否大于第一预设阈值;If the network speed of the network rises sharply, determining whether the proportion of the downloaded segments of the media file that have been downloaded is greater than a first preset threshold;
    若小于所述第一预设阈值,则直接根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载;If it is less than the first preset threshold, directly select a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file to download;
    若大于或等于所述第一预设阈值,则在所述媒体文件正在下载的分片下载完成后,根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If it is greater than or equal to the first preset threshold, after the download of the downloading segment of the media file is completed, a media file with a code rate corresponding to the instant speed is selected for download according to a pre-stored media configuration file.
  16. 如权利要求11-13任意一项所述的终端,其特征在于,若所述网络的网络速度发生陡升或陡降,所述根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载,包括:The terminal according to any one of claims 11-13, wherein if the network speed of the network rises sharply or drops sharply, the bit rate selected according to the pre-stored media configuration file corresponds to the instant speed Media files for download, including:
    若所述网络的网络速度发生陡升或陡降,则获取预设时间段内网络速度发生陡升与发生陡降之间的时间间隔;If the network speed of the network rises or drops steeply, the time interval between the steep rise and the steep drop of the network speed within the preset time period is acquired;
    若所述时间间隔小于第二预设阈值的次数小于预设次数,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载;If the number of times the time interval is less than the second preset threshold is less than the preset number of times, selecting a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
    若所述时间间隔小于第二预设阈值的次数大于或等于所述预设次数,则在网络速度发生陡升时,保持当前码率的媒体文件的下载。If the number of times that the time interval is less than the second preset threshold is greater than or equal to the preset number of times, the download of the media file of the current bit rate is maintained when the network speed rises sharply.
  17. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:A computer-readable storage medium that stores computer-readable instructions, wherein the computer-readable instructions are executed by at least one processor to implement the following steps:
    获取网络的即时速度和平均速度;Get the real-time speed and average speed of the network;
    根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降;Judging whether the network speed of the network has a steep rise or fall according to the instant speed and the average speed;
    若所述网络的网络速度发生陡升或陡降,则根据预先存储的媒体配置文件选择码率与所述即时速度对应的媒体文件进行下载。If the network speed of the network rises or drops steeply, the media file with the code rate corresponding to the instant speed is selected for download according to the pre-stored media configuration file.
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述获取网络的即时速度和平均速度包括:17. The computer-readable storage medium of claim 17, wherein said acquiring the instantaneous speed and average speed of the network comprises:
    获取最新下载的m个数据包中每个数据包的字节数和下载时间,以及获取最新下载的n个数据包的总字节数和总下载时间;n和m为大于等于1的整数,且n大于m;Get the number of bytes and download time of each data packet in the latest downloaded m data packets, and get the total number of bytes and total download time of the latest n data packets downloaded; n and m are integers greater than or equal to 1, And n is greater than m;
    利用所述m个数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度;利用所述n个数据包的总字节数和总下载时间计算得到所述网络的平均速度。The m instantaneous speeds of the network are calculated using the number of bytes of each data packet in the m data packets and the download time; the total number of bytes of the n data packets and the total download time are used to calculate the total speed State the average speed of the network.
  19. 如权利要求18所述的计算机可读存储介质,其特征在于,所述利用所述m个The computer-readable storage medium of claim 18, wherein the use of the m
    数据包中的每个数据包的字节数和下载时间计算得到所述网络的m个即时速度包括:The number of bytes of each data packet in the data packet and the download time calculate the m instantaneous speeds of the network including:
    利用所述m个数据包中最后完成下载的一个数据包的字节数和下载时间计算得到所述网络的第一个即时速度,利用所述m个数据包中最后完成下载的两个数据包的总字节数和总下载时间计算得到所述网络的第二个即时速度,依次类推,直至得到所述网络的第m个即时速度;Calculate the first instant speed of the network by using the byte count and download time of the last downloaded data packet among the m data packets, and use the last two data packets downloaded in the m data packets The total number of bytes and the total download time are calculated to obtain the second instantaneous speed of the network, and so on, until the mth instantaneous speed of the network is obtained;
    或者,or,
    利用所述m个数据包中的每个数据包的字节数和下载时间分别计算得到所述网络的一个即时速度,总共得到所述网络的m个即时速度。The number of bytes and the download time of each data packet in the m data packets are respectively calculated to obtain an instant speed of the network, and a total of m instant speeds of the network are obtained.
  20. 如权利要求17-19任意一项所述的计算机可读存储介质,其特征在于,所述根据所述即时速度和平均速度判断所述网络的网络速度是否发生陡升或陡降,包括:22. The computer-readable storage medium according to any one of claims 17-19, wherein the judging whether the network speed of the network has a steep rise or fall according to the instantaneous speed and the average speed comprises:
    若所述网络的m个即时速度均大于第一倍数的所述平均速度,则确定所述网络的网络速度发生陡升;If the m instantaneous speeds of the network are all greater than the average speed of the first multiple, it is determined that the network speed of the network has risen sharply;
    若所述网络的m个即时速度均小于第二倍数的所述平均速度,则确定所述网络的网络速度发生陡降。If the m instantaneous speeds of the network are all less than the second multiple of the average speed, it is determined that the network speed of the network drops sharply.
PCT/CN2019/118543 2019-05-28 2019-11-14 Media file downloading method and apparatus, and terminal and medium WO2020238065A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910461908.5A CN110121100B (en) 2019-05-28 2019-05-28 Method, device, terminal and computer readable storage medium for downloading media file
CN201910461908.5 2019-05-28

Publications (1)

Publication Number Publication Date
WO2020238065A1 true WO2020238065A1 (en) 2020-12-03

Family

ID=67523442

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118543 WO2020238065A1 (en) 2019-05-28 2019-11-14 Media file downloading method and apparatus, and terminal and medium

Country Status (2)

Country Link
CN (1) CN110121100B (en)
WO (1) WO2020238065A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115421649A (en) * 2022-08-02 2022-12-02 佳源科技股份有限公司 Indexable and extensible parameter file fragment storage system and method

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111510777B (en) 2019-01-30 2021-11-23 上海哔哩哔哩科技有限公司 Method and device for measuring network speed, computer equipment and readable storage medium
CN110121100B (en) * 2019-05-28 2022-03-15 平安科技(深圳)有限公司 Method, device, terminal and computer readable storage medium for downloading media file
CN110719535B (en) * 2019-09-02 2021-09-14 北方工业大学 Adaptive equalization adjustment method for downlink video stream code rate at video source end
CN110868626B (en) * 2019-11-06 2021-06-11 北京达佳互联信息技术有限公司 Method and device for preloading content data
CN111757181B (en) * 2020-06-29 2022-07-29 海信电子科技(武汉)有限公司 Method for reducing network media definition jitter and display device
CN112565833A (en) * 2020-11-26 2021-03-26 的卢技术有限公司 HLS-based multimedia adaptive play control method
CN113852866B (en) * 2021-09-16 2022-08-02 珠海格力电器股份有限公司 Media stream processing method, device and system
CN114363674B (en) * 2021-12-09 2024-02-09 北京快乐茄信息技术有限公司 Video playing method, device, terminal and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104010232A (en) * 2014-05-23 2014-08-27 惠州Tcl移动通信有限公司 Method and system for intelligently playing online videos, player and mobile terminal
CN106210929A (en) * 2016-07-13 2016-12-07 诚迈科技(南京)股份有限公司 Network flow download terminal based on HLS client and optimization method
CN106878828A (en) * 2017-02-21 2017-06-20 微鲸科技有限公司 The method and device of automatic switchover multimedia code check
US20180054470A1 (en) * 2015-03-20 2018-02-22 Huawei Technologies Co., Ltd. Streaming media resource downloading method and apparatus, and terminal device
CN110121100A (en) * 2019-05-28 2019-08-13 平安科技(深圳)有限公司 Method for down loading, device, terminal and the computer readable storage medium of media file

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106686036A (en) * 2015-11-10 2017-05-17 中兴通讯股份有限公司 Multimedia data downloading method and system, client and server
CN107438202A (en) * 2016-05-26 2017-12-05 中兴通讯股份有限公司 A kind of method and device for realizing code check switching
CN106803968B (en) * 2016-12-23 2020-04-17 伟乐视讯科技股份有限公司 Method for adaptively adjusting video resolution based on bandwidth of HLS protocol
CN107995220A (en) * 2017-12-25 2018-05-04 张秀娟 A kind of method of hls switchings resolution ratio
CN109379632B (en) * 2018-10-25 2020-02-14 中国地质大学(武汉) Code rate gradual switching method and system for dynamic self-adaptive HTTP (hyper text transport protocol) stream

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104010232A (en) * 2014-05-23 2014-08-27 惠州Tcl移动通信有限公司 Method and system for intelligently playing online videos, player and mobile terminal
US20180054470A1 (en) * 2015-03-20 2018-02-22 Huawei Technologies Co., Ltd. Streaming media resource downloading method and apparatus, and terminal device
CN106210929A (en) * 2016-07-13 2016-12-07 诚迈科技(南京)股份有限公司 Network flow download terminal based on HLS client and optimization method
CN106878828A (en) * 2017-02-21 2017-06-20 微鲸科技有限公司 The method and device of automatic switchover multimedia code check
CN110121100A (en) * 2019-05-28 2019-08-13 平安科技(深圳)有限公司 Method for down loading, device, terminal and the computer readable storage medium of media file

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115421649A (en) * 2022-08-02 2022-12-02 佳源科技股份有限公司 Indexable and extensible parameter file fragment storage system and method
CN115421649B (en) * 2022-08-02 2023-10-20 佳源科技股份有限公司 Indexable and extensible parameter file slicing storage system and method

Also Published As

Publication number Publication date
CN110121100B (en) 2022-03-15
CN110121100A (en) 2019-08-13

Similar Documents

Publication Publication Date Title
WO2020238065A1 (en) Media file downloading method and apparatus, and terminal and medium
US10305947B2 (en) Pre-buffering audio streams
WO2022057391A1 (en) Cache memory adjustment method, apparatus, and computer device
CN110430457B (en) Method and device for playing different-end audio and video and audio playing system
US8473630B1 (en) Adaptive video streaming using time-to-offset mapping
CN109753207B (en) Information processing method and device and storage medium
CN109600437B (en) Downloading method of streaming media resource and cache server
WO2020155959A1 (en) Definition switching method and apparatus, computer device, and readable storage medium
WO2017045528A1 (en) Method, device and system for multicast transmission
US11233885B2 (en) Efficient capture and streaming of data packets
US11374843B2 (en) Method for measuring network speed, computing device, and computer-program product
WO2022105798A1 (en) Video processing method and apparatus, and storage medium
EP3253065B1 (en) Streaming media resource downloading method and apparatus, and terminal device
US10404828B2 (en) Streaming apparatus, streaming method, and streaming service system using the streaming apparatus
WO2017080428A1 (en) Streaming media channel recording, reviewing method, device, server and storage medium
EP3142381A1 (en) Network video playing method and device
TW201428503A (en) Method and system for managing cache files
US20210320957A1 (en) Method of requesting video, computing device, and computer-program product
BR112012030152B1 (en) method and system for determining a system delay factor
WO2020155956A1 (en) First-frame equalization current-limiting method and apparatus, computer device and readable storage medium
CN111405370B (en) Video playback method and device
WO2020155962A1 (en) Definition switching algorithm selection method and system, and device and medium
CN104506631A (en) Audio file cache method and audio file cache equipment
WO2020098455A1 (en) Method for real-time delivery of media stream and server
WO2023083213A1 (en) Data decoding method and apparatus, electronic device and readable storage medium

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: 19930892

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19930892

Country of ref document: EP

Kind code of ref document: A1

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 1205A DATED 04/05/2022)