Universal m3u8 file rewriting method and system

By downloading and storing rewrite configuration information, the m3u8 file rewriting process is simplified, and the problems of complex and long cycle in the existing technology are solved, and rapid storage and reuse are achieved to meet a variety of rewriting needs.

WO2024244408A1PCT designated stage expired Publication Date: 2024-12-05CHINA TELECOM CLOUD TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/139658
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-31
Filing Date
2023-12-18
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

In the prior art, the m3u8 file rewriting operation is complex and the cycle is long, and it is necessary to write code frequently to meet the different rewriting needs of customers.

Method used

By downloading the rewrite configuration information, determining the domain name and channel domain name, storing it in shared memory, obtaining the initial m3u8 file, and finding or generating caches based on the cache key and channel domain name, the rewriting of the m3u8 file is realized, simplifying the rewriting process.

Benefits of technology

It realizes the rapid storage and reuse of m3u8 files, simplifies rewriting operations, shortens the rewriting cycle, and adapts to various rewriting configuration information needs without customized development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023139658_05122024_PF_FP_ABST
    Figure CN2023139658_05122024_PF_FP_ABST
Patent Text Reader

Abstract

A universal m3u8 file rewriting method and system. The universal m3u8 file rewriting method comprises the following steps: downloading rewriting configuration information; determining domain name information of the downloaded rewriting configuration information; determining a sub-channel domain name of the downloaded rewriting configuration information; storing the downloaded rewriting configuration information in a shared memory by means of the domain name information and the sub-channel domain name; acquiring an initial m3u8 file; determining domain name information corresponding to the initial m3u8 file; according to the domain name information, acquiring, from the shared memory, rewriting configuration information corresponding to the initial m3u8 file; determining a sub-channel domain name and a cache key corresponding to the initial m3u8 file; searching for a cache according to the cache key and the sub-channel domain name, and when there is a corresponding cache, taking content in the corresponding cache as a rewritten m3u8 file; and when there is no corresponding cache, rewriting the initial m3u8 file according to the rewriting configuration information, so as to obtain a rewritten m3u8 file. In this way, different rewriting requirements can be satisfied according to various types of rewriting configuration information without the need to perform custom development for each rewriting requirement, thereby effectively shortening a delivery cycle of an m3u8 file rewriting requirement.
Need to check novelty before this filing date? Find Prior Art

Description

A universal m3u8 file rewriting method and system Technical Field

[0001] The embodiments of this specification mainly relate to the technical field of m3u8 file rewriting, specifically a universal m3u8 file rewriting method and system. Background Art

[0002] Content delivery networks need to support the rewriting of m3u8 files. The existing m3u8 file rewriting process is as follows: the customer submits a request to rewrite the m3u8 file, and the content delivery network manufacturer's technical staff writes the corresponding code to complete the rewriting of the m3u8 file based on the rewriting request, and finally returns the rewritten m3u8 file to the customer.

[0003] Customers' requirements for rewriting m3u8 files are often different. For example, some customers need to rewrite m3u8 files A and B, while others need to rewrite m3u8 files B and C. Another example is that some customers need to rewrite m3u8 file A based on rewrite configuration information 1, while others need to rewrite m3u8 file A based on rewrite configuration information 2.

[0004] Therefore, in the prior art, whenever a customer requests to rewrite an m3u8 file, the technical personnel of the content distribution network manufacturer need to rewrite the corresponding code to complete the rewriting operation of the m3u8 file according to the rewriting request, which makes the m3u8 file rewriting operation complicated and the rewriting cycle long.

[0005] Summary of the Invention

[0006] The embodiments of this specification aim to solve the problems existing in the prior art and propose a universal m3u8 file rewriting method and system to solve the problems of complex m3u8 file rewriting operation and long rewriting cycle in the prior art.

[0007] In a first aspect, the present disclosure provides a general m3u8 file rewriting method, comprising the following steps:

[0008] Download and rewrite configuration information;

[0009] Determine the domain name information of the downloaded rewriting configuration information;

[0010] Determine the sub-channel domain name of the downloaded rewrite configuration information;

[0011] The downloaded rewriting configuration information is stored in the shared memory through the domain name information and the sub-channel domain name;

[0012] Get the initial m3u8 file;

[0013] Determine the domain name information corresponding to the initial m3u8 file;

[0014] Obtain rewrite configuration information corresponding to the initial m3u8 file from shared memory according to the domain name information;

[0015] Determine the sub-channel domain name and cache key corresponding to the initial m3u8 file;

[0016] According to the cache key and the sub-channel domain name, a cache is searched, and when a corresponding cache exists, the content in the corresponding cache is used as the rewritten m3u8 file; when a corresponding cache does not exist, the initial m3u8 file is rewritten according to the rewrite configuration information to obtain the rewritten m3u8 file.

[0017] Preferably, determining the sub-channel domain name of the downloaded rewriting configuration information specifically includes the following steps:

[0018] Comparing the downloaded rewriting configuration information with the rewriting configuration information in the configuration information storage unit, and when the configuration information storage unit contains the same rewriting configuration information as the downloaded rewriting configuration information, using the sub-channel domain name of the corresponding rewriting configuration information in the configuration information storage unit as the sub-channel domain name of the downloaded rewriting configuration information;

[0019] When there is no rewrite configuration information identical to the downloaded rewrite configuration information in the configuration information storage unit, a new sub-channel domain name is generated, and the new sub-channel domain name is used as the sub-channel domain name of the downloaded rewrite configuration information; and the downloaded configuration information is stored in the configuration information storage unit via the new sub-channel domain name.

[0020] Preferably, rewriting the initial m3u8 file according to the rewrite configuration information specifically comprises the following steps:

[0021] Generate a corresponding cache according to the cache key and the sub-channel domain name;

[0022] Read a subfile in the initial m3u8 file, and determine whether the subfile meets the truncation condition. When the subfile meets the truncation condition, cut off the corresponding subfile and read the next subfile in the initial m3u8 file;

[0023] When the subfile does not meet the truncation condition, determine whether the subfile meets the editing condition. When the subfile does not meet the editing condition, write the subfile into the cache and read the next subfile in the initial m3u8 file.

[0024] When the subfile meets the editing condition, the subfile is edited according to the rewrite configuration information, and the edited subfile is written into the cache, and the next subfile in the initial m3u8 file is read;

[0025] When the next sub-file in the initial m3u8 file cannot be read, the content in the corresponding cache is used as the rewritten m3u8 file.

[0026] Preferably, determining whether the subfile meets the truncation condition specifically includes the following steps:

[0027] Obtain the cumulative duration of the slices in the subfile, and compare the cumulative duration of the slices in the subfile with the preset time threshold;

[0028] Get the total number of slices in the sub-file, and compare the total number of slices in the sub-file with a preset number threshold;

[0029] When the cumulative duration of the slices in the subfile is less than a preset time threshold or the total number of slices in the subfile is greater than a preset number threshold, the subfile is determined to meet the truncation condition; otherwise, the subfile is determined not to meet the truncation condition.

[0030] Preferably, determining whether the sub-file meets the editing condition specifically includes the following steps:

[0031] Determine the type of sub-file;

[0032] When the sub-file is a file of the url type, it is determined that the sub-file meets the editing condition; otherwise, it is determined that the sub-file does not meet the editing condition.

[0033] In a second aspect, the present specification provides a general m3u8 file rewriting system, including:

[0034] Configuration information download module, used to download and rewrite configuration information;

[0035] A first domain name information determination module, configured to determine the domain name information of the downloaded rewriting configuration information;

[0036] A first sub-channel domain name determination module, configured to determine the sub-channel domain name of the downloaded rewriting configuration information;

[0037] A configuration information storage module is used to store the downloaded rewrite configuration information in a shared memory through domain name information and sub-channel domain name;

[0038] File acquisition module, used to obtain the initial m3u8 file;

[0039] A second domain name information determination module is used to determine the domain name information corresponding to the initial m3u8 file;

[0040] A configuration information acquisition module is used to obtain the rewrite configuration information corresponding to the initial m3u8 file from the shared memory according to the domain name information;

[0041] A second sub-channel domain name determination module is used to determine the sub-channel domain name corresponding to the initial m3u8 file;

[0042] A cache key determination module, configured to determine a cache key corresponding to the initial m3u8 file;

[0043] A cache search module, configured to search the cache according to the cache key and the sub-channel domain name;

[0044] A first rewriting file determination module is used to use the content in the corresponding cache as the rewritten m3u8 file when a corresponding cache exists;

[0045] The second rewriting file determining module is used for rewriting the initial m3u8 file according to the rewriting configuration information to obtain a rewritten m3u8 file when there is no corresponding cache.

[0046] Preferably, the first sub-channel domain name determination module specifically includes:

[0047] a configuration information comparison unit, configured to compare the downloaded rewriting configuration information with the rewriting configuration information in the configuration information storage unit;

[0048] a first sub-channel domain name determining unit configured to, when the configuration information storage unit contains rewriting configuration information identical to the downloaded rewriting configuration information, use the sub-channel domain name of the corresponding rewriting configuration information in the configuration information storage unit as the sub-channel domain name of the downloaded rewriting configuration information;

[0049] A sub-channel domain name generating unit, configured to generate a new sub-channel domain name when the configuration information storage unit does not contain the same rewriting configuration information as the downloaded rewriting configuration information;

[0050] The second sub-channel domain name determining unit is used to use the new sub-channel domain name as the sub-channel domain name of the downloaded rewritten configuration information; the configuration information storage unit is used to store the downloaded configuration information through the new sub-channel domain name.

[0051] Preferably, the second rewriting file determination module specifically includes:

[0052] A cache generation unit, configured to generate a corresponding cache according to the cache key and the sub-channel domain name;

[0053] The sub-file reading unit is used to read a sub-file in the initial m3u8 file;

[0054] A first sub-file determination unit, configured to determine whether the sub-file meets a truncation condition;

[0055] A file truncation unit, configured to truncate the corresponding sub-file when the sub-file meets the truncation condition;

[0056] a second sub-file determination unit, configured to determine whether the sub-file meets the editing condition when the sub-file does not meet the truncation condition;

[0057] a first sub-file writing unit, configured to write the sub-file into the cache when the sub-file does not meet the editing condition;

[0058] a sub-file editing unit, configured to edit the sub-file according to the rewriting configuration information when the sub-file meets the editing condition;

[0059] A second sub-file writing unit, configured to write the edited sub-file into the cache;

[0060] The rewriting file determining unit is used to use the content in the corresponding cache as the rewritten m3u8 file when the next sub-file in the initial m3u8 file cannot be read.

[0061] Preferably, the first sub-file determination unit specifically includes:

[0062] The cumulative duration acquisition subunit is used to obtain the cumulative duration of the slices in the sub-file;

[0063] The cumulative duration comparison subunit is used to compare the cumulative duration of the slices in the subfile with the preset time threshold;

[0064] The total number acquisition subunit is used to obtain the total number of slices in the subfile;

[0065] A total number comparison subunit is used to compare the total number of slices in the subfile with a preset number threshold;

[0066] The first judgment result determination subunit is used to determine that the subfile meets the truncation condition when the cumulative duration of the slices in the subfile is less than a preset time threshold or the total number of slices in the subfile is greater than a preset number threshold; otherwise, it is determined that the subfile does not meet the truncation condition.

[0067] Preferably, the second sub-file determination unit specifically includes:

[0068] A type determination subunit, used to determine the type of the subfile;

[0069] The second determination result determining subunit is configured to determine that the subfile meets the editing condition when the subfile is a file of the url type; otherwise, determine that the subfile does not meet the editing condition. Beneficial effects

[0070] The m3u8 file rewriting method and system of the present specification embodiment can store the rewritten m3u8 file content. When the same m3u8 file needs to be rewritten next time, the corresponding rewriting content can be directly called, making the rewriting operation of the m3u8 file more simple and convenient, and shortening the rewriting cycle of the m3u8 file. The m3u8 file rewriting method and system of the present specification embodiment can realize different rewriting requirements according to various rewriting configuration information, without the need for customized development of each rewriting requirement, effectively shortening the delivery cycle of the m3u8 file rewriting requirement. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] FIG1 is a schematic flow diagram of a method for rewriting an m3u8 file provided by an embodiment of this specification;

[0072] FIG2 is a schematic structural diagram of an m3u8 file rewriting system provided by an embodiment of this specification;

[0073] FIG3 is a schematic diagram of the structure of an m3u8 file after it is opened according to an embodiment of the present specification. DETAILED DESCRIPTION

[0074] Hereinafter, embodiments of the present specification will be described in more detail with reference to the accompanying drawings.

[0075] Embodiment 1: a kind of general m3u8 file rewriting method, as shown in Figure 1, comprises the following steps:

[0076] L1. Download and rewrite configuration information.

[0077] Assume that the current customer's rewriting requirements are: rewriting m3u8 file No. A, m3u8 file No. B and m3u8 file No. C, then this embodiment can download three rewriting configuration information from the client, namely, rewriting configuration information No. 1 for rewriting m3u8 file No. A, rewriting configuration information No. 2 for rewriting m3u8 file No. B and rewriting configuration information No. 3 for rewriting m3u8 file No. C.

[0078] L2. Determine the domain name information of the downloaded rewriting configuration information.

[0079] Each m3u8 file corresponds to a unique domain name. For example, m3u8 file A corresponds to domain name A, m3u8 file B corresponds to domain name B, and m3u8 file C corresponds to domain name C. Then, because rewrite configuration information No. 1 is used to rewrite m3u8 file No. A, the domain name information corresponding to rewrite configuration information No. 1 can be domain name A; rewrite configuration information No. 2 is used to rewrite m3u8 file No. B, so the domain name information corresponding to rewrite configuration information No. 2 can be domain name B; rewrite configuration information No. 3 is used to rewrite m3u8 file No. C, so the domain name information corresponding to rewrite configuration information No. 3 can be domain name C.

[0080] L3. Determine the sub-channel domain name of the downloaded rewriting configuration information.

[0081] Even if the m3u8 file No. A is rewritten, the specific content of the rewritten configuration information No. 1 is not always the same.

[0082] For example, in the m3u8 file rewriting demand of the previous client, it is also necessary to rewrite the m3u8 file A, so a copy of the rewrite configuration information No. 1 will also be downloaded. Assuming that the previous rewrite configuration information No. 1 is different from the current rewrite configuration information No. 1 in specific content, the present embodiment distinguishes the two rewrite configuration information No. 1 by the sub-channel domain name. Assuming that the sub-channel domain name of the previous rewrite configuration information No. 1 is A domain name-1, the sub-channel domain name of the current rewrite configuration information No. 1 can be A domain name-2.

[0083] In addition, step L3 may specifically include the following steps:

[0084] L31. Compare the downloaded rewrite configuration information with the rewrite configuration information in the configuration information storage unit. When the configuration information storage unit contains rewrite configuration information that is identical to the downloaded rewrite configuration information, the sub-channel domain name of the corresponding rewrite configuration information in the configuration information storage unit is used as the sub-channel domain name of the downloaded rewrite configuration information.

[0085] This embodiment includes a configuration information storage unit comprising multiple configuration information storage areas. Each configuration information storage area has multiple configuration information storage subareas, each of which is used to store a copy of rewrite configuration information. The configuration information storage areas are named using domain name information, and the configuration information storage subareas are named using sub-channel domain names.

[0086] In this embodiment, after determining that the domain name information of rewrite configuration information No. 1 is domain name A, the configuration information storage area corresponding to domain name A can be immediately found. Then, rewrite configuration information No. 1 is compared with the rewrite configuration information in the configuration information storage sub-area of ​​the corresponding configuration information storage area. If the rewrite configuration information in a configuration information storage sub-area is the same as the current rewrite configuration information No. 1, the name of the corresponding configuration information storage sub-area can be used as the sub-channel domain name of rewrite configuration information No. 1. For example, if the name of the corresponding configuration information storage sub-area is domain name A-18, then the sub-channel domain name of rewrite configuration information No. 1 is domain name A-18.

[0087] In this embodiment, after determining that the domain name information of the rewritten configuration information No. 2 is domain name B, the configuration information storage area corresponding to domain name B can be immediately found. The rewritten configuration information No. 2 is then compared with the rewritten configuration information in the configuration information storage sub-area of ​​the corresponding configuration information storage area. If the rewritten configuration information in a certain configuration information storage sub-area is the same as the current rewritten configuration information No. 2, the name of the corresponding configuration information storage sub-area can be used as the sub-channel domain name of the rewritten configuration information No. 2. For example, if the name of the corresponding configuration information storage sub-area is domain name B-5, then the sub-channel domain name of the rewritten configuration information No. 2 is domain name B-5.

[0088] In this embodiment, after determining that the domain name information of the rewrite configuration information No. 3 is the domain name C, the configuration information storage area corresponding to the domain name C can be immediately found, and then the rewrite configuration information No. 3 is compared with the rewrite configuration information in the configuration information storage sub-area in the corresponding configuration information storage area. When no rewrite configuration information in a certain configuration information storage sub-area is found to be the same as the current rewrite configuration information No. 3, step L32 can be entered.

[0089] L32. When there is no rewrite configuration information identical to the downloaded rewrite configuration information in the configuration information storage unit, a new sub-channel domain name is generated, and the new sub-channel domain name is used as the sub-channel domain name of the downloaded rewrite configuration information; and the downloaded configuration information is stored in the configuration information storage unit through the new sub-channel domain name.

[0090] Assume that no configuration information storage sub-area with the same storage content as the rewritten configuration information No. 3 is found in the configuration information storage area named C domain name, and the names of the configuration information storage sub-areas already include C domain name-1 to C domain name-36.

[0091] Therefore, this embodiment first generates a new sub-channel domain name, which may be C domain name-37. This new sub-channel domain name (i.e., C domain name-37) is then used as the sub-channel domain name for rewriting configuration information No. 3. Furthermore, a configuration information storage sub-area named C domain name-37 is added to the configuration information storage area named C domain name, and the current rewriting configuration information No. 3 is stored in the corresponding configuration information storage sub-area for use in the next rewriting configuration information comparison.

[0092] L4. Store the downloaded rewrite configuration information in the shared memory through the domain name information and the sub-channel domain name.

[0093] In this embodiment, after the domain name information (domain name A) and the sub-channel domain name (domain name A-18) of the rewrite configuration information No. 1 are determined, the rewrite configuration information No. 1 can be stored in the shared memory through a folder, and the corresponding folder is named by domain name A plus domain name A-18.

[0094] After the domain name information (domain name B) and the sub-channel domain name (domain name B-5) of the rewritten configuration information No. 2 are determined, the rewritten configuration information No. 2 can be stored in the shared memory through a folder, and the corresponding folder is named by domain name B plus domain name B-5.

[0095] After the domain name information (C domain name) and the sub-channel domain name (C domain name-37) of the rewrite configuration information No. 3 are determined, the rewrite configuration information No. 3 can be stored in the shared memory through a folder, and the corresponding folder is named by C domain name plus C domain name-37.

[0096] S1. Get the initial m3u8 file.

[0097] Steps L1 to L4 only need to be prepared before step S1, and do not necessarily need to proceed to step S1 immediately after step L4 ends. In addition, because step L1 downloads rewrite configuration information No. 1, rewrite configuration information No. 2, and rewrite configuration information No. 3, it can be seen that the current rewrite demand is to rewrite m3u8 file No. A, m3u8 file No. B, and m3u8 file No. C, so step S1 first obtains the initial m3u8 file No. A, initial m3u8 file No. B, and initial m3u8 file No. C from the source station.

[0098] S2. Determine the domain name information corresponding to the initial m3u8 file.

[0099] The initial m3u8 file number A itself corresponds to a unique domain name, namely, domain name A. Therefore, the domain name information of the initial m3u8 file number A can be determined to be domain name A through the initial m3u8 file number A itself.

[0100] The initial m3u8 file number B itself corresponds to a unique domain name, namely the B domain name. Therefore, the domain name information of the initial m3u8 file number B itself can be determined to be the B domain name.

[0101] The initial C-number m3u8 file itself corresponds to a unique domain name, namely the C domain name. Therefore, the domain name information of the initial C-number m3u8 file itself can be determined to be the C domain name.

[0102] S3. Obtain rewriting configuration information corresponding to the initial m3u8 file from the shared memory according to the domain name information.

[0103] The folder storing the rewrite configuration information No. 1 in the shared memory can be found through domain name A. The name of the folder is domain name A+domain name A-18.

[0104] The folder storing the rewrite configuration information No. 2 in the shared memory can be found through the B domain name. The name of the folder is B domain name + B domain name - 5.

[0105] The folder storing the rewrite configuration information No. 3 in the shared memory can be found through the C domain name. The name of the folder is C domain name + C domain name - 37.

[0106] S4. Determine the sub-channel domain name and cache key corresponding to the initial m3u8 file.

[0107] Based on the name of the folder found by the initial m3u8 file A, it can be determined that the sub-channel domain name of the initial m3u8 file A is A domain name-18. The sub-channel domain name of the initial m3u8 file A is exactly the same as the sub-channel domain name of the rewritten configuration information No. 1. The cache key of the initial m3u8 file A is the unique identifier of the m3u8 file A. Each m3u8 file itself has a unique identifier, that is, the cache key of the initial m3u8 file A can be determined by the initial m3u8 file itself. Assume that the cache key of the initial m3u8 file A is 111111.

[0108] Based on the name of the folder found by the initial m3u8 file B, it can be determined that the sub-channel domain name of the initial m3u8 file B is B domain name-5. The sub-channel domain name of the initial m3u8 file B is exactly the same as the sub-channel domain name of the rewritten configuration information No. 2. The cache key of the initial m3u8 file B is the unique identifier of the m3u8 file B. Each m3u8 file itself has a unique identifier, that is, the cache key of the initial m3u8 file B can be determined by the initial m3u8 file itself. Assume that the cache key of the initial m3u8 file B is 222222.

[0109] Based on the name of the folder found by the initial m3u8 file C, it can be determined that the sub-channel domain name of the initial m3u8 file C is C domain name-37. The sub-channel domain name of the initial m3u8 file C is exactly the same as the sub-channel domain name of the rewritten configuration information No. 3. The cache key of the initial m3u8 file C is the unique identifier of the m3u8 file C. Each m3u8 file itself has a unique identifier, that is, the cache key of the initial m3u8 file C can be determined by the initial m3u8 file C itself. Assume that the cache key of the initial m3u8 file C is 333333.

[0110] S5. Look up the cache according to the cache key and the sub-channel domain name. When there is a corresponding cache, use the content in the corresponding cache as the rewritten m3u8 file; when there is no corresponding cache, rewrite the initial m3u8 file according to the rewrite configuration information to obtain the rewritten m3u8 file.

[0111] The present embodiment has many master caches, each of which is named by a cache key, and each master cache is used to store the content after the corresponding class m3u8 file is rewritten. For example, the master cache with a cache key of 111111 is used to store the content after the initial A m3u8 file is rewritten; the master cache with a cache key of 222222 is used to store the content after the initial B m3u8 file is rewritten; and the master cache with a cache key of 333333 is used to store the content after the initial C m3u8 file is rewritten.

[0112] Each main cache has multiple sub-caches, each sub-cache is named by a sub-channel domain name, and each main cache is used to store the content of the corresponding class m3u8 file after being rewritten by the corresponding rewrite configuration information. For example, the main cache with a cache key of 111111 has a sub-cache with a sub-channel domain name of domain name A-1 to a sub-cache with a sub-channel domain name of domain name A-22. The main cache with a cache key of 222222 has a sub-cache with a sub-channel domain name of domain name B-1 to a sub-cache with a sub-channel domain name of domain name B-20. The main cache with a cache key of 333333 has a sub-cache with a sub-channel domain name of domain name C-1 to a sub-cache with a sub-channel domain name of domain name C-36.

[0113] The present embodiment is obtaining initial A number m3u8 file, and after determining the sub-channel domain name (i.e. A domain name-18) and cache key (i.e. 11111) of initial A number m3u8 file, first find corresponding main cache (named 111111) according to cache key 111111, then find corresponding sub-cache (named A domain name-18) by sub-channel domain name A domain name-18.Owing to being able to find corresponding sub-cache, explanation has been carried out before that initial A number m3u8 file is rewritten this operation by No. 1 rewrite configuration information of the present embodiment, and the content of the A number m3u8 file after rewriting is exactly the content in the corresponding sub-cache.So the present embodiment directly outputs the content in the corresponding sub-cache as the content after initial A number m3u8 file is rewritten, and the present embodiment has omitted the concrete rewrite operation to initial A number m3u8 file.

[0114] The present embodiment is obtaining initial B number m3u8 file, and after determining the sub-channel domain name (i.e. B domain name-5) and cache key (i.e. 222222) of initial B number m3u8 file, first find corresponding main cache (named 222222) according to cache key 222222, then find corresponding sub-cache (named B domain name-5) by sub-channel domain name B domain name-5.Owing to being able to find corresponding sub-cache, explanation has been carried out before that initial B number m3u8 file is rewritten this operation by No. 2 rewrite configuration informations of the present embodiment, and the content of the B number m3u8 file after rewriting is exactly the content in the corresponding sub-cache.So the present embodiment directly outputs the content in the corresponding sub-cache as the content after initial B number m3u8 file is rewritten, and the present embodiment has omitted the concrete rewrite operation to initial B number m3u8 file.

[0115] The present embodiment, after obtaining initial C m3u8 file, and determining the sub-channel domain name (i.e. C domain name-37) and cache key (i.e. 333333) of initial C m3u8 file, first finds corresponding main cache (named 333333) according to cache key 333333, then searches for corresponding sub-cache (named C domain name-37) by sub-channel domain name C domain name-37. However, the present embodiment cannot find corresponding sub-cache, therefore, it is necessary to carry out specific rewrite operation to initial C m3u8 file.

[0116] Further, rewriting the initial m3u8 file according to the rewrite configuration information specifically includes the following steps:

[0117] S51. Generate a corresponding cache according to the cache key and the sub-channel domain name.

[0118] In this embodiment, a sub-cache named C domain name-37 is added to the main cache named 333333. The sub-cache is used to store the content after the initial C m3u8 file is rewritten by the rewriting configuration information No. 3 of this embodiment.

[0119] S52. reads a subfile in the initial m3u8 file, and determines whether the subfile meets the truncation condition. When the subfile meets the truncation condition, cuts the corresponding subfile, and reads the next subfile in the initial m3u8 file.

[0120] As shown in Figure 3, the m3u8 file contains sub-files, and one sub-file is set per line.

[0121] The present embodiment first reads the 1st subfile in the initial C m3u8 file, i.e. the subfile in row 1. Then determine whether the subfile meets the truncation condition. Meeting the truncation condition indicates that the corresponding subfile is a bad file and needs to be discarded.

[0122] Determining whether the subfile meets the truncation condition specifically includes the following steps:

[0123] S521. Obtain the cumulative duration of the slices in the subfile and compare the cumulative duration of the slices in the subfile with a preset time threshold. Assume that the preset time threshold in this embodiment is 10 seconds and the cumulative duration of the slices in the first subfile is 5 seconds.

[0124] S522. Obtain the total number of slices in the subfiles and compare the total number of slices in the subfiles with a preset number threshold. Assume that the preset number threshold in this embodiment is 20 slices. The total number of slices in the first subfile is 21 slices.

[0125] S523. When the cumulative duration of the slices in the subfile is less than the preset time threshold or the total number of slices in the subfile is greater than the preset number threshold, the subfile is determined to meet the truncation condition; otherwise, the subfile is determined to not meet the truncation condition. Because the total number of slices in the first subfile (21 slices) is greater than the preset number threshold (20 slices) in this embodiment, the first subfile is determined to meet the truncation condition. Therefore, the corresponding subfile is truncated (i.e., the first subfile is skipped and discarded), and the process returns to step S52.

[0126] Continue to read the 2nd subfile in initial C m3u8 file, i.e. the subfile in row 2. Then judge whether this subfile meets the cut-off condition, suppose that the 2nd subfile does not meet the cut-off condition, i.e. the 2nd subfile is a normal file, can not discard, then enter step S53.

[0127] S53. When the sub-file does not meet the truncation condition, determine whether the sub-file meets the editing condition. When the sub-file does not meet the editing condition, write the sub-file into the cache and read the next sub-file in the initial m3u8 file.

[0128] Determining whether the sub-file meets the editing conditions specifically includes the following steps:

[0129] S531. Determine the type of the sub-file. The sub-files in the m3u8 file have various types, some of which do not need to be edited, while others need to be edited and rewritten.

[0130] S532. If the sub-file is a file of the url type, determine that the sub-file meets the editing condition; otherwise, determine that the sub-file does not meet the editing condition. In this embodiment, the url type sub-file is regarded as a sub-file that needs to be edited and rewritten.

[0131] Assuming that the second sub-file in this embodiment is not a sub-file of the url type, it means that the second sub-file does not need to be edited, and the second sub-file is directly written into the sub-cache named C domain name-37, and then returns to step S52.

[0132] Continue to read the 3rd subfile in initial C m3u8 file, i.e. the subfile in the 3rd row. Then determine whether this subfile meets the cut-off condition, assuming that the 3rd subfile does not meet the cut-off condition. Then determine whether the 3rd subfile meets the editing condition, assuming that the 3rd subfile meets the editing condition, then enter step S54.

[0133] S54. When the sub-file meets the editing condition, the sub-file is edited according to the rewriting configuration information, and the edited sub-file is written into the cache, and the next sub-file in the initial m3u8 file is read.

[0134] In this embodiment, the third subfile is edited and rewritten based on rewriting configuration information No. 3. The specific editing and rewriting methods directly adopt existing technologies. For example, the request protocol, request host name, and other content are rewritten. After the third subfile is rewritten, the third subfile is written to the subcache named C domain name-37, and then the process returns to step S52.

[0135] Continue to read the 4th sub-file in the initial C m3u8 file...and continue the cycle.

[0136] S55. When the next sub-file in the initial m3u8 file cannot be read, the content in the corresponding cache is used as the rewritten m3u8 file.

[0137] When all sub-files in the initial C m3u8 file are read, the content in the sub-cache named C domain name-37 is output as the content after rewriting the initial C m3u8 file, and the sub-cache named C domain name-37 is saved in the main cache named 333333.

[0138] The m3u8 file rewriting method in the present embodiment can store the rewritten m3u8 file content, and when the same m3u8 file needs to be rewritten next time, directly call the corresponding rewrite content, so that the rewrite operation of the m3u8 file will be easier, and the rewrite cycle of the m3u8 file can be shortened.

[0139] Embodiment 2: A universal m3u8 file rewriting system is used to implement the m3u8 file rewriting method described in Embodiment 1. As shown in Figure 2, the system includes: a configuration information downloading module, a first domain name information determination module, a first sub-channel domain name determination module, a configuration information storage module, a file acquisition module, a second domain name information determination module, a configuration information acquisition module, a second sub-channel domain name determination module, a cache key determination module, a cache search module, a first rewriting file determination module and a second rewriting file determination module.

[0140] The configuration information downloading module is used to download the rewriting configuration information. The first domain name information determining module is used to determine the domain name information of the downloaded rewriting configuration information. The first sub-channel domain name determining module is used to determine the sub-channel domain name of the downloaded rewriting configuration information.

[0141] The first sub-channel domain name determination module specifically includes: a configuration information comparison unit, a first sub-channel domain name determination unit, a sub-channel domain name generation unit, a second sub-channel domain name determination unit, and a configuration information storage unit. The configuration information comparison unit is configured to compare the downloaded rewritten configuration information with the rewritten configuration information in the configuration information storage unit. The first sub-channel domain name determination unit is configured to, when the configuration information storage unit contains rewritten configuration information identical to the downloaded rewritten configuration information, use the sub-channel domain name of the corresponding rewritten configuration information in the configuration information storage unit as the sub-channel domain name of the downloaded rewritten configuration information. The sub-channel domain name generation unit is configured to, when the configuration information storage unit does not contain rewritten configuration information identical to the downloaded rewritten configuration information, generate a new sub-channel domain name. The second sub-channel domain name determination unit is configured to use the new sub-channel domain name as the sub-channel domain name of the downloaded rewritten configuration information. The configuration information storage unit is configured to store the downloaded configuration information using the new sub-channel domain name.

[0142] The configuration information storage module is used to store the downloaded rewrite configuration information in the shared memory using the domain name information and the sub-channel domain name. The file acquisition module is used to obtain the initial m3u8 file. The second domain name information determination module is used to determine the domain name information corresponding to the initial m3u8 file. The configuration information acquisition module is used to obtain the rewrite configuration information corresponding to the initial m3u8 file from the shared memory based on the domain name information. The second sub-channel domain name determination module is used to determine the sub-channel domain name corresponding to the initial m3u8 file. The cache key determination module is used to determine the cache key corresponding to the initial m3u8 file. The cache search module is used to search the cache based on the cache key and the sub-channel domain name. The first rewrite file determination module is used to use the content in the corresponding cache as the rewritten m3u8 file when a corresponding cache exists. The second rewrite file determination module is used to rewrite the initial m3u8 file according to the rewrite configuration information to obtain the rewritten m3u8 file when a corresponding cache does not exist.

[0143] The second rewrite file determination module specifically includes: a cache generation unit, a subfile reading unit, a first subfile determination unit, a file truncation unit, a second subfile determination unit, a first subfile writing unit, a subfile editing unit, a second subfile writing unit, and a rewrite file determination unit. The cache generation unit is configured to generate a corresponding cache based on the cache key and the sub-channel domain name. The subfile reading unit is configured to read a subfile from the initial m3u8 file. The first subfile determination unit is configured to determine whether the subfile meets the truncation condition. The file truncation unit is configured to truncate the corresponding subfile if the subfile meets the truncation condition. The second subfile determination unit is configured to determine whether the subfile meets the editing condition if the subfile does not meet the truncation condition. The first subfile writing unit is configured to write the subfile into the cache if the subfile does not meet the editing condition. The subfile editing unit is configured to edit the subfile according to the rewrite configuration information if the subfile meets the editing condition. The second subfile writing unit is configured to write the edited subfile into the cache. The rewriting file determining unit is used for using the content in the corresponding cache as the rewritten m3u8 file when the next sub-file in the initial m3u8 file cannot be read.

[0144] Among them, the first sub-file determination unit specifically includes: a cumulative duration acquisition sub-unit, a cumulative duration comparison sub-unit, a total number acquisition sub-unit, a total number comparison sub-unit and a first determination result determination sub-unit. The cumulative duration acquisition sub-unit is used to obtain the cumulative duration of the slices in the sub-file. The cumulative duration comparison sub-unit is used to compare the cumulative duration of the slices in the sub-file with a preset time threshold. The total number acquisition sub-unit is used to obtain the total number of slices in the sub-file. The total number comparison sub-unit is used to compare the total number of slices in the sub-file with a preset number threshold. The first determination result determination sub-unit is used to determine that the sub-file meets the truncation condition when the cumulative duration of the slices in the sub-file is less than the preset time threshold or the total number of slices in the sub-file is greater than the preset number threshold; otherwise, it is determined that the sub-file does not meet the truncation condition.

[0145] The second sub-file determination unit specifically includes a type determination sub-unit and a second determination result determination sub-unit. The type determination sub-unit is configured to determine the type of the sub-file. The second determination result determination sub-unit is configured to determine that the sub-file meets the editing condition if the sub-file is a URL type file; otherwise, determine that the sub-file does not meet the editing condition.

[0146] The m3u8 file rewriting system in the present embodiment can store the rewritten m3u8 file content. When the same m3u8 file needs to be rewritten next time, the corresponding rewrite content can be directly called, so that the rewrite operation of the m3u8 file is more simple and convenient, and the rewrite cycle of the m3u8 file can be shortened.

[0147] Although certain embodiments of the present specification are shown in the accompanying drawings, it should be understood that the present specification can be implemented in various forms and should not be construed as limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present specification. It should be understood that the drawings and embodiments of the present specification are for illustrative purposes only and are not intended to limit the scope of protection of the present specification.

Claims

1. A general m3u8 file rewriting method comprises the following steps: Download and rewrite configuration information; Determine the domain name information of the downloaded rewriting configuration information; Determine the sub-channel domain name of the downloaded rewrite configuration information; The downloaded rewriting configuration information is stored in the shared memory through the domain name information and the sub-channel domain name; Get the initial m3u8 file; Determine the domain name information corresponding to the initial m3u8 file; Obtaining rewrite configuration information corresponding to the initial m3u8 file from the shared memory according to the domain name information; Determine the sub-channel domain name and cache key corresponding to the initial m3u8 file; Search the cache according to the cache key and the sub-channel domain name, and when a corresponding cache exists, use the content in the corresponding cache as the rewritten m3u8 file; When there is no corresponding cache, the initial m3u8 file is rewritten according to the rewriting configuration information to obtain a rewritten m3u8 file.

2. m3u8 file rewriting method according to claim 1, determining the sub-channel domain name of the downloaded rewrite configuration information specifically comprises the following steps: Comparing the downloaded rewriting configuration information with the rewriting configuration information in the configuration information storage unit, when the configuration information storage unit contains the same rewriting configuration information as the downloaded rewriting configuration information, using the sub-channel domain name of the corresponding rewriting configuration information in the configuration information storage unit as the sub-channel domain name of the downloaded rewriting configuration information; When there is no rewrite configuration information identical to the downloaded rewrite configuration information in the configuration information storage unit, a new sub-channel domain name is generated, and the new sub-channel domain name is used as the sub-channel domain name of the downloaded rewrite configuration information; and the downloaded configuration information is stored in the configuration information storage unit via the new sub-channel domain name.

3. m3u8 file rewriting method according to claim 1, rewriting the initial m3u8 file according to the rewrite configuration information specifically comprises the following steps: Generate a corresponding cache according to the cache key and the sub-channel domain name; Read a subfile in the initial m3u8 file, and determine whether the subfile meets the truncation condition. When the subfile meets the truncation condition, truncate the corresponding subfile and read the next subfile in the initial m3u8 file; When the sub-file does not meet the truncation condition, determine whether the sub-file meets the editing condition, and when the sub-file does not meet the editing condition, write the sub-file into the cache, and read the next sub-file in the initial m3u8 file; When the sub-file meets the editing condition, the sub-file is edited according to the rewrite configuration information, and the edited sub-file is written into the cache, and the next sub-file in the initial m3u8 file is read; When the next sub-file in the initial m3u8 file cannot be read, the content in the corresponding cache is used as the rewritten m3u8 document.

4. m3u8 file rewriting method according to claim 3, judging whether described subfile meets the truncation condition specifically comprises the following steps: Obtain the cumulative duration of the slices in the subfile, and compare the cumulative duration of the slices in the subfile with a preset time threshold; Obtain the total number of slices in the subfile, and compare the total number of slices in the subfile with a preset number threshold; When the cumulative duration of the slices in the sub-file is less than a preset time threshold or the total number of slices in the sub-file is greater than a preset number threshold, the sub-file is determined to meet the truncation condition; otherwise, the sub-file is determined not to meet the truncation condition.

5. m3u8 file rewriting method according to claim 3, judging whether described subfile meets editing condition specifically comprises the following steps: Determine the type of the sub-file; When the sub-file is a file of the url type, it is determined that the sub-file meets the editing condition; otherwise, it is determined that the sub-file does not meet the editing condition.

6. A universal m3u8 file rewriting system, comprising: Configuration information download module, used to download and rewrite configuration information; A first domain name information determination module, used to determine the domain name information of the downloaded rewriting configuration information; A first sub-channel domain name determination module, used to determine the sub-channel domain name of the downloaded rewriting configuration information; A configuration information storage module, used to store the downloaded rewrite configuration information in a shared memory through domain name information and sub-channel domain names; File acquisition module, used to obtain the initial m3u8 file; A second domain name information determination module, used to determine the domain name information corresponding to the initial m3u8 file; A configuration information acquisition module, used for acquiring the rewriting configuration information corresponding to the initial m3u8 file from the shared memory according to the domain name information; A second sub-channel domain name determination module is used to determine the sub-channel domain name corresponding to the initial m3u8 file; A cache key determination module, used to determine a cache key corresponding to the initial m3u8 file; A cache search module, used to search the cache according to the cache key and the sub-channel domain name; A first rewriting file determination module is used for, when a corresponding cache exists, using the content in the corresponding cache as the rewritten m3u8 file; The second rewriting file determination module is used to rewrite the initial m3u8 file according to the rewriting configuration information to obtain a rewritten m3u8 file when there is no corresponding cache.

7. The m3u8 file rewriting system according to claim 6, wherein the first sub-channel domain name determination module specifically comprises: A configuration information comparison unit, used to compare the downloaded rewrite configuration information with the rewrite configuration information in the configuration information storage unit; a first sub-channel domain name determining unit, configured to, when the configuration information storage unit contains rewriting configuration information identical to the downloaded rewriting configuration information, use the sub-channel domain name of the corresponding rewriting configuration information in the configuration information storage unit as the sub-channel domain name of the downloaded rewriting configuration information; A sub-channel domain name generating unit, for generating a new sub-channel domain name when there is no rewriting configuration information identical to the downloaded rewriting configuration information in the configuration information storage unit; The second sub-channel domain name determination unit is used to use the new sub-channel domain name as the sub-channel domain name of the downloaded rewritten configuration information; the configuration information storage unit is used to store the downloaded configuration information through the new sub-channel domain name.

8. According to the m3u8 file rewriting system of claim 6, the second rewriting file determination module specifically comprises: A cache generation unit, used to generate a corresponding cache according to the cache key and the sub-channel domain name; A sub-file reading unit is used to read a sub-file in the initial m3u8 file; A first sub-file determination unit, used to determine whether the sub-file meets the truncation condition; A file truncation unit, used to truncate the corresponding sub-file when the sub-file meets the truncation condition; A second sub-file determination unit, configured to determine whether the sub-file meets the editing condition when the sub-file does not meet the truncation condition; A first sub-file writing unit, configured to write the sub-file into the cache when the sub-file does not meet the editing condition; A sub-file editing unit, configured to edit the sub-file according to the rewriting configuration information when the sub-file meets the editing condition; A second sub-file writing unit, used for writing the edited sub-file into the cache; The rewritten file determination unit is used to use the content in the corresponding cache as the rewritten m3u8 file when the next sub-file in the initial m3u8 file cannot be read.

9. The m3u8 file rewriting system according to claim 8, wherein the first sub-file determination unit specifically comprises: The cumulative duration acquisition subunit is used to obtain the cumulative duration of the slices in the subfile; The cumulative duration comparison subunit is used to compare the cumulative duration of the slices in the subfile with a preset time threshold; The total number acquisition subunit is used to obtain the total number of slices in the subfile; A total number comparison subunit, used to compare the total number of slices in the subfile with a preset number threshold; A first determination result determination subunit, configured to determine that the subfile meets a truncation condition when the cumulative duration of the slices in the subfile is less than a preset time threshold or the total number of the slices in the subfile is greater than a preset number threshold; Otherwise, determine the The subfile is not eligible for truncation.

10. The m3u8 file rewriting system according to claim 8, wherein the second sub-file determination unit specifically comprises: A type determination subunit, used to determine the type of the subfile; The second determination result determination subunit is used to determine that the subfile meets the editing condition when the subfile is a file of the url type; otherwise, determine that the subfile does not meet the editing condition.

Citation Information

Patent Citations

  • Display apparatus, content displaying method, and non-transitory recording medium

    CN108665303A

  • Media file acquisition method and device and storage medium

    CN110309342A

  • Configuration data adding method, device and system for CDN

    CN111314726A

  • Universal m3u8 file rewriting method and system

    CN116339817A

  • Systems and methods for midstream selection of content to insert into a media stream

    US20220030315A1