CN110868643B - Method and device for determining video downloading progress - Google Patents

Method and device for determining video downloading progress Download PDF

Info

Publication number
CN110868643B
CN110868643B CN201911147254.5A CN201911147254A CN110868643B CN 110868643 B CN110868643 B CN 110868643B CN 201911147254 A CN201911147254 A CN 201911147254A CN 110868643 B CN110868643 B CN 110868643B
Authority
CN
China
Prior art keywords
video
downloading
target
downloaded
text 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
CN201911147254.5A
Other languages
Chinese (zh)
Other versions
CN110868643A (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.)
Zhengzhou Apas Technology Co ltd
Original Assignee
Zhengzhou Apas Technology 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 Zhengzhou Apas Technology Co ltd filed Critical Zhengzhou Apas Technology Co ltd
Priority to CN201911147254.5A priority Critical patent/CN110868643B/en
Publication of CN110868643A publication Critical patent/CN110868643A/en
Application granted granted Critical
Publication of CN110868643B publication Critical patent/CN110868643B/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/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
    • 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/85Assembly of content; Generation of multimedia applications
    • H04N21/854Content authoring
    • H04N21/85406Content authoring involving a specific file format, e.g. MP4 format
    • 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/85Assembly of content; Generation of multimedia applications
    • H04N21/858Linking data to content, e.g. by linking an URL to a video object, by creating a hotspot
    • H04N21/8586Linking data to content, e.g. by linking an URL to a video object, by creating a hotspot by using a URL

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a method and a device for determining video downloading progress, wherein the method comprises the following steps: acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video; analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses; determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips; and determining the downloading progress of the target video according to the progress parameter. In this way, the downloading progress of the target video can be determined through the progress parameters related to the downloading progress of the plurality of video segments of the target video, and the downloading progress does not need to be determined according to the total byte number of the target video, so that the problem that the downloading progress cannot be determined under the condition that the total byte number of the target video cannot be determined can be effectively solved.

Description

Method and device for determining video downloading progress
Technical Field
The present application relates to the field of streaming media technologies, and in particular, to a method and an apparatus for determining a video downloading progress.
Background
A video in m3u8 format (hereinafter referred to as m3u8 video) is a streaming video, and is generally composed of a text file ending in m3u8 and a plurality of video clips (TSs). The text file at the end of m3u8 usually contains download addresses of a plurality of video clips, and when m3u8 video is downloaded, each video clip can be downloaded one by one according to the download addresses until all the video clips are downloaded successfully, so that m3u8 video is obtained.
Generally, in the video downloading process, it is necessary to determine the downloading progress of the video according to the number of bytes downloaded and the total number of bytes of the video, where the total number of bytes of the video may be returned by the server after establishing a connection with the server. However, the m3u8 video contains a plurality of video segments, the video segments need to be downloaded one by one, and during the downloading process, the server usually only returns the byte number of one video segment, which results in that the total byte number of the video segments (i.e. the m3u8 video) cannot be determined, and thus the downloading progress of the m3u8 video cannot be determined.
Disclosure of Invention
The embodiment of the application provides a method and a device for determining a video downloading progress, which are used for solving the problem that the video downloading progress cannot be determined in the process of downloading a video in an m3u8 format.
In order to solve the technical problem, the present application is implemented as follows:
the embodiment of the application provides a method for determining video downloading progress, which comprises the following steps:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and determining the downloading progress of the target video according to the progress parameter.
An embodiment of the present application provides an apparatus, including:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a text file of a target video, the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video segments of the target video;
the downloading unit analyzes the text file to obtain downloading addresses of the video clips and downloads the video clips according to the downloading addresses;
the progress parameter determining unit is used for determining progress parameters related to the downloading progress of the video clips in the process of downloading the video clips;
and the downloading progress determining unit is used for determining the downloading progress of the target video according to the progress parameter.
An embodiment of the present application provides an electronic device, including:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and determining the downloading progress of the target video according to the progress parameter.
Embodiments of the present application provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and determining the downloading progress of the target video according to the progress parameter.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects:
according to the technical scheme provided by the embodiment of the application, when the target video in the m3u8 format is downloaded, the multiple video segments of the target video can be downloaded according to the download addresses of the multiple video segments of the target video, and in the downloading process, the downloading progress of the target video is determined according to the progress parameters related to the downloading progress of the multiple video segments, and the downloading progress of the target video does not need to be determined according to the total byte number of the target video, so that the problem that the downloading progress of the video cannot be determined under the condition that the total byte number of the target video cannot be determined can be effectively solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
Fig. 1 is a flowchart illustrating a method for determining a video download progress according to an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram illustrating a video downloading method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an apparatus for determining a video download progress according to an embodiment of the present application.
Detailed Description
Generally, during the downloading process of the video, the downloading progress of the video can be determined according to the total number of bytes of the video and the number of bytes downloaded. Specifically, when downloading a video, a connection needs to be established with a server providing the video, and in the case of establishing the connection, the server may return information such as the total number of bytes of the video to be downloaded. Therefore, in the video downloading process, the downloading progress of the video can be determined according to the total number of bytes returned by the server and the number of bytes downloaded.
For example, assuming that the total number of bytes of the video to be downloaded is a and the number of bytes downloaded is B, the downloading progress of the video is (B/a) × 100%.
However, for m3u8 formatted video, m3u8 video is usually combined by multiple video clips, and when m3u8 video is downloaded, multiple video clips need to be downloaded one by one. When downloading each video segment, based on the above-mentioned video downloading process, the server only returns the total number of bytes of the video segment. Therefore, the problem that the total byte number of only one video segment can be determined in the process of downloading the m3u8 video, the total byte number of the m3u8 video cannot be determined, and the downloading progress of the m3u8 video cannot be determined.
In order to solve the above technical problem, an embodiment of the present application provides a method and an apparatus for determining a video downloading progress, where the method includes: acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video; analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses; determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips; and determining the downloading progress of the target video according to the progress parameter.
According to the technical scheme provided by the embodiment of the application, when the target video in the m3u8 format is downloaded, the multiple video segments of the target video can be downloaded according to the download addresses of the multiple video segments of the target video, and in the downloading process, the downloading progress of the target video is determined according to the progress parameters related to the downloading progress of the multiple video segments, and the downloading progress of the target video does not need to be determined according to the total byte number of the target video, so that the problem that the downloading progress of the video cannot be determined under the condition that the total byte number of the target video cannot be determined can be effectively solved.
The technical solutions of the present application will be described clearly and completely below with reference to the specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the technical solution provided in the embodiment of the present application may be used to determine the download progress of a video in m3u8 format, and may also be used to determine the download progress of other videos combined by multiple video clips.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart illustrating a method for determining a video download progress according to an embodiment of the present application. The execution subject of the present embodiment may be a terminal that performs video downloading. The method is as follows.
S102: the method comprises the steps of obtaining a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video.
A video in m3u8 format generally consists of a text file ending in m3u8 and a plurality of video clips, wherein the text file comprises download addresses of the plurality of video clips. According to the embodiment of the application, when the target video with the format of m3u8 is downloaded, the text file of the target video can be obtained.
When the text file of the target video is obtained, the method specifically includes the following steps:
firstly, the method comprises the following steps: and acquiring a download address of the target video.
For example, for target video A, the download address of A.m3u8 http:// www.video/a.m3u8 can be used.
Secondly, the method comprises the following steps: and establishing network connection with the server according to the download address.
The server may be a server that provides the target video, and establishing a network connection with the server based on the download address may be understood as accessing the download address.
It should be noted that the network connection with the server is set up here to determine whether the download address is legal or valid, i.e. whether the server allows downloading the target video. If the download address is legal or valid, the network device can be successfully established with the server, and the server returns a successful type of HTTP status code (e.g., 200).
Thirdly, the method comprises the following steps: if the network connection is successfully established, a target file is established in the local download directory.
If the HTTP status code of the success type returned by the server is received, it may be determined that the network connection with the server is successfully established. When the network connection with the server is successfully established, the download address can be considered to be legal or valid, the server allows the target video to be downloaded, at this time, the downloading of the target video can be started, and the target file can be created in the local download directory, so that the target video can be downloaded into the target file later.
Alternatively, if an HTTP status code of an error type returned by the server is received, it may be determined that the network connection with the server is not successfully established. In the case that the network connection with the server is not successfully established, the download address can be considered to be illegal or invalid, the server does not allow the target video to be downloaded, and the subsequent steps can be not required to be executed. In the embodiment of the present application, the successful establishment of the network connection with the server may be taken as an example for explanation.
Fourthly: and establishing network connection with the server again, and downloading the text file into the target file according to the downloading address.
When the downloading of the target video is started, the network connection with the server needs to be established again. It should be noted that the purpose of establishing the network connection with the server is to download the target video, which is different from the above-mentioned confirmation of whether the download address is legal or valid.
And under the condition that the network connection with the server is successfully established again, the text file can be downloaded to the target file according to the downloading address. Wherein the text file comprises download addresses of a plurality of video segments constituting the target video.
Fifth, the method comprises the following steps: and acquiring the text file from the target file.
After downloading the text file of the target video into the target file, when acquiring the text file, the text file may be acquired from the target file.
S104: and analyzing the text file to obtain the download addresses of the video clips, and downloading the video clips according to the download addresses.
After the text file of the target video is obtained, the text file can be analyzed to obtain download addresses of a plurality of video clips included in the text file, wherein the plurality of video clips are a plurality of video clips forming the target video.
In this embodiment of the application, analyzing the text file of the target video to obtain the download addresses of the multiple video segments may specifically include:
firstly, the text file is analyzed to obtain a plurality of key fields included in the text file.
The text file may generally include a plurality of key fields, and one key field may include information related to one video clip, where the related information may include a playing time length of the video clip and a download address of the video clip.
After the text file is analyzed, a plurality of key fields included in the text file can be obtained.
For example, the text contents included in the text file are as follows:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:5
#EXTINF:4.064,
http://www.video/a/0.ts
#EXTINF:4.0,
http://www.video/a/1.ts
#EXTINF:4.0,
http://www.video/a/2.ts
#EXTINF:4.0,
http://www.video/a/3.ts
#EXTINF:4.0,
http://www.video/a/4.ts
#EXTINF:4.0,
http://www.video/a/5.ts
#EXTINF:4.0,
http://www.video/a/6.ts
#EXTINF:4.0,
http://www.video/a/7.ts
#EXTINF:4.0,
http://www.video/a/8.ts
#EXTINF:4.0,
http://www.video/a/9.ts
#EXTINF:4.0,
http://www.video/a/10.ts
#EXT-X-ENDLIST。
after the text file is analyzed, the following 11 key fields can be obtained:
#EXTINF:4.064,http://www.video/a/0.ts
#EXTINF:4.0,http://www.video/a/1.ts
#EXTINF:4.0,http://www.video/a/2.ts
#EXTINF:4.0,http://www.video/a/3.ts
#EXTINF:4.0,http://www.video/a/4.ts
#EXTINF:4.0,http://www.video/a/5.ts
#EXTINF:4.0,http://www.video/a/6.ts
#EXTINF:4.0,http://www.video/a/7.ts
#EXTINF:4.0,http://www.video/a/8.ts
#EXTINF:4.0,http://www.video/a/9.ts
#EXTINF:4.0,http://www.video/a/10.ts
the 11 key fields correspond to 11 video segments, taking a first key field "# extinnf: 4.064, http:// www.video/a/0. ts" as an example, 4.064 in the key fields is the playing time length of the video segments corresponding to the key fields, and http:// www.video/a/0.ts is the downloading address of the video segments corresponding to the key fields.
Secondly, a downloading list is obtained according to the related information of the video clips included in the key fields, and the downloading list includes the downloading addresses of the video clips.
Still taking the above 11 key fields as an example, according to the related information of the video clips included in the 11 key fields, a download list including the download addresses of the 11 video clips can be obtained.
http://www.video/a/0.ts
http://www.video/a/1.ts
http://www.video/a/2.ts
http://www.video/a/3.ts
http://www.video/a/4.ts
http://www.video/a/5.ts
http://www.video/a/6.ts
http://www.video/a/7.ts
http://www.video/a/8.ts
http://www.video/a/9.ts
http://www.video/a/10.ts
After the download addresses of the plurality of video segments constituting the target video are obtained, the plurality of video segments can be downloaded according to the download addresses.
In this embodiment of the present application, when downloading a plurality of video segments, one thread may be used for downloading, or a plurality of threads may be used for downloading, and when downloading using a plurality of threads, assuming that the number of the plurality of threads is t and the number of the video segments is N, each thread needs to process (N/t) video downloading tasks, where if (N/t) is not an integer, one of the threads (e.g., the last thread) may be selected to process the remaining downloading tasks. According to the technical scheme provided by the embodiment of the application, the downloading progress of the plurality of video clips downloaded on each thread can be determined. For ease of understanding, the following description may take the example of downloading multiple video clips using one thread.
S106: determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips.
In this embodiment of the application, the progress parameters related to the downloading progress of the multiple video clips at least may include: the number of the plurality of video segments, the number of video segments downloaded, the total number of bytes of video segments being downloaded, and the number of bytes downloaded.
The number of the plurality of video segments is equal to the number of the analyzed download addresses, the number of the downloaded video segments can be obtained by statistics of the download terminal, the total byte number of the video segments being downloaded can be returned by the server providing the target video, and the downloaded byte number of the video segments being downloaded can be determined by the download terminal.
S108: and determining the downloading progress of the target video according to the progress parameter.
In the embodiment of the present application, considering that, in a general case, the playing durations of a plurality of video segments constituting a target video are substantially the same, and that, in a case where the playing durations are substantially the same, the sizes of the plurality of video segments are also substantially the same, therefore, in a case where the progress parameter at least includes the number of the plurality of video segments, the number of downloaded video segments, the total number of bytes of a video segment being downloaded, and the number of bytes downloaded, the download progress of the target video can be determined by the following formula:
Figure BDA0002282554460000101
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segment, and N is the number of the video segment.
For example, assuming that the number of video segments constituting the target video is 10, the 10 videos are downloaded by 1 thread, the number of currently downloaded video segments is 4, the total number of bytes of 1 video segment being downloaded is 200kb, and the number of bytes downloaded is 100kb, then the current download progress is: (100/200+4)/10 × 100% ═ 45%.
It should be noted that, in a case that the difference between the playing time lengths of the plurality of video segments constituting the target video is smaller than or equal to the preset threshold (the difference between the playing time lengths of the corresponding plurality of video segments is smaller than or equal to the preset threshold), the downloading progress of the target video can be determined through the above formula. The preset threshold value can be set manually according to the accuracy of the downloading progress.
It should be noted that, in individual cases, the difference between the playing durations of the video segments may be greater than the preset threshold, and accordingly, the difference between the total number of bytes of the video segments is also greater than the preset threshold, and then the method for determining the downloading progress may no longer be applicable. In this case, in order to determine the downloading progress of the target video, the size relationship between the total number of bytes of the plurality of video segments may be determined according to the size relationship between the playing durations of the plurality of video segments, and then the downloading progress may be determined under the condition that the number of the plurality of video segments, the number of downloaded video segments, the total number of bytes of the video segments being downloaded, and the number of bytes being downloaded are known.
The playing duration of the video clip may be determined according to the key fields obtained by the analysis in S104, where one key field includes related information of one video clip, and the related information includes the playing duration of the video clip.
Still taking the above 10 video segments downloaded by 1 thread as an example, assuming that the downloaded 4 video segments are A, B, C and D, the video segment being downloaded is E, the video segments not being downloaded are F, G, H, I and J, A, B and C have playing durations 2 times of E, D and F have playing durations the same as E, and G, H, I and J have playing durations 1.5 times of E, then it can be considered that the total byte count of A, B and C is 2 times of E, the total byte count of D and F is the same as E, the total byte count of G, H, I and J is 1.5 times of E, the total byte count of known E is 200kb, the byte count of downloaded is 100kb, and then the current downloading progress is: [ (200 × 2 × 3+200+100)/(200 × 2 × 3+200 × 3+200 × 1.5 × 3) ] × 100% — 55.6%.
After determining the downloading progress of the target video, optionally, the downloading progress may be displayed in a downloading interface, so that the user may clearly know the downloading progress of the current target video.
Optionally, for each video clip, after the video clip is downloaded, the video clip may also be named. In the naming, the video clip may be named preferably according to the index of the video clip in the download list described in S104.
Taking the above download address download list comprising 11 video segments as an example, the download address http:// www.video/a/0.ts of the first video segment in the list is located at 0 in the list, then the first video segment can be named as 0. ts; the download address http:// www.video/a/1.ts of the second video segment is located at 1 in the list, then the second video segment can be named as 1. ts; … …, respectively; by analogy, the last video segment may be named 10. ts.
After the video clip is named, the video clip can be stored. Preferably, the video clip may be stored in the object file described in the above S102.
After the plurality of video clips of the target video are named and stored based on the method, the text file of the target video can be updated.
Specifically, after storing a plurality of video clips of the target video, storage paths of the plurality of video clips may be determined, and then download addresses of the plurality of video clips included in the text file may be replaced with the storage paths of the plurality of video clips, thereby updating the text file of the target video.
Taking the above text file including the download addresses of 11 video clips as an example, assuming that the named 11 video clips are stored in the destination file a under the download file of the local SD card, the storage paths of the 11 video clips may be:
sdcard/download/A/0.ts
sdcard/download/A/1.ts
sdcard/download/A/2.ts
sdcard/download/A/3.ts
sdcard/download/A/4.ts
sdcard/download/A/5.ts
sdcard/download/A/6.ts
sdcard/download/A/7.ts
sdcard/download/A/8.ts
sdcard/download/A/9.ts
sdcard/download/A/10.ts
replacing the download addresses of the 11 video clips in the text file with the storage paths of the 11 video clips, so as to obtain the following updated text file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:5
#EXTINF:4.064,
sdcard/download/A/0.ts
#EXTINF:4.0,
sdcard/download/A/1.ts
#EXTINF:4.0,
sdcard/download/A/2.ts
#EXTINF:4.0,
sdcard/download/A/3.ts
#EXTINF:4.0,
sdcard/download/A/4.ts
#EXTINF:4.0,
sdcard/download/A/5.ts
#EXTINF:4.0,
sdcard/download/A/6.ts
#EXTINF:4.0,
sdcard/download/A/7.ts
#EXTINF:4.0,
sdcard/download/A/8.ts
#EXTINF:4.0,
sdcard/download/A/9.ts
#EXTINF:4.0,
sdcard/download/A/10.ts
#EXT-X-ENDLIST
after the updated text file is obtained, when the target video is played, the plurality of video clips can be read from the storage paths of the plurality of video clips included in the text file, so that the target video is played.
According to the technical scheme provided by the embodiment of the application, when the target video in the m3u8 format is downloaded, the multiple video segments of the target video can be downloaded according to the download addresses of the multiple video segments of the target video, and in the downloading process, the downloading progress of the target video is determined according to the progress parameters related to the downloading progress of the multiple video segments, and the downloading progress of the target video does not need to be determined according to the total byte number of the target video, so that the problem that the downloading progress of the video cannot be determined under the condition that the total byte number of the target video cannot be determined can be effectively solved.
To facilitate understanding of how to determine the downloading progress when downloading the target video in the m3u8 format, and the whole downloading process, see fig. 2. Fig. 2 is a schematic flowchart of a video downloading method according to an embodiment of the present application, which may specifically include the following steps:
s201: and acquiring a download address of the target video.
S202: and establishing network connection with the server according to the download address.
The server may be a server providing the target video, and establishing a network connection with the server may be understood as a download address for accessing the target video.
S203: whether a network connection with the server is successfully established.
If the successful type of HTTP status code returned by the server is received, it may be confirmed that the network connection with the server is successfully established, and at this time, it may be stated that the download address of the target video is valid and valid, and S204 may be performed; if the HTTP status code of the error type returned by the server is received, it may be confirmed that the network connection with the server is not successfully established, and at this time, it may be stated that the download address of the target video is invalid illegally, and S215 may be performed.
S204: a destination file is created in the local download directory.
The target file may be used to store a text file and a plurality of video clips of the target video.
S205: and establishing network connection with the server again, and downloading the text file of the target video into the target file according to the downloading address.
S206: and acquiring a text file of the target video from the target file.
S207: and analyzing the text file of the target video to obtain a plurality of key fields included in the text file.
One key field comprises the relevant information of one video clip, and the relevant information can comprise the playing time length and the downloading address of the video clip.
S208: and obtaining a download list comprising download addresses of the plurality of video clips according to the plurality of key fields.
S209: and downloading the plurality of video clips according to the download addresses of the plurality of video clips.
When downloading a plurality of video clips, one thread may be used for downloading, and a plurality of threads may also be used for downloading, and the subsequently determined downloading progress may be the downloading progress of a plurality of video clips downloaded on each thread.
S210: in the process of downloading the plurality of video clips, determining a progress parameter related to the downloading progress of the plurality of video clips.
The schedule parameters may include at least: the number of the plurality of video segments, the number of video segments downloaded, the total number of bytes of video segments being downloaded, and the number of bytes downloaded.
S211: and determining the downloading progress of the target video according to the progress parameters.
In determining the download progress, it is preferable that the download progress of the target video is determined by the following formula, considering that in a general case, the playing time lengths of the plurality of video clips constituting the target video are substantially the same, and in a case where the playing time lengths are substantially the same, the sizes of the plurality of video clips are also substantially the same, and therefore, in a case where the difference in the playing time lengths of the plurality of video clips is less than or equal to a preset threshold (the difference in the total number of bytes corresponding to the plurality of video clips is less than or equal to the preset threshold):
Figure BDA0002282554460000151
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, and M is the downloaded byte numberAnd N is the number of the video clips.
Optionally, considering that in individual cases, the difference between the playing durations of the plurality of video segments constituting the target video may be greater than a preset threshold (the difference between the total byte numbers of the corresponding plurality of video segments is greater than the preset threshold), at this time, the size relationship between the total byte number of the video being downloaded and the total byte numbers of the other video segments may be determined according to the size relationship between the playing duration of the video being downloaded among the plurality of videos and the playing durations of the other video segments, so as to determine the playing duration of the target video. Specific reference may be made to specific implementation of the corresponding step in S108, and details are not described here.
S212: after each video clip is downloaded, each video clip is named according to the index of the download address of the video clip in the download list.
For example, if the position of the download address of the video clip in the download list is i, then the video clip may be named as i.ts.
S213: and storing the named plurality of video clips in a target file.
S214: and replacing the download addresses of the plurality of videos in the text file with the storage paths of the plurality of videos to obtain the updated text file.
After the updated text file is obtained, when the target video is played, the plurality of video clips can be read according to the storage path in the updated text file, so that the target video is played.
S215: and (6) ending.
The embodiment shown in fig. 2 provides a video downloading method, during a video downloading process, a downloading progress of a target video may be determined through a progress parameter related to downloading progresses of a plurality of video segments, and a downloading progress of the video does not need to be determined according to a total number of bytes of the target video, so that a problem that the downloading progress cannot be determined under a condition that the total number of bytes of the target video cannot be determined can be effectively avoided. In addition, after the plurality of video clips are downloaded, the plurality of video clips are named and stored, and the storage paths of the plurality of video clips replace the download addresses in the text file of the target video, so that the target video can be conveniently played based on the storage paths of the video clips when the target video is played.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 3, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 3, but this does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form a device for determining the video downloading progress on a logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and determining the downloading progress of the target video according to the progress parameter.
The method performed by the apparatus for determining a video download progress according to the embodiment of fig. 3 of the present application may be applied to or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the method in fig. 1 and fig. 2, and implement the functions of the apparatus for determining a video download progress in the embodiment shown in fig. 1 and fig. 2, which are not described herein again in this embodiment of the present application.
Of course, besides the software implementation, the electronic device of the present application does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
Embodiments of the present application also propose a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiment shown in fig. 1 and 2, and in particular to perform the following operations:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining a progress parameter related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and determining the downloading progress of the target video according to the progress parameter.
Fig. 4 is a schematic structural diagram of an apparatus for determining a video download progress according to an embodiment of the present application. The method specifically comprises the following steps: an acquisition unit 41, a download unit 42, a progress parameter determination unit 43, and a download progress determination unit 44, wherein:
the acquiring unit 41 is configured to acquire a text file of a target video, where the format of the target video is m3u8, and the text file includes download addresses of multiple video segments of the target video;
the downloading unit 42 analyzes the text file to obtain downloading addresses of the plurality of video segments, and downloads the plurality of video segments according to the downloading addresses;
a progress parameter determining unit 43, which determines progress parameters related to the downloading progress of the plurality of video clips in the process of downloading the plurality of video clips;
and the downloading progress determining unit 44 is used for determining the downloading progress of the target video according to the progress parameter.
Optionally, the progress parameter includes the number of the plurality of video segments, the number of downloaded video segments, the total number of bytes of the video segments being downloaded, and the number of bytes downloaded.
Optionally, the downloading progress determining unit 44 determines the downloading progress of the target video according to the progress parameter, including:
determining a download progress of the target video by the following formula:
Figure BDA0002282554460000191
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segments, and N is the number of the plurality of video segments.
Optionally, the obtaining unit 41 obtains a text file of the target video, including:
acquiring a downloading address of the target video;
establishing network connection with a server according to the download address of the target video;
if the network connection is successfully established, establishing a target file in a local download directory;
establishing network connection with the server again, and downloading the text file into the target file according to the downloading address of the target video;
and acquiring the text file from the target file.
Optionally, the downloading unit 42 parses the text file to obtain the download addresses of the plurality of video segments, and includes:
analyzing the text file to obtain a plurality of key fields included in the text file, wherein one key field includes related information of one video clip;
and obtaining a downloading list according to the relevant information of the video clips included in the key fields, wherein the downloading list includes the downloading addresses of the video clips.
Optionally, the apparatus for determining video download progress 40 further includes a storage unit 45, where:
for each video clip, after the downloading unit 42 finishes downloading the video clip, the storage unit 45 names the video clip according to the index of the downloading address of the video clip in the downloading list;
and storing the video clip.
Optionally, the storage unit 45 determines a storage path of the plurality of video segments after storing the plurality of video segments;
and replacing the download addresses of the plurality of video clips included in the text file with the storage paths of the plurality of video clips to update the text file.
The device 40 for determining a video download progress provided in this embodiment of the present application may further execute the method in fig. 1 and fig. 2, and implement the functions of the device for determining a video download progress in the embodiments shown in fig. 1 and fig. 2, which are not described herein again in this embodiment of the present application.
In short, the above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.

Claims (7)

1. A method for determining video downloading progress is characterized by comprising the following steps:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining progress parameters related to the downloading progress of the video clips in the process of downloading the video clips, wherein the progress parameters comprise the number of the video clips, the number of downloaded video clips, the total number of bytes of the video clips being downloaded and the number of bytes downloaded;
determining the downloading progress of the target video by the following formula under the condition that the size difference of the plurality of video clips is smaller than or equal to a preset threshold value:
Figure FDA0003475273970000011
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segments, and N is the number of the plurality of video segments;
the method for acquiring the text file of the target video comprises the following steps:
acquiring a downloading address of the target video;
establishing network connection with a server according to the download address of the target video;
if the network connection is successfully established, establishing a target file in a local download directory;
establishing network connection with the server again, and downloading the text file into the target file according to the downloading address of the target video;
and acquiring the text file from the target file.
2. The method of claim 1, wherein parsing the text file to obtain download addresses for the plurality of video segments comprises:
analyzing the text file to obtain a plurality of key fields included in the text file, wherein one key field includes related information of one video clip;
and obtaining a downloading list according to the relevant information of the video clips included in the key fields, wherein the downloading list includes the downloading addresses of the video clips.
3. The method of claim 2, wherein the method further comprises:
after the video clips are downloaded, naming the video clips according to indexes of the downloading addresses of the video clips in the downloading list;
and storing the video clip.
4. The method of claim 3, wherein the method further comprises:
after storing the plurality of video segments, determining storage paths of the plurality of video segments;
and replacing the download addresses of the plurality of video clips included in the text file with the storage paths of the plurality of video clips to update the text file.
5. An apparatus for determining a video download progress, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a text file of a target video, the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video segments of the target video;
the downloading unit analyzes the text file to obtain downloading addresses of the video clips and downloads the video clips according to the downloading addresses;
a progress parameter determining unit, configured to determine a progress parameter related to a download progress of the plurality of video segments during downloading of the plurality of video segments, where the progress parameter includes the number of the plurality of video segments, the number of downloaded video segments, a total number of bytes of a video segment being downloaded, and a number of bytes downloaded;
a download progress determining unit that determines a download progress of the target video by the following formula in a case where the size difference of the plurality of video clips is less than or equal to a preset threshold:
Figure FDA0003475273970000021
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segments, and N is the number of the plurality of video segments;
the acquiring unit acquires a text file of a target video, and includes:
acquiring a downloading address of the target video;
establishing network connection with a server according to the download address of the target video;
if the network connection is successfully established, establishing a target file in a local download directory;
establishing network connection with the server again, and downloading the text file into the target file according to the downloading address of the target video;
and acquiring the text file from the target file.
6. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining progress parameters related to the downloading progress of the video clips in the process of downloading the video clips, wherein the progress parameters comprise the number of the video clips, the number of downloaded video clips, the total number of bytes of the video clips being downloaded and the number of bytes downloaded;
determining the downloading progress of the target video by the following formula under the condition that the size difference of the plurality of video clips is smaller than or equal to a preset threshold value:
Figure FDA0003475273970000031
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segments, and N is the number of the plurality of video segments;
the method for acquiring the text file of the target video comprises the following steps:
acquiring a downloading address of the target video;
establishing network connection with a server according to the download address of the target video;
if the network connection is successfully established, establishing a target file in a local download directory;
establishing network connection with the server again, and downloading the text file into the target file according to the downloading address of the target video;
and acquiring the text file from the target file.
7. A computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to:
acquiring a text file of a target video, wherein the format of the target video is m3u8, and the text file comprises download addresses of a plurality of video clips of the target video;
analyzing the text file to obtain download addresses of the video clips, and downloading the video clips according to the download addresses;
determining progress parameters related to the downloading progress of the video clips in the process of downloading the video clips, wherein the progress parameters comprise the number of the video clips, the number of downloaded video clips, the total number of bytes of the video clips being downloaded and the number of bytes downloaded;
determining the downloading progress of the target video by the following formula under the condition that the size difference of the plurality of video clips is smaller than or equal to a preset threshold value:
Figure FDA0003475273970000041
wherein l is the downloaded byte number of the video segment being downloaded, k is the total byte number of the video segment being downloaded, M is the number of the downloaded video segments, and N is the number of the plurality of video segments;
the method for acquiring the text file of the target video comprises the following steps:
acquiring a downloading address of the target video;
establishing network connection with a server according to the download address of the target video;
if the network connection is successfully established, establishing a target file in a local download directory;
establishing network connection with the server again, and downloading the text file into the target file according to the downloading address of the target video;
and acquiring the text file from the target file.
CN201911147254.5A 2019-11-21 2019-11-21 Method and device for determining video downloading progress Active CN110868643B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911147254.5A CN110868643B (en) 2019-11-21 2019-11-21 Method and device for determining video downloading progress

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911147254.5A CN110868643B (en) 2019-11-21 2019-11-21 Method and device for determining video downloading progress

Publications (2)

Publication Number Publication Date
CN110868643A CN110868643A (en) 2020-03-06
CN110868643B true CN110868643B (en) 2022-04-26

Family

ID=69655882

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911147254.5A Active CN110868643B (en) 2019-11-21 2019-11-21 Method and device for determining video downloading progress

Country Status (1)

Country Link
CN (1) CN110868643B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113810773B (en) * 2021-09-17 2024-03-01 北京百度网讯科技有限公司 Video downloading method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104244079A (en) * 2013-06-07 2014-12-24 腾讯科技(深圳)有限公司 Video download method and device
CN108924630A (en) * 2018-05-29 2018-11-30 武汉斗鱼网络科技有限公司 A kind of method and playback equipment of display caching progress
JP2019036787A (en) * 2017-08-10 2019-03-07 株式会社ミクシィ Information processing apparatus, video distribution method, and video distribution program
CN109688483A (en) * 2018-12-17 2019-04-26 北京爱奇艺科技有限公司 A kind of method, apparatus and electronic equipment obtaining video

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101217638B (en) * 2007-12-28 2012-10-24 深圳市迅雷网络技术有限公司 Downloading method, system and device of video file fragmentation
US20130080267A1 (en) * 2011-09-26 2013-03-28 Unicorn Media, Inc. Single-url content delivery
CN103024456B (en) * 2011-09-27 2016-02-24 腾讯科技(深圳)有限公司 A kind of Online Video player method and video playback server
CN103648019A (en) * 2013-11-29 2014-03-19 乐视致新电子科技(天津)有限公司 Video downloading method and device based on HLS protocol
CN103826159B (en) * 2013-12-04 2017-12-19 Tcl集团股份有限公司 The local offline player method and terminal of a kind of M3U8 format videos
US20170257423A1 (en) * 2016-03-02 2017-09-07 Le Holdings (Beijing) Co., Ltd. Method of automatically downloading video based on a user flag and electronic device
CN106331788A (en) * 2016-08-31 2017-01-11 乐视控股(北京)有限公司 Video download method and device
CN108769830B (en) * 2018-05-29 2021-05-28 武汉斗鱼网络科技有限公司 Method for caching video and related equipment
CN108965910B (en) * 2018-08-09 2022-05-10 网宿科技股份有限公司 Video caching method and player

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104244079A (en) * 2013-06-07 2014-12-24 腾讯科技(深圳)有限公司 Video download method and device
JP2019036787A (en) * 2017-08-10 2019-03-07 株式会社ミクシィ Information processing apparatus, video distribution method, and video distribution program
CN108924630A (en) * 2018-05-29 2018-11-30 武汉斗鱼网络科技有限公司 A kind of method and playback equipment of display caching progress
CN109688483A (en) * 2018-12-17 2019-04-26 北京爱奇艺科技有限公司 A kind of method, apparatus and electronic equipment obtaining video

Also Published As

Publication number Publication date
CN110868643A (en) 2020-03-06

Similar Documents

Publication Publication Date Title
CN109639636B (en) Service data forwarding method, service data processing method, service data forwarding device, service data processing device and electronic equipment
US11081108B2 (en) Interaction method and apparatus
CN108228293B (en) Interface skin switching method and device
CN107798064B (en) Page processing method, electronic device and computer readable storage medium
CN107528885B (en) Service request processing method and device
CN107479868B (en) Interface loading method, device and equipment
CN114064594B (en) Data processing method and device
CN111241040B (en) Information acquisition method and device, electronic equipment and computer storage medium
CN111158793A (en) Application page skipping method and device, electronic equipment and readable storage medium
CN109660859A (en) A kind of animated show method and mobile terminal
CN110868643B (en) Method and device for determining video downloading progress
CN112286706B (en) Remote and rapid acquisition method for application information of android application and related equipment
CN114268538A (en) Configuration method and device of front-end route
CN111506747B (en) File analysis method, device, electronic equipment and storage medium
CN111031117B (en) Multimedia file downloading method and related device
US10970332B2 (en) Electronic device and digital content managing method
CN112218166A (en) Play starting method and related device for memory play of on-demand video
CN111709748A (en) Transaction execution method and device with service attribute and electronic equipment
CN108446144B (en) Application program starting method and device, terminal and storage medium
CN111046308A (en) Page loading method and device
CN112463746B (en) File storage and generation method and device and electronic equipment
CN110069731B (en) Data processing method and device, electronic equipment and computer readable storage medium
CN109729419B (en) Push video preloading method and device, electronic equipment and storage medium
CN109615465B (en) Service order processing method and device and electronic equipment
CN112907198A (en) Service state circulation maintenance method and device and electronic equipment

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