CN110121100B - Method, device, terminal and computer readable storage medium for downloading media file - Google Patents

Method, device, terminal and computer readable storage medium for downloading media file Download PDF

Info

Publication number
CN110121100B
CN110121100B CN201910461908.5A CN201910461908A CN110121100B CN 110121100 B CN110121100 B CN 110121100B CN 201910461908 A CN201910461908 A CN 201910461908A CN 110121100 B CN110121100 B CN 110121100B
Authority
CN
China
Prior art keywords
network
speed
downloading
instant
media file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910461908.5A
Other languages
Chinese (zh)
Other versions
CN110121100A (en
Inventor
马潜
许可
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910461908.5A priority Critical patent/CN110121100B/en
Publication of CN110121100A publication Critical patent/CN110121100A/en
Priority to PCT/CN2019/118543 priority patent/WO2020238065A1/en
Application granted granted Critical
Publication of CN110121100B publication Critical patent/CN110121100B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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 encoded video stream 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Communication Control (AREA)

Abstract

The invention belongs to the technical field of computers, and particularly relates to a method, a device, a terminal and a computer readable storage medium for downloading a media file, wherein the method comprises the following steps: acquiring the instant speed and the average speed of a network; judging whether the network speed of the network is increased or decreased steeply according to the instant speed and the average speed; if the network speed of the network rises or drops steeply, the media file corresponding to the code rate and the instant speed is selected according to the pre-stored media configuration file for downloading, and the problem that when the network speed fluctuates greatly, a user terminal cannot switch to downloading of the media file corresponding to the changed code rate and the changed network speed in time, so that audio and video playing is blocked or the time for entering the optimal playing state is long is solved.

Description

Method, device, terminal and computer readable storage medium for downloading media file
Technical Field
The present invention belongs to the field of computer technologies, and in particular, to a method, an apparatus, a terminal, and a computer-readable storage medium for downloading a media file.
Background
When media files such as audio or video are downloaded on the network by using a streaming transmission technology, the audio files or the video files are continuously transmitted to the terminal in real time by the server, a user does not need to wait until the whole media files are completely downloaded to play the media, and the media can be played only after the start delay of several seconds or tens of seconds, so that the start delay is effectively shortened, and the cache capacity of the terminal is saved.
For the same audio/video program, the server generally provides a plurality of media files with different qualities to adapt to downloading and playing under different network conditions. Each media file corresponds to a code rate, each media file comprises a plurality of fragments, one fragment is divided into a plurality of data packets, and after the data packets corresponding to each fragment are downloaded by the terminal, audio and video playing is carried out by taking the fragment as a basic playing unit.
When the terminal downloads the fragments, the network speed of the network is generally calculated, and the media file with the code rate corresponding to the network speed of the network is selected for downloading. However, based on the current streaming media transmission protocol, when the network speed fluctuates greatly, the terminal generally cannot switch to downloading of the media file with the code rate corresponding to the changed network speed in time, which causes a problem that the audio and video playing of the terminal is easy to be blocked or the time for entering the optimal playing state is long.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a terminal and a computer-readable storage medium for downloading a media file, which can solve the technical problem that when a network speed fluctuates greatly, the terminal cannot switch to downloading of the media file with a code rate corresponding to the changed network speed in time, which causes a pause in audio/video playing or a long time for entering an optimal playing state.
A first aspect of an embodiment of the present invention provides a method for downloading a media file, including:
acquiring the instant speed and the average speed of a network;
judging whether the network speed of the network is increased or decreased steeply according to the instant speed and the average speed;
and if the network speed of the network is increased or decreased steeply, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download.
A second aspect of the embodiments of the present invention provides a device for downloading a media file, including:
the acquisition unit is used for acquiring the instant speed and the average speed of the network;
the judging unit is used for judging whether the network speed of the network is steeply increased or steeply decreased according to the instant speed and the average speed;
and the downloading unit is used for selecting the media file with the code rate corresponding to the instant speed according to a pre-stored media configuration file to download if the network speed of the network is increased or decreased steeply.
A third aspect of the embodiments of the present invention provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method when executing the computer program.
A fourth aspect of the embodiments of the present invention provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the above method.
In the embodiment of the invention, the terminal judges whether the network speed of the network is steeply increased or steeply decreased by acquiring the instant speed and the average speed of the network and according to the instant speed and the average speed, rather than simply determining whether the network speed of the network is rising or falling sharply based on the average speed, and therefore, when the network speed of the network rises or falls steeply, the media file with the code rate corresponding to the instant speed can be selected in time according to the pre-stored media configuration file for downloading, and the changed network speed can be measured without downloading at least one fragmented data packet after the network speed of the network rises or falls steeply, so that the problem that the terminal cannot switch to the downloading of the media file with the code rate corresponding to the changed network speed in time, so that the audio and video playing is blocked or the time for entering the optimal playing state is longer is avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments or the prior art will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and that for a person skilled in the art, other relevant drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic flow chart illustrating an implementation process of a method for downloading a media file according to an embodiment of the present invention;
fig. 2 is a schematic flowchart illustrating a specific implementation flow of step 101 of a method for downloading a media file according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a specific implementation of calculating a current instantaneous speed of a network according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a downloaded data packet by a terminal according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating a specific implementation of step 102 of a method for downloading a media file according to an embodiment of the present invention;
fig. 6 is a flowchart illustrating a first specific implementation of step 103 of a method for downloading a media file according to an embodiment of the present invention;
fig. 7 is a flowchart illustrating a second specific implementation of step 103 of a method for downloading a media file according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of a device for downloading a media file according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
When media files such as audio or video are downloaded on the network by using a Streaming transport technology (HTTP Live Streaming, HLS), an HLS client first receives a configuration file in an m3u8 format sent by an audio/video server, then calculates a network speed of the network, and selects a media file with a corresponding bandwidth (code rate) to download according to the network speed, so that the terminal can smoothly play audio/video.
However, in the current method for calculating the network speed of the network, the calculation is performed by dividing the download time by the number of bytes of 50 data packets downloaded. Generally, one fragment is less than 50 data packets, and therefore, when the network speed fluctuates greatly, data of at least one fragment needs to be downloaded after the network speed fluctuates greatly to calculate the accurate network speed, so that the terminal cannot switch to downloading of a media file with a code rate corresponding to the changed network speed in time, and the problem that the audio and video playing of the terminal is easy to be blocked or the time for entering the optimal playing state is long is caused.
For example, the network speed corresponding to each of 50 data packets downloaded before the network speed fluctuates greatly is 350KBps, that is, the network speed is stabilized at 350KBps, after the network speed fluctuates greatly, the network speed corresponding to the first downloaded data packet is 140KBps, the network speed corresponding to the second downloaded data packet is 160KBps, the network speed corresponding to the third downloaded data packet is 150KBps, the average speed of the three data packets is 150KBps, which is about 0.42 times of 350KBps, that is, at this time, the network speed has fluctuated greatly. However, if the network speed is continuously calculated by dividing the number of bytes of the downloaded 50 packets by the total download time, the calculated network speed is (350KBps × 47+140KBps + 160KBps +150KBps)/50 — 338KBps, however, the 338KBps cannot judge that the network speed fluctuates greatly compared with 350KBps, and therefore, it is necessary to download at least one fragmented packet after the network speed fluctuates greatly to measure the changed network speed, which causes the terminal not to switch to the downloading of the media file with the code rate corresponding to the changed network speed in time, and causes the problem that the audio/video playing of the terminal is easy to be jammed or the time for entering the optimal playing state is long.
In the embodiment of the invention, the terminal judges whether the network speed of the network is steeply increased or steeply decreased by acquiring the instant speed and the average speed of the network and according to the instant speed and the average speed, rather than simply determining whether the network speed of the network is ramping up or down based on the average speed, and therefore, when the network speed of the network rises or falls steeply, the media file with the code rate corresponding to the instant speed can be selected in time according to the pre-stored media configuration file for downloading, and the changed network speed can be measured without downloading at least one fragmented data packet after the network speed of the network rises or falls steeply, so that the problem that the terminal cannot switch to the downloading of the media file with the code rate corresponding to the changed network speed in time, so that the audio and video playing is blocked or the time for entering the optimal playing state is longer is solved.
Fig. 1 shows a schematic flow chart of an implementation of a method for downloading a media file according to an embodiment of the present invention, which includes steps 101 to 103.
Step 101, obtaining the instantaneous speed and the average speed of the network.
When the HLS client is used for playing audio and video, the terminal firstly receives and stores a configuration file in an m3u8 format sent by an audio and video server, then acquires the network speed of the terminal when media files such as audio or video are downloaded on the network by using a streaming transmission technology, and selects the media file with the corresponding code rate to download according to the network speed, so that the terminal can smoothly play the audio and video.
In the embodiment of the invention, the step of acquiring the network speed of the terminal comprises the step of acquiring the instant speed and the average speed of the network.
Optionally, as shown in fig. 2, the obtaining of the instantaneous speed and the average speed of the network may include: step 201 to step 202.
Step 201, acquiring byte number and downloading time of each data packet in m data packets downloaded latest, and acquiring total byte number and total downloading time of n data packets downloaded latest; n and m are integers of 1 or more, and n is greater than m.
Step 202, calculating m instant speeds of the network by using the byte number and the downloading time of each data packet in the m data packets; and calculating the average speed of the network by using the total byte number and the total downloading time of the n data packets.
The values of n and m can be taken according to the actual application scene, and the invention is not limited to this, and only n and m need to be ensured to be integers greater than or equal to 1, and n is greater than m.
For example, the value of n may be 50, and the value of m may be 3, so that after the number of bytes and the download time of each of the 50 newly downloaded data packets are obtained, and the total number of bytes and the total download time of the 3 newly downloaded data packets are obtained, 3 instant speeds of the network may be calculated by using the number of bytes and the download time of each of the 3 data packets; and calculating the average speed of the network by using the total byte number and the total download time of the 50 data packets.
As shown in fig. 3, in step 202, the calculating m instant speeds of the network by using the byte number and the download time of each of the m data packets may specifically include: step 301 or step 302.
Step 301, calculating to obtain a first instant speed of the network by using the byte number and the downloading time of the last downloaded data packet of the m data packets, calculating to obtain a second instant speed of the network by using the total byte number and the total downloading time of the last downloaded two data packets of the m data packets, and so on until obtaining the mth instant speed of the network.
For example, as shown in fig. 4, packet 1, packet 2 and packet 3 are three packets that are downloaded continuously, and packet 1 is a last packet that is downloaded completely, in this embodiment, the first instantaneous speed of the network is obtained by dividing the number of bytes of packet 1 by the download time; dividing the total byte number of the data packet 1 and the data packet 2 by the download time of the data packet 1 and the data packet 2 to obtain a second instant speed of the network; the third instantaneous speed of the network is obtained by dividing the total number of bytes of the data packet 1, the data packet 2 and the data packet 3 by the download time of the three, and the instantaneous speeds of 3 networks are obtained in total.
Step 302, respectively calculating an instant speed of the network by using the byte number and the downloading time of each data packet in the m data packets, and obtaining m instant speeds of the network in total.
For example, as shown in fig. 4, packet 1, packet 2 and packet 3 are three newly downloaded packets, and packet 1 is a last packet that completes downloading, in this embodiment, the first instant speed of the network is obtained by dividing the number of bytes of packet 1 by the downloading time; dividing the number of bytes of the data packet 2 by the downloading time to obtain a second instant speed of the network; the third instant speed of the network is obtained by dividing the number of bytes of the packet 3 by the download time thereof, and 3 instant speeds of the network are obtained in total.
And 102, judging whether the network speed of the network is increased or decreased steeply according to the instant speed and the average speed.
After the instant speed and the average speed of the network are obtained, whether the network speed of the network rises or drops steeply can be judged according to the instant speed and the average speed.
Optionally, as shown in fig. 5, the determining whether the network speed of the network is steep up or steep down according to the instantaneous speed and the average speed may include: step 501 to step 502.
Step 501, if m instant speeds of the network are all larger than the average speed of a first multiple, determining that the network speed of the network rises steeply.
Step 502, if the m instantaneous speeds of the network are all less than the average speed of the second multiple, determining that the network speed of the network drops steeply.
Since the average speed is calculated according to more data packets, the speed level of the whole network can be reflected, and the instant speed of the network is calculated according to less data packets, the latest speed change condition of the network can be reflected, therefore, whether the network speed of the network is steeply increased or steeply decreased can be reasonably judged by comparing the instant speed with the average speed.
In the embodiment of the present invention, values of the first multiple and the second multiple may be set according to an actual application scenario, which is not limited in the present invention. For example, the first multiple is 2 to 5, and the second multiple is 0.7 to 0.1.
In the embodiment of the invention, the network speed is determined to rise steeply when m instant speeds of the network are all larger than the average speed of the first multiple by comparing the m instant speeds of the network with the average speed of the first multiple and/or the average speed of the second multiple; when the m instant speeds of the network are all smaller than the average speed of the second multiple, the network speed of the network is determined to be steeply reduced, so that the judgment on whether the network speed of the network is steeply increased or steeply reduced can be more accurate.
In some embodiments of the present invention, the determining whether the network speed of the network has a steep rise or a steep fall according to the instantaneous speed and the average speed may further include: if the preset number of the m instant speeds of the network are all larger than the average speed of a first multiple, determining that the network speed rises steeply; and if the preset number of the m instant speeds of the network are all smaller than the average speed of the second multiple, determining that the network speed is suddenly reduced. The preset number may be m greater than a set multiple, for example, the set multiple may be 0.9, 0.85, or 0.8.
That is, when determining whether the network speed of the network is rising or falling according to the instant speed and the average speed, it may be determined that the network speed is rising or falling without the m instant speeds of the network all being greater than a first multiple or less than a second multiple of the average speed, and it may be determined that the network speed is rising or falling only by the average speed of a part of the m instant speeds of the network being greater than the first multiple or less than the second multiple of the average speed, so that there is a certain redundancy in determining whether the network speed is rising or falling.
And 103, if the network speed of the network is increased or decreased steeply, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file to download.
The pre-stored media configuration file stores audio and video stream information, which may include: the corresponding relation between the code rate and the media file, and the content type information of the media file.
For example, the correspondence 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: 40 Kbps; there are audio stream, no video stream, 1 JPEG picture;
audio-video stream 01: 120 Kbps; there is an audio stream, there is a video stream (video stream resolution 176x 144);
audio and video stream 02: 300 Kbps; there is an audio stream, there is a video stream (video stream resolution 320x 180);
audio and video stream 03: 500 Kbps; there is an audio stream, there is a video stream (video stream resolution 400x 224);
audio and video stream 04: 800 Kbps; there is an audio stream, there is a video stream (video stream resolution 480x 270);
audio and video stream 05: 1300 Kbps; there is an audio stream, there is a video stream (video stream resolution 640x 360);
audio and video stream 06: 2200 Kbps; there is an audio stream and there is a video stream (video stream resolution 1024x 576).
In the embodiment of the invention, when the network speed of the network is judged to be steeply increased or steeply decreased, the media file with the code rate corresponding to the instant speed can be selected according to the pre-stored media configuration file for downloading, so that the problem that the terminal cannot be switched to download the media file with the code rate corresponding to the changed network speed in time when the network speed is greatly fluctuated, so that the audio and video playing is blocked or the time for entering the optimal playing state is longer is solved.
When the number of the instant speeds is greater than 2, the selecting, according to a pre-stored media configuration file, a media file with a code rate corresponding to the instant speed for downloading comprises: and selecting a media file with a code rate corresponding to the average speed of the instant speed according to a pre-stored media configuration file for downloading.
For example, the currently played audio/video stream is 300KBps audio/video stream 02, the average speed of the network is 350KBps, the second multiple is 0.5, and the calculated average speed of 3 instant speeds is 150KBps, wherein the first instant speed is 150 KBps; the second instantaneous speed is 160 KBps; the third instant speed is 140 KBps; it can be determined that a steep drop in network speed occurs because the 3 instantaneous speeds of the network are each less than the second multiple of the average speed. At this time, the media file audio/video stream 01 with the code rate corresponding to the average speed of the instant speed of 150KBps can be selected according to the pre-stored media configuration file for downloading. That is to say, the downloading of the media file with the code rate corresponding to the changed network speed can be switched to in time from the fourth data packet after the network speed of the network is greatly changed, so that the problem that the audio and video playing of the terminal is easy to be blocked or enters the optimal playing state for a long time is avoided.
For example, as shown in table one, it can be seen through tests that when the audio/video file is downloaded by using the method for downloading audio/video stream of the present invention, the time for audio/video playing to be stuck can be effectively reduced, the time for audio/video playing to enter the optimal playing state can be effectively shortened, and the problem that the audio/video playing of the terminal is easy to be stuck or the time for audio/video playing to enter the optimal playing state is long is avoided.
Table one:
Figure BDA0002074856630000101
optionally, in some embodiments of the present invention, as shown in fig. 6, in step 103, if the network speed of the network rises steeply, the selecting, according to the pre-stored media configuration file, the media file with the bitrate corresponding to the instant speed for downloading may include: step 601 to step 603.
Step 601, if the network speed of the network rises steeply, determining whether the downloaded proportion of the fragments of the media file being downloaded is greater than a first preset threshold value.
Step 602, if the bit rate is smaller than the first preset threshold, directly selecting a media file with a bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading.
Step 603, if the value is greater than or equal to the first preset threshold, after the downloading of the fragments of the media file being downloaded is completed, selecting the media file with the code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading.
When the audio and video stream is downloaded, the fragments are used as the most basic playing unit, and only two choices are available for one fragment: either completely downloaded and played or not downloaded or discarded after a portion is downloaded. Therefore, when the network speed of the network rises steeply and the downloading of the audio/video stream with higher code rate needs to be switched, whether the completed proportion of the fragments of the media file which is being downloaded is larger than a preset threshold value or not can be judged firstly, if so, the downloading of the audio/video stream with higher code rate is switched to after the downloading of the fragments of the media file which is being downloaded is completed, so that the phenomenon that the fragments which are not downloaded are discarded and the audio/video stream is blocked due to the switching to the downloading of the audio/video stream with higher code rate under the condition of insufficient cache is avoided.
The value of the first preset threshold may be determined according to an actual application scenario, which is not limited in the present invention. For example, the first preset threshold may be 95% or 90%.
Optionally, in some embodiments of the present invention, as shown in fig. 7, when the network speed fluctuation frequency is large, in order to avoid too frequent switching of the audio/video stream, in step 103, if the network speed of the network is increased or decreased steeply, the selecting, according to the pre-stored media profile, the media file with the bitrate corresponding to the instant speed for downloading may further include: step 701 to step 703.
And 701, if the network speed of the network rises steeply or drops steeply, acquiring a time interval between the steep rise and the steep drop of the network speed in a preset time period.
Step 702, if the time interval is smaller than the second preset threshold for less than a preset number, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading.
And 703, if the time interval is less than the second preset threshold for more than or equal to the preset times, keeping downloading of the media file with the current code rate when the network speed is steep.
For example, the preset time period is 2 minutes, and if the network speed of the network rises and falls steeply for 5 times continuously within 2 minutes, it indicates that the network speed of the network is poor in stability, and the downloading of the media file with the current bitrate needs to be maintained when the network speed rises steeply, so as to avoid frequent switching of audio and video streams, which causes video playing to be blocked.
As shown in fig. 8, an embodiment of the present invention provides an apparatus 800 for downloading a media file, including:
an obtaining unit 801 is used for obtaining the instantaneous speed and the average speed of the network.
A determining unit 802, configured to determine whether a network speed of the network is steep-rising or steep-falling according to the instant speed and the average speed.
A downloading unit 803, configured to select, according to a pre-stored media configuration file, a media file with a code rate corresponding to the instant speed for downloading if the network speed of the network rises or falls abruptly.
Optionally, the obtaining unit 801 is further specifically configured to:
acquiring the byte number and the downloading time of each data packet in m data packets downloaded latest, and acquiring the total byte number and the total downloading time of n data packets downloaded latest; n and m are integers greater than or equal to 1, and n is greater than m;
calculating m instant speeds of the network by using the byte number and the downloading time of each data packet in the m data packets; and calculating the average speed of the network by using the total byte number and the total downloading time of the n data packets.
Optionally, the obtaining unit 801 is further specifically configured to:
calculating to obtain a first instant speed of the network by using the byte number and the downloading time of one data packet which is downloaded last in the m data packets, calculating to obtain a second instant speed of the network by using the total byte number and the total downloading time of two data packets which are downloaded last in the m data packets, and repeating the steps until the mth instant speed of the network is obtained;
or,
and respectively calculating an instant speed of the network by using the byte number and the downloading time of each data packet in the m data packets, and obtaining m instant speeds of the network in total.
Optionally, the determining unit 802 is further specifically configured to:
if m instant speeds of the network are all larger than the average speed of a first multiple, determining that the network speed of the network rises steeply;
and if the m instant speeds of the network are all smaller than the average speed of the second multiple, determining that the network speed of the network drops steeply.
Optionally, the downloading unit 803 is further specifically configured to:
if the network speed of the network rises steeply, judging whether the downloaded proportion of the fragments of the media file is larger than a first preset threshold value or not;
if the bit rate is smaller than the first preset threshold value, directly selecting a media file with the bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
if the bit rate is larger than or equal to the first preset threshold, after the fragment downloading of the media file is finished, selecting the media file with the bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading.
Optionally, the downloading unit 803 is further specifically configured to:
if the network speed of the network is steeply increased or steeply decreased, acquiring a time interval between the steep increase and the steep decrease of the network speed in a preset time period;
if the time interval is smaller than the second preset threshold for times smaller than the preset times, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
and if the time interval is smaller than the second preset threshold for more than or equal to the preset times, the downloading of the media file with the current code rate is kept when the network speed is steep.
It should be noted that, for convenience and simplicity of description, the specific working process of the above-described downloading apparatus 800 for media files may refer to the corresponding process of the method described in fig. 1 and fig. 7, and is not described herein again.
Fig. 9 is a schematic diagram of a terminal according to an embodiment of the present invention. As shown in fig. 9, the terminal 8 includes: a processor 90, a memory 91 and a computer program 92, such as a download program for media files, stored in said memory 91 and operable on said processor 90. The processor 90, when executing the computer program 92, implements the steps in the above-described embodiments of the method for downloading each media file, such as the steps 101 to 103 shown in fig. 1. Alternatively, the processor 90, when executing the computer program 92, implements the functions of each module/unit in each device embodiment described above, for example, the functions of the modules 801 to 803 shown in fig. 8.
The computer program may be divided into one or more modules/units, which are stored in the memory 91 and executed by the processor 90 to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program in the terminal. For example, the computer program may be divided into an acquisition unit, a judgment unit and a download unit, and each unit functions as follows: the acquisition unit is used for acquiring the instant speed and the average speed of the network; the judging unit is used for judging whether the network speed of the network is steeply increased or steeply decreased according to the instant speed and the average speed; and the downloading unit is used for selecting the media file with the code rate corresponding to the instant speed according to a pre-stored media configuration file to download if the network speed of the network is increased or decreased steeply.
The terminal can be a mobile terminal such as a smart phone or a computing device such as a desktop computer, a notebook, a palm computer and a cloud server. The terminal may include, but is not limited to, a processor 90, a memory 91. Those skilled in the art will appreciate that fig. 9 is only an example of a terminal and is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or different components, e.g., the terminal may also include input-output devices, network access devices, buses, etc.
The Processor 90 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may 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 a memory of the terminal. The memory 91 may also be an external storage device of the terminal, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal. Further, the memory 91 may also include both an internal storage unit and an external storage device of the terminal. The memory 91 is used for storing the computer program and other programs and data required by the terminal. The memory 91 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal and method may be implemented in other ways. For example, the above-described apparatus/terminal embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (9)

1. A method for downloading a media file, comprising:
acquiring the instant speed and the average speed of a network;
judging whether the network speed of the network is increased or decreased steeply according to the instant speed and the average speed;
if the network speed of the network is increased or decreased steeply, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading, wherein the method comprises the following steps: if the network speed of the network rises steeply, judging whether the downloaded proportion of the fragments of the media file is larger than a first preset threshold value or not; if the bit rate is smaller than the first preset threshold value, directly selecting a media file with the bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading; if the bit rate is larger than or equal to the first preset threshold, after the fragment downloading of the media file is completed, the media file with the bit rate corresponding to the instant speed is selected according to a pre-stored media configuration file to be downloaded, and the bit rate switching is avoided under the condition of insufficient cache.
2. The downloading method of claim 1, wherein the obtaining the instantaneous speed and the average speed of the network comprises:
acquiring the byte number and the downloading time of each data packet in m data packets downloaded latest, and acquiring the total byte number and the total downloading time of n data packets downloaded latest; n and m are integers greater than or equal to 1, and n is greater than m;
calculating m instant speeds of the network by using the byte number and the downloading time of each data packet in the m data packets; and calculating the average speed of the network by using the total byte number and the total downloading time of the n data packets.
3. The downloading method of claim 2, wherein said calculating m instantaneous speeds of the network using the number of bytes and the download time of each of the m packets comprises:
calculating to obtain a first instant speed of the network by using the byte number and the downloading time of one data packet which is downloaded last in the m data packets, calculating to obtain a second instant speed of the network by using the total byte number and the total downloading time of two data packets which are downloaded last in the m data packets, and repeating the steps until the mth instant speed of the network is obtained;
or,
and respectively calculating an instant speed of the network by using the byte number and the downloading time of each data packet in the m data packets, and obtaining m instant speeds of the network in total.
4. The downloading method according to any one of claims 1-3, wherein the determining whether the network speed of the network is steep or steep according to the instant speed and the average speed comprises:
if m instant speeds of the network are all larger than the average speed of a first multiple, determining that the network speed of the network rises steeply;
and if the m instant speeds of the network are all smaller than the average speed of the second multiple, determining that the network speed of the network drops steeply.
5. The downloading method according to any one of claims 1-3, wherein if the network speed of the network is rising or falling sharply, the selecting the media file with the bitrate corresponding to the instant speed according to the pre-stored media profile for downloading comprises:
if the network speed of the network is steeply increased or steeply decreased, acquiring a time interval between the steep increase and the steep decrease of the network speed in a preset time period;
if the time interval is smaller than the second preset threshold for times smaller than the preset times, selecting a media file with a code rate corresponding to the instant speed according to a pre-stored media configuration file for downloading;
and if the time interval is smaller than the second preset threshold for more than or equal to the preset times, the downloading of the media file with the current code rate is kept when the network speed is steep.
6. An apparatus for downloading a media file, comprising:
the acquisition unit is used for acquiring the instant speed and the average speed of the network;
the judging unit is used for judging whether the network speed of the network is steeply increased or steeply decreased according to the instant speed and the average speed;
a downloading unit, configured to select, according to a pre-stored media configuration file, a media file with a code rate corresponding to the instant speed for downloading if the network speed of the network is increased or decreased steeply, including: if the network speed of the network rises steeply, judging whether the downloaded proportion of the fragments of the media file is larger than a first preset threshold value or not; if the bit rate is smaller than the first preset threshold value, directly selecting a media file with the bit rate corresponding to the instant speed according to a pre-stored media configuration file for downloading; if the bit rate is larger than or equal to the first preset threshold, after the fragment downloading of the media file is completed, the media file with the bit rate corresponding to the instant speed is selected according to a pre-stored media configuration file to be downloaded, and the bit rate switching is avoided under the condition of insufficient cache.
7. The downloading apparatus of claim 6, wherein the obtaining unit is further configured to:
acquiring the byte number and the downloading time of each data packet in m data packets downloaded latest, and acquiring the total byte number and the total downloading time of n data packets downloaded latest; n and m are integers greater than or equal to 1, and n is greater than m;
calculating m instant speeds of the network by using the byte number and the downloading time of each data packet in the m data packets; and calculating the average speed of the network by using the total byte number and the total downloading time of the n data packets.
8. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1-5 when executing the computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN201910461908.5A 2019-05-28 2019-05-28 Method, device, terminal and computer readable storage medium for downloading media file Active CN110121100B (en)

Priority Applications (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
PCT/CN2019/118543 WO2020238065A1 (en) 2019-05-28 2019-11-14 Media file downloading method and apparatus, and terminal and medium

Applications Claiming Priority (1)

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

Publications (2)

Publication Number Publication Date
CN110121100A CN110121100A (en) 2019-08-13
CN110121100B true CN110121100B (en) 2022-03-15

Family

ID=67523442

Family Applications (1)

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

Country Status (2)

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

Families Citing this family (9)

* 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
CN115421649B (en) * 2022-08-02 2023-10-20 佳源科技股份有限公司 Indexable and extensible parameter file slicing storage system and method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106210929A (en) * 2016-07-13 2016-12-07 诚迈科技(南京)股份有限公司 Network flow download terminal based on HLS client and optimization method
WO2017080450A1 (en) * 2015-11-10 2017-05-18 中兴通讯股份有限公司 Multi-media data download method, client, server, system and storage medium
CN106803968A (en) * 2016-12-23 2017-06-06 伟乐视讯科技股份有限公司 A kind of method that bandwidth self-adaption based on HLS protocol adjusts video resolution
CN107995220A (en) * 2017-12-25 2018-05-04 张秀娟 A kind of method of hls switchings resolution ratio

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104010232B (en) * 2014-05-23 2017-12-12 惠州Tcl移动通信有限公司 A kind of intelligence plays method, system, player and the mobile terminal of Online Video
EP3253065B1 (en) * 2015-03-20 2019-03-06 Huawei Technologies Co., Ltd. Streaming media resource downloading method and apparatus, and terminal device
CN107438202A (en) * 2016-05-26 2017-12-05 中兴通讯股份有限公司 A kind of method and device for realizing code check switching
CN106878828A (en) * 2017-02-21 2017-06-20 微鲸科技有限公司 The method and device of automatic switchover multimedia code check
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
CN110121100B (en) * 2019-05-28 2022-03-15 平安科技(深圳)有限公司 Method, device, terminal and computer readable storage medium for downloading media file

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017080450A1 (en) * 2015-11-10 2017-05-18 中兴通讯股份有限公司 Multi-media data download method, client, server, system and storage medium
CN106210929A (en) * 2016-07-13 2016-12-07 诚迈科技(南京)股份有限公司 Network flow download terminal based on HLS client and optimization method
CN106803968A (en) * 2016-12-23 2017-06-06 伟乐视讯科技股份有限公司 A kind of method that bandwidth self-adaption based on HLS protocol adjusts video resolution
CN107995220A (en) * 2017-12-25 2018-05-04 张秀娟 A kind of method of hls switchings resolution ratio

Also Published As

Publication number Publication date
CN110121100A (en) 2019-08-13
WO2020238065A1 (en) 2020-12-03

Similar Documents

Publication Publication Date Title
CN110121100B (en) Method, device, terminal and computer readable storage medium for downloading media file
CN105163134A (en) Video coding parameter setting method, device and video coding device for live video
ES2624910T3 (en) Client side sequence switching
CN109474854B (en) Video playing method, playlist generating method and related equipment
EP2597885A1 (en) Method and device for playing stream media video content
EP3253065B1 (en) Streaming media resource downloading method and apparatus, and terminal device
US11374843B2 (en) Method for measuring network speed, computing device, and computer-program product
CN111447447B (en) Live broadcast encoding method and device and electronic equipment
CN113453085B (en) Method and device for judging playing card pause and electronic terminal
CN106688239A (en) Video downloading method, apparatus, and system
CN109862403B (en) Adaptive code rate switching method and device, electronic equipment and storage medium
CN108881931B (en) Data buffering method and network equipment
US20150134846A1 (en) Method and apparatus for media segment request retry control
CN111510770A (en) Method and device for switching definition, computer equipment and readable storage medium
EP2963896A1 (en) Method for operating a cache arranged along a transmission path between client terminals and at least one server, and corresponding cache
CN108235149A (en) A kind of method and device for optimizing video playing fluency
CN109769125B (en) Dynamic adjustment method for streaming media code rate, media server and transcoding server
CN111510761B (en) First frame equalization current limiting method and device, computer equipment and readable storage medium
CN108494702B (en) Transmission control method and apparatus, storage medium, and electronic apparatus
CN113949874A (en) Video coding method and device and electronic equipment
CN107734360B (en) Control method and device of streaming media server
CN111491207A (en) Video data processing method and device in live broadcast and electronic equipment
CN109788326B (en) Video resource pre-pushing method, device and system
CN110933516B (en) Multimedia live broadcasting method, device and equipment
WO2023083213A1 (en) Data decoding method and apparatus, electronic device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant