Time sequence processing method based on HLS slicing

By employing a layered and progressive hybrid detection method and pre-generated placeholder video segments, the problems of inaccurate duration detection and insufficient interruption detection in HLS slice timing processing are solved, achieving efficient video playback continuity and improved user experience.

CN121636746APending Publication Date: 2026-03-10CHENGDU JIUZHOU ELECTRONIC INFORMATION SYSTEM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-16
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing technologies in HLS slice timing processing suffer from inaccurate slice file duration detection, a trade-off between index reconstruction performance and storage consumption, and insufficient video interruption detection and filling functions, which affect the continuity of video playback and user experience.

Method used

A layered and progressive hybrid detection method is adopted. By using path parsing, adjacent file verification and streaming media processing tools, a slice file index database is built. Combined with an asynchronous thread pool and pre-generated placeholder video clips, the accuracy of slice file duration detection and automatic filling of interruptions are achieved.

Benefits of technology

It improves the accuracy and efficiency of segment file duration detection, reduces resource consumption, ensures the continuity of video playback and user experience, and reduces the overall time from 12 hours in the traditional method to about 1 hour, with duration extraction efficiency improved by more than 95%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121636746A_ABST
    Figure CN121636746A_ABST
Patent Text Reader

Abstract

The invention relates to the field of streaming media service and video processing, and discloses an HLS slice-based time sequence processing method, which comprises the following steps of: capturing at least one HLS main index file and a plurality of slice files based on a video stream; constructing a slice file index database without initial duration information; obtaining the recorded duration of the slice file from the HLS main index file, and updating the duration to an index database; for the slice file of which the duration is not obtained, comparing the sequence number sequence of the slice files in the video stream, and if the sum of the starting time of the current slice and the preset slice duration is equal to the starting time of the slice file corresponding to the next sequence number, taking the preset slice duration as the second duration of the current slice file; for the slice file of which the duration is still not acquired, acquiring the duration of the slice file by means of a streaming media processing tool, and updating a database; and finally, for the condition that the video stream is cut off, carrying out occupied filling, thereby realizing effective acquisition and management of the duration of the HLS slice file, and ensuring the integrity of video stream processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of streaming media services and video processing, and more particularly to a timing processing method based on HLS slicing. Background Technology

[0002] HLS, an HTTP-based streaming media protocol, is widely used in live video streaming and video-on-demand scenarios due to its advantages such as adaptive bitrate, broad compatibility, and robust reliability, providing users with a smooth viewing experience. In scenarios where video-on-demand and surveillance are integrated, it is often necessary to associate a video stream within a specific business-related time period with specific business information, such as business ID, video start time, and end time, so that users can quickly locate and play back the corresponding video content according to their business needs. However, existing technologies still have the following problems when processing the above data: 1. The video stream slice file index lacks accurate duration information. Typically, real-time video streams are segmented into slice files based on a fixed set duration (e.g., 30 seconds), and HLS index files are output synchronously during video stream transmission. However, the actual duration of the generated slices is not strictly equal to the set duration; some slices may exceed the set value (e.g., 31 seconds, 32 seconds, etc.), while the last slice is often shorter than the set duration.

[0003] Currently, most methods for detecting video segment duration include: relying solely on filenames or video paths, or relying solely on calling tools like FFprobe to obtain the duration of each segment file. These methods lack multi-level, end-to-end detection mechanisms, resulting in incomplete duration detection mechanisms and simplistic implementations. Such a single method of detecting the duration of a segment file may fail to obtain the actual duration of the segment, thus making it impossible to accurately locate the corresponding segment file within the start-to-end time interval specified by the business logic.

[0004] 2. The conflict between index rebuilding performance and storage consumption If the segment duration is obtained solely by filename or video path, and the main index file is not updated in time due to network latency or server failure (e.g., newly added segments are not written to the index), the detected duration will lag behind the actual video stream, compromising the index's accuracy. If the duration is obtained by calling tools like FFprobe for each segment file and then written to the segment file index database, significant I / O and CPU overhead will occur. When a large number of segment files accumulate from a single stream, analyzing them one by one with FFprobe will generate massive decoding and disk read / write operations in a short period, impacting real-time service.

[0005] 3. Insufficient video interruption detection and compensation functions. In real-world scenarios, due to the complexity of network environments, there may be missed detections during stream interruption detection. If blank segments cannot be detected in time, they cannot be filled in promptly, severely impacting playback continuity. Existing technologies also lack a unified mechanism for filling in placeholder videos. Developers often need to manually generate missing blank segments using FFmpeg at the business layer based on the blank time period and then stitch them together as placeholder segments. This process is inefficient because FFmpeg is mostly a single-process synchronous process, and processing long blank segments is time-consuming; moreover, the parameters of the placeholder segments are prone to differ from the original video, resulting in poor stitching quality. Even pre-generating standard-length placeholder segments faces the problem of high resource consumption: corresponding templates need to be generated for multi-bitrate and multi-resolution streams, storage resources increase dramatically with the number of variants, and pre-computation also consumes a lot of computing power, affecting normal streaming media processing.

[0006] In summary, the main bottlenecks of existing technologies in HLS slice timing processing are: the inability to obtain the precise duration of slice files, the imperfect duration detection mechanism, the single implementation method, and the difficulty in accurately locating slices for a specified time period; the contradiction between index reconstruction performance and storage consumption; and the insufficient video interruption detection and filling functions. These shortcomings will result in the inability to present a complete playback interface to the user when the camera is interrupted or the network fluctuates, which seriously affects the availability of the system and user satisfaction. Summary of the Invention

[0007] To address the aforementioned technical problems, this invention provides a timing processing method based on HLS slices, the specific steps of which include: S1. Capture at least one HLS master index file and multiple slice files based on the video stream; S2. Construct an initial, time-limit-free slice file index database based on the aforementioned multiple slice files; S311. Based on the at least one HLS master index file, obtain the duration of the recorded slice file as the first duration, and update the obtained first duration to the slice file index database; S312. For a slice file whose duration has not been obtained, compare the sequence number order of the slice files in the video stream. If the start time of the current slice plus the preset slice duration equals the start time of the slice file corresponding to the next sequence number, then the duration of the current slice file is the preset slice duration and is used as the second duration. S313. For slice files whose duration has not yet been obtained, the duration of the slice file is obtained through streaming media processing tools as the third duration; S32. To fill in placeholders when there are interruptions in the video stream.

[0008] Preferably, the method for obtaining the HLS master index file includes: listening to the network hook callback events of the streaming media server through a sidecar proxy to perceive the file name, start time, and file path of the video stream.

[0009] Preferably, the processing method of the HLS master index file includes: renaming the master index file with the start time of the video as a marker.

[0010] Preferably, the method for obtaining the third duration includes: submitting the path of the segment file whose duration has not yet been obtained to the verification pool of the streaming media processing tool, executing the streaming media processing tool through an asynchronous thread pool to obtain the third duration, and writing the third duration into the segment file index database.

[0011] Preferably, after writing the third duration into the slice file index database, the third duration is then updated in the local cache.

[0012] Preferably, before using the streaming media processing tool, it is first checked whether there is already a duration record corresponding to the slice file path in the local cache; if so, the corresponding third duration is directly updated to the slice file index database.

[0013] Preferably, the placeholder filling method includes: S321. Obtain multiple placeholder video clips and generate a combination of placeholder video clips of several durations; S322. The duration to be filled at the interruption point is taken as the filling duration, and the combination of the placeholder video segments is matched according to the filling duration as the filling slice; S323. Update the storage path of the filled slice and the filling duration to the HLS index file.

[0014] Preferably, the method for generating a combination of placeholder video clips of several durations includes: Define a set of preset durations; A combination of several different placeholder video segments is obtained based on different durations in the preset duration set.

[0015] Preferably, the method for generating the fill slice includes: splicing together the placeholder video segments in the placeholder video segment combination to obtain the fill slice.

[0016] Preferably, the combination of placeholder video clips should meet the following conditions: The sum of the durations of each placeholder video segment equals the filling duration; Minimize the number of placeholder video segments.

[0017] Compared with the prior art, the present invention has the following beneficial effects: This invention proposes an HLS segment timing processing method, forming a layered, progressive hybrid detection approach: "path resolution → adjacent file verification → streaming media processing tools." This method effectively solves the problems of insufficient accuracy and low efficiency in existing techniques for duration detection. In terms of accuracy, multi-level detection eliminates the defects of single-detection methods, significantly reducing the detection error rate. In terms of efficiency, the layered strategy of prioritizing lightweight detection and supplementing it with heavy tool verification significantly reduces resource consumption, meeting the real-time detection requirements of continuous video streams. It can achieve duration detection and rapid index construction for massive amounts of segment files. Experimental verification shows that when processing 100,000-level segment files, the overall processing time is reduced from 12 hours using traditional methods to approximately 1 hour, with duration extraction efficiency improved by over 95%. For interruptions in the video stream, a placeholder filling method automatically identifies and fills in the interrupted segments, ensuring the continuity and integrity of video playback. By pre-generating placeholder segments of various durations, optimal segment combination filling can be completed within milliseconds, ensuring no deviation between the player's indexed playback duration and the actual recording duration, greatly improving playback continuity and user experience. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of an HLS slice timing processing method provided in a preferred embodiment of the present invention; Figure 2 This is a flowchart of the slice timing processing with added real-time monitoring and the introduction of a supplementary recording mechanism provided in a preferred embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Example 1 In existing HLS streaming media transmissions, players often rely on the #EXTINF tag in the master index file (.m3u8) to determine the duration of each segment. However, on some platforms or in environments with weak signals, the master index may be incomplete, potentially missing some duration information, which limits the player's skipping, preloading, and playback positioning functions. Furthermore, relying entirely on the server's master index file cannot dynamically adapt to actual changes in the segment files.

[0022] In addition, some technical solutions rely solely on tools such as FFmpeg (e.g., the ffprobe command) to extract duration information from each slice file. Although this method has high accuracy, it has drawbacks such as low processing efficiency, high computational overhead, and is not suitable for large-scale real-time streaming. Especially in environments with a large number of slices or poor network conditions, frequent calls to external parsing tools may lead to system response delays and affect overall performance.

[0023] like Figure 1 As shown, this embodiment provides an HLS slice timing processing method, including the following steps: S1. Capture at least one HLS master index file and multiple slice files based on the video stream.

[0024] In some preferred embodiments, the HLS master index file, i.e., m3u8, lists the names and partial duration information of the video slice files; the slice files, i.e., ts slice files, are used to store short-duration video segments, and each file is called a slice.

[0025] Obtain an m3u8 index file and multiple corresponding ts slice files from the video stream or server. The m3u8 index file contains the slice playback order and the #EXTINF tag information for some slices, while the ts slice files contain the actual media content.

[0026] S2. Construct an initial, time-limit-free slice file index database based on the aforementioned multiple slice files.

[0027] In some preferred embodiments, the slice file index database can be in the form of a database table, or it can be a reasonable design by those skilled in the art based on the actual situation or site requirements. The slice file index database explicitly records information such as the file name, start time, duration, and data source of each slice.

[0028] In some preferred embodiments, the slice file index database can be constructed sequentially by extracting the initial time and sequence number based on the file path; alternatively, it can be a reasonable design by those skilled in the art based on actual conditions or site requirements. The initially constructed slice index database includes the following fields: file name; Start time field; Serial number; File path.

[0029] S311. Based on the at least one HLS master index file, obtain the duration of the recorded slice file as the first duration, and update the slice file index database with the obtained first duration.

[0030] In some preferred embodiments, the first duration is the duration of the TS slice file directly read from the m3u8 file. The duration information contained in each "#EXTINF:" tag is parsed from the m3u8 index file, and this duration is used as the first duration and filled into the duration field of the corresponding slice. The m3u8 index file is read line by line; if "#EXTINF:x.xxxx" is detected, the next line containing the TS slice file name is read and a corresponding relationship is established.

[0031] S312. For a slice file whose duration has not been obtained, compare the sequence number order of the slice files in the video stream. If the start time of the current slice plus the preset slice duration equals the start time of the slice file corresponding to the next sequence number, then the duration of the current slice file is the preset slice duration, which is used as the second duration.

[0032] In some preferred embodiments, the preset slice duration can be 10 seconds, or it can be a reasonable design by those skilled in the art based on actual conditions or site requirements. For slice files lacking #EXTINF tag information, if the slice's start time information is available (such as player recordings or timestamps), the duration of the current slice can be inferred by calculating the start time difference between adjacent slices. If the segment file is segment_ i The start time is T i segment_{ i The starting time of +1} is T i+1 The duration of the current slice is inferred to be T. i+1 -T i ; If the inferred duration of the current slice file is equal to the preset slice duration of 10 seconds, then the inferred result is updated in the slice file index database; if the inferred value is abnormal (such as being negative or greater than the threshold of 9 seconds or 11 seconds), then it is skipped.

[0033] S313. For slice files whose duration has not yet been obtained, obtain the duration of the slice file through the streaming media processing tool as the third duration.

[0034] In some preferred embodiments, the third duration is the duration of the TS segment file obtained by the streaming media processing tool; for TS segment files skipped in step S312, the streaming media processing tool FFprobe is called to parse them and extract the third duration of the TS segment. An asynchronous thread pool is used to execute commands. This mechanism, by reusing threads and executing non-blockingly, can fully utilize system resources while ensuring the smooth operation of the main thread, making it particularly suitable for batch processing of file path verification needs.

[0035] In some preferred embodiments, the asynchronous thread pool executes commands as follows: ffprobe -v error -show_entries format=duration\ -of default=noprint_wrappers=1:nokey=1\ <ts_path> The meanings of its main parameters are explained below: The "-v error" field indicates that the log level is set to error, and only error messages will be output. The “show_entries format=duration” field indicates the metadata entries to be displayed, mainly the duration field in the format (i.e., file format information). This field is selected because it is used to detect the duration of sliced ​​files. In the field "-of default=noprint_wrappers=1:nokey=1", "-of default" indicates that the default output format is used, which is essentially a simplified INI-like structure; "noprint_wrappers=1" means that the header and footer wrapping information (such as "FORMAT" and " / FORMAT") are not printed; "nokey=1" means that the field name "duration=" is not displayed, and only the duration value itself is output. This can reduce redundant information, reduce parsing costs, and make pure numerical output easier to import into the slice file index database when processing massive slice files.

[0036] “<ts_path> "Field: Indicates the input file path, usually a .ts format video file, specifying the target file to be analyzed; The above command was executed successfully, and the output is a simple numerical value.

[0037] S32. To fill in placeholders when there are interruptions in the video stream.

[0038] In some preferred embodiments, the placeholder filling method includes the following steps: acquiring multiple placeholder video segments using a streaming media tool, generating a combination of placeholder video segments of several durations; using the duration to be filled at the interruption point as the filling duration, and matching the combination of placeholder video segments according to the filling duration as a filling slice; updating the storage path of the filling slice and the filling duration in the HLS index file. This addresses the issue of interruptions in the video stream.

[0039] Example 2 like Figure 2 As shown, in some embodiments, real-time monitoring capabilities are added based on Embodiment 1, including: real-time monitoring of changes in the HLS master index file under the video stream directory, parsing newly added slice files, and re-executing steps S311-S313 to achieve incremental updates. In other embodiments, a supplementary recording mechanism for the slice file index database is introduced based on Embodiment 1, including: periodically scanning the slice file index database, and performing steps S311-S313 on slice files not recorded in the slice file index database to achieve supplementary recording.

[0040] Example 3 Based on Example 1, this example is used to obtain the HLS master index file.

[0041] The HLS master index file is typically stored in the public path of the streaming media server. Common methods for obtaining the HLS master index file include polling or active querying. In these traditional methods, the client or processor often needs to periodically retrieve or brute-force scan the server directory to obtain newly generated index files. This results in a failure to respond in real-time to updates to the master index file, potentially leading to missed segment processing or delayed duration information. These methods suffer from low real-time performance, low efficiency in obtaining the HLS master index file, and high resource consumption. To address these issues, in some preferred embodiments, this invention uses a sidecar proxy to monitor network hook callback events of the streaming media server to perceive the video stream's filename, start time, and file path, thereby obtaining the HLS master index file.

[0042] In this embodiment, the HLS master index file can be obtained immediately when the network hook callback event occurs, which is more real-time and consumes relatively less resources.

[0043] Example 4 Based on Example 1, this example is used to process the HLS master index file to facilitate subsequent tracing and slice file index verification.

[0044] In existing technologies, HLS master index files typically use fixed filenames (such as index.m3u8) and are continuously overwritten and updated, lacking explicit time identifiers. Without processing this master index file, the system will struggle to determine the start time of the video stream corresponding to the master index file, thus affecting the accurate matching of slice durations with the playback timeline. Furthermore, if multiple master index files need to be stored for comparison, backtracking, or slice file index database management, fixed filenames can cause naming conflicts and index confusion; they may also lead to abnormal slice file sorting and incorrect durations, affecting the accuracy of slice duration detection and the reliability of the system.

[0045] In some preferred embodiments, the HLS master index file can be processed by renaming it with the start time of the video as a marker, or by a reasonable design by those skilled in the art based on the actual situation or on-site needs, to facilitate subsequent tracing and verification of the slice file index.

[0046] Example 5 Based on Example 1, this example uses a streaming media processing tool to obtain the third duration.

[0047] In existing technologies, some techniques use MP4Box or MediaInfo tools to obtain the duration. MP4Box primarily targets files with .mp4 structures and has poor support for HLS segments of type .ts. During parsing, it often fails to obtain a valid duration due to a lack of complete encapsulation header information or keyframe indexes. While MediaInfo can display various audio and video metadata, it lacks the flexibility and robustness for programmatic systems, and has a high probability of parsing failure when dealing with segment files with encoding anomalies or missing frames. To address these issues, in some preferred embodiments, obtaining the third duration using the streaming media processing tool can be achieved by using the streaming media processing tool FFprobe to parse the segment files. First, the path of the segment file whose duration has not yet been obtained is submitted to the verification pool of the streaming media processing tool. Then, the streaming media processing tool is executed through an asynchronous thread pool to obtain the third duration. Finally, the third duration is written to the segment file index database.

[0048] This embodiment, by reusing threads and executing non-blockingly, can make full use of system resources while ensuring the smooth operation of the main thread, making it particularly suitable for batch processing of file path verification needs.

[0049] Example 6 Based on Example 1, this example also performs local caching operations on the third duration.

[0050] After the third duration is written to the slice file index database, if the third duration is not synchronously updated to the local cache, the following problem may occur: the system still needs to frequently read duration information from the slice file index database in subsequent processing, causing data access delays or wasted read and write resources. To solve the above problems, in some preferred embodiments, after the third duration is written to the slice file index database, the third duration can be updated to the local cache.

[0051] This embodiment can effectively reduce the frequency of reading and writing to the slice file index database, improve the overall efficiency of video stream processing, and avoid repeated processing of slice files for extracting the third duration.

[0052] Example 7 Based on Example 1, this example introduces a local cache hit priority mechanism.

[0053] Typically, the duration of a segment file is obtained directly using streaming media processing tools for duration parsing. This approach does not check whether the duration record for the segment file already exists in the local cache. This could lead to situations where some segment files have already obtained their third duration in historical processing and are cached locally, but due to the lack of cache checks, they are still repeatedly submitted to the streaming media processing tool, resulting in computational redundancy and wasted computing resources. In some preferred embodiments, before the streaming media processing tool is used, the local cache is checked to see if a duration record corresponding to the segment file path already exists. If so, the corresponding third duration is directly updated to the segment file index database.

[0054] This embodiment saves resources by checking the local cache before calling the streaming media processing tool. For existing segment file duration records, the parsing step of the streaming media processing tool is skipped.

[0055] Example 8 Based on Example 1, this example provides a placeholder filling method.

[0056] Existing technologies often employ real-time encoding to handle video interruptions. This approach encodes the unsignaled content in real time to generate a placeholder video when a video interruption occurs. However, real-time encoding involves complex encoding calculations, which can increase the initial screen latency by approximately 400ms, severely impacting the user viewing experience and failing to achieve the millisecond-level index completion and playback continuity guarantees sought by this invention, thus affecting normal streaming media processing. To address these issues, in some preferred embodiments, the placeholder filling method of this invention includes the following steps: S321. Obtain multiple placeholder video clips and generate a combination of placeholder video clips of several durations; In some preferred embodiments, the placeholder video segments are formed by splicing multiple preset placeholder segments of different durations according to certain rules, creating a set of video segments that can match the duration of the signal interruption. The placeholder video segments can be obtained using the FFmpeg processing tool, acquiring several no-signal placeholder video segments of different resolutions and durations. These placeholder video segments can be of various resolutions and standard durations (e.g., 1 second, 2 seconds, 5 seconds, 10 seconds, 30 seconds). The placeholder video segments can adopt a black screen, mute, or prompt screen style, or can be reasonably designed by those skilled in the art based on actual conditions or site requirements. Based on the placeholder video segments, combinations of placeholder video segments of several durations are generated. For example, combinations of placeholder video segments are generated from the acquired 1-second, 2-second, 5-second, 10-second, and 30-second basic placeholder video segments, including "1s+2s, 2s+5s, 5s+10s, 5s+10s+30s," etc.

[0057] The acquired placeholder video clips are then uniformly stored in a local pre-generated video library, making it easier to extract the corresponding video clips from the pre-generated video library later.

[0058] S322. The duration to be filled at the interruption point is taken as the filling duration, and the combination of the placeholder video segments is matched according to the filling duration as the filling slice; In some preferred embodiments, the interruption occurs when the time interval between two adjacent slices is greater than a preset slice period. For example, the preset slice period is set to 5 seconds (i.e., under normal transmission conditions, the time interval between adjacent slices in HLS streaming media should be close to 5 seconds, allowing for an error of ±1 second). The time interval between two adjacent slices is calculated as follows: the end time of the first slice is 00:05:30; the start time of the second slice is 00:05:50; the calculated time interval is 00:05:50 - 00:05:30 = 20 seconds. Since 20 seconds is greater than 5 seconds, it is determined that an interruption has occurred at this point, and the interruption duration is 20 seconds - 5 seconds = 15 seconds. The fill-in duration is used to fill the final video slice of the interruption period, which is composed of placeholder video clips; for example, if an interruption is detected and 15 seconds of fill-in is needed, a placeholder combination of "5s + 10s" is matched as the fill-in slice.

[0059] S323. Update the storage path of the filled slice and the filling duration to the HLS index file.

[0060] In some preferred embodiments, the storage path of the fill slice obtained in S62 in the pre-generated library and the duration of 5 seconds are written into the HLS index file to replace the blank record at the original interruption position.

[0061] This embodiment does not require the real-time generation of placeholder segments. By combining basic segments, processing efficiency is further improved, resource consumption is reduced, and the normal processing of streaming media is avoided.

[0062] Example 9 Based on Example 8, this example provides a method for generating a combination of placeholder video clips of several durations.

[0063] Existing technologies employ a static predefined strategy when combining placeholder video clips: a unique combination (e.g., 5s=5s, 6s=5s+1s) is pre-created for each possible interruption duration (e.g., 1~60 seconds), or fixed segments are directly reused (e.g., splicing together entirely 1-second segments), without algorithmic optimization. This strategy becomes severely resource-intensive as the interruption duration increases, requiring a re-definition of the duration for each subsequent interruption, failing to dynamically respond to randomly occurring durations in the service. To address these issues, the placeholder video clip combination steps of this invention include: Define a set of preset durations; In some preferred embodiments, the preset duration set can be defined as {30, 10, 5, 2, 1}, or it can be a reasonable design by those skilled in the art based on actual conditions or site requirements.

[0064] A combination of several different placeholder video segments is obtained based on different durations in the preset duration set.

[0065] In some preferred embodiments, obtaining a combination of several different placeholder video segments based on different durations in a preset duration set can be achieved using the idea of ​​making change with a coin, or it can be a reasonable design by those skilled in the art based on the actual situation or on-site needs.

[0066] In some preferred embodiments, the idea behind coin change is as follows (e.g., the interruption duration is 27s): prioritize basic segments from largest to smallest, and use the fewest segments to cover the target duration.

[0067] From 1 second to 27 seconds, determine whether each duration can be achieved by combining basic segments (30, 10, 5, 2, 1 seconds). For each duration, check in the order of "30 seconds → 10 seconds → 5 seconds → 2 seconds → 1 second", prioritizing the largest available segment (i.e., segment duration ≤ current duration, and remaining duration can be covered by other segments). Record the selected segment immediately. Use an array to record the last selected segment for each duration. Finally, working backward from 27 seconds, subtract the recorded segments one by one to obtain the complete combination.

[0068] For example, 27 seconds: First select 10 seconds (17 seconds remaining) → then select 10 seconds (7 seconds remaining) → select 5 seconds (2 seconds remaining) → select 2 seconds (0 seconds remaining). Final combination: [10,10,5,2] (only 4 segments, total duration 27 seconds).

[0069] This embodiment transforms the problem of matching the duration of power outages into a mathematical optimization problem of making change with coins, fundamentally solving the pain points of existing technologies such as excessive storage, low efficiency, and poor adaptability, making power outage compensation both efficient and flexible.

[0070] Example 10 Based on Embodiment 7, this embodiment provides a method for splicing the placeholder video segments in the placeholder video segment combination.

[0071] Existing video technologies employ a segment-by-segment encoding and splicing method, such as splicing 10s+10s, then 10s+10s+5s, and finally concatenating the result with 2s. This relies on FFmpeg's single-process sequential processing, resulting in extremely low efficiency. In some superior embodiments, the splicing mechanism of this invention is as follows: when a 27-second interruption is detected and a placeholder combination of [10s, 10s, 5s, 2s] is matched, the storage paths of the four segments are written to a text file in sequence. Then, matching basic placeholder segments are extracted from a pre-generated video library. These segments have the same resolution, bitrate, frame rate, and audio format as the original video. Next, FFmpeg is called to read the video and audio streams of these four segments sequentially via the concat protocol, using a direct copy mode for processing. This avoids re-encoding the video and audio data, only splicing the original data streams of the four segments into a continuous, complete data stream in chronological order. This process skips the time-consuming encoding stage, significantly reducing processing time.

[0072] Example 11 Based on Example 7, this example specifies the conditions that the combination of placeholder video clips should meet: The sum of the durations of each placeholder video segment equals the filling duration; If the sum of the durations of the placeholder video segments is less than the filling duration, the interruption period cannot be fully covered, and users will still see blank screens or jumps (e.g., an interruption of 15 seconds, but combined into 12-second segments, leaving 3 seconds without content), perceiving a service anomaly. If the sum of the durations of the placeholder video segments is greater than the filling duration, the filling segment takes longer, causing the start time of the original next segment to be forcibly shifted backward (e.g., an interruption of 15 seconds, combined into 17-second segments, the original segment starts at 15 seconds, but actually starts at 17 seconds), resulting in time jumps or fast-forwarding during playback.

[0073] Minimize the number of placeholder video segments.

[0074] If the number of placeholder video segments is not minimized, the splicing operation becomes increasingly cumbersome as the number of segments increases (e.g., 15 one-second segments versus 2 ten-plus-five segments). Assuming a single segment splicing takes 50ms, 15 segments take 750ms, while 2 segments only take 100ms, representing a 7-fold efficiency difference. Furthermore, frequent calls to the splicing tool to process multiple segments will consume the CPU / IO resources of the streaming media server, leading to encoding and transmission delays in the normal video stream.

[0075] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.

Claims

1. A method for timing processing based on HLS slice, characterized in that, The application comprises: S1. Capturing at least one HLS master index file and a plurality of slice files based on a video stream; S2. Building an initial slice file index database without time length based on the plurality of slice files; S311. Obtaining the recorded time length of the slice file as a first time length based on the at least one HLS master index file, and updating the first time length obtained to the slice file index database; S312. For the slice file without obtained time length, comparing the sequence number order of the slice file in the video stream, if the starting time of the current slice plus the preset slice time length is equal to the starting time of the slice file corresponding to the next sequence number, then the time length of the current slice file is the preset slice time length as a second time length; S313. For the slice file still without obtained time length, obtaining the time length of the slice file as a third time length through a streaming processing tool; S32. Filling the placeholder for the case of flow interruption in the video stream.

2. The method of claim 1, wherein, The HLS master index file acquisition method comprises: listening to the network hook callback event of the streaming server through the sidecar proxy to perceive the file name, starting time and file path of the video stream.

3. The method of claim 1, wherein, The HLS master index file processing method comprises: renaming the master index file with the starting time of the video as a mark.

4. The method of claim 1, wherein, The third time length acquisition method comprises: submitting the path of the slice file still without obtained time length to the verification pool of the streaming processing tool, executing the streaming processing tool through an asynchronous thread pool to obtain the third time length, and writing the third time length to the slice file index database.

5. The method of claim 4, wherein, After writing the third time length to the slice file index database, the third time length is updated to the local cache.

6. The method of claim 5, wherein, Before using the streaming processing tool, it is checked whether there is a time length record corresponding to the path of the slice file in the local cache; if there is, the corresponding third time length is directly updated to the slice file index database.

7. The method of claim 1, wherein, The placeholder filling method comprises: S321. Obtaining a plurality of placeholder video segments to generate a combination of a plurality of time length placeholder video segments; S322. Taking the time length to be filled in the flow interruption as a filling time length, matching the combination of the placeholder video segments as a filling slice according to the filling time length; S323. Updating the storage path of the filling slice and the filling time length to the HLS index file.

8. The method of claim 7, wherein, The combination of a plurality of time length placeholder video segments is generated by: Defining a preset time length set; According to different time lengths in the preset time length set, a combination of a plurality of different placeholder video segments is obtained.

9. The method of claim 7, wherein, The filling slice is generated by splicing each placeholder video segment in the combination of the placeholder video segments.

10. The method of claim 9, wherein, The combination of the placeholder video segments should meet the following conditions: The sum of the time lengths of the placeholder video segments is equal to the filling time length; The number of the placeholder video segments is minimized.