A video clip level content management and control method and system

CN121792808BActive Publication Date: 2026-05-26BEIJING YIHE BOJIA EDUCATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING YIHE BOJIA EDUCATION TECH CO LTD
Filing Date
2026-03-09
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing video playback technologies, when handling complex control logic, cause the main thread to be blocked, affecting smoothness and precise frame-level control, especially in unstable network or high-load environments where it is difficult to achieve zero-latency response.

Method used

A video segment-level content management and control method is adopted. By using an asynchronous lookahead thread, rule determination and time-consuming business logic are separated from the main thread. Asynchronous processing is achieved by using a time-series state index structure and an instruction circular queue, ensuring that the main thread operates at a lightweight level.

Benefits of technology

It effectively reduced CPU usage, eliminated minor stuttering, and achieved zero-latency business logic response and a smooth viewing experience, while also balancing complex business control with high-precision control logic execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121792808B_ABST
    Figure CN121792808B_ABST
Patent Text Reader

Abstract

This invention relates to the field of multimedia video processing and playback control technology, specifically a video segment-level content management and control method and system, comprising: a time-series discrete mapping step: obtaining a server-side rule set and mapping it to a time-series state index structure with video durations divided into discrete-time graticles; an asynchronous look-ahead detection step: calculating the look-ahead time based on the current playback time using an independent asynchronous thread and reading the corresponding graticle data from the bitmap; an instruction generation and caching step: generating instruction objects based on graticle control identifiers using preprocessing logic and pushing them sequentially into an instruction circular queue; and a frame-level synchronous application step: checking the queue during main playback thread rendering, and applying the instruction if the current time matches the instruction trigger time. This invention reduces playback CPU usage, eliminates micro-stuttering caused by main thread blocking, and ensures accurate triggering of control logic at the frame level.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of multimedia video processing and playback control technology, specifically to a method and system for video segment-level content management and control. Background Technology

[0002] With the evolution of streaming media technology, video playback services are no longer limited to simple linear streaming. Complex control logic such as permission verification, dynamic material replacement, and content masking are increasingly widely used in long video scenarios. Currently, video content control and management are generally executed synchronously in the main playback thread of the player. For example, during playback, the rule set is polled in real time and related business logic is processed directly. However, this processing method directly occupies the main thread's time slice when time-consuming operations such as network I / O (input / output) requests, resource download decoding, or GPU (graphics processing unit) shader compilation are involved, leading to rendering pipeline blockage. The main thread blockage not only causes slight stuttering in video playback and high CPU (central processing unit) usage, disrupting playback smoothness, but also makes it impossible to achieve frame-level precise triggering and zero-latency response of control commands in weak network or high-load environments, making it difficult to balance high-precision business control and user viewing experience. Therefore, there is an urgent need to provide an improved video segment-level content management and control method to overcome the above defects. Summary of the Invention

[0003] To address the aforementioned technical problems, this invention provides a method and system for video segment-level content management and control. Specifically, the technical solution of this invention is as follows:

[0004] A method for video segment-level content management and control, the method comprising the following steps:

[0005] Obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video timeline. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period.

[0006] During video playback, an asynchronous lookahead thread, independent of the main playback progress thread, calculates the lookahead time based on the current playback time and reads the target raster data corresponding to the lookahead time from the time-series state index structure.

[0007] Based on the control identifier present in the target raster data, the preprocessing logic corresponding to the control identifier is executed to generate an execution instruction object, and the execution instruction object is pushed into the instruction circular queue in timestamp order;

[0008] When the main video playback thread renders each frame, it checks the head of the instruction circular queue, and if the current playback time matches the execution instruction object at the head of the instruction circular queue, it applies the execution instruction object.

[0009] Preferably, mapping the video segment control rule set to a temporal state index structure corresponding to the video timeline includes:

[0010] The start timestamp, end timestamp, and control type of the video segment control rule set are parsed.

[0011] Establish a sparse mapping structure with time code as the index key and the control type as the value as the time-series state index structure;

[0012] For time periods not included in the video segment control rule set, they are marked as empty in the sparse mapping structure.

[0013] Preferably, the step of executing the preprocessing logic corresponding to the control identifier present in the target raster data to generate an execution instruction object includes:

[0014] Identify the specific business type of the control identifier, wherein the business type includes permission verification, material replacement, or content masking;

[0015] In the asynchronous lookahead thread, the time-consuming operation corresponding to the business type is executed asynchronously, and the operation result is obtained;

[0016] The operation result is encapsulated into an execution instruction object containing a trigger timestamp and an execution action.

[0017] Preferably, the step of pushing the execution instruction objects into the instruction circular queue in timestamp order further includes:

[0018] Detect whether multiple consecutive time grids read by the asynchronous lookahead thread have the same control identifier;

[0019] When multiple execution instruction objects have the same control identifier, they are merged into a single persistent instruction object.

[0020] The persistent instruction object is pushed into the instruction circular queue for the main thread of playback progress to read.

[0021] Preferably, the method further includes a dynamic update step:

[0022] In response to receiving a new rule version number from the server, a new time-series state index structure is constructed in a background thread;

[0023] Atomic operations are used to replace the pointer to the old time-series state index structure with a pointer to the new time-series state index structure.

[0024] In the next scan performed by the asynchronous lookahead thread, the target raster data is read based on the new temporal state index structure.

[0025] Preferably, the step of checking the head of the instruction circular queue when rendering each frame on the main video playback thread includes:

[0026] Read the trigger timestamp of the executed instruction object from the head of the instruction circular queue;

[0027] The current playback time is compared with the trigger timestamp: if the current playback time is greater than or equal to the trigger timestamp, the match is considered successful, and the execution instruction object is removed from the instruction circular queue; if the current playback time is less than the trigger timestamp, the state of the instruction circular queue remains unchanged.

[0028] Preferably, the application of the execution instruction object includes:

[0029] Based on the action type in the execution instruction object, a mask layer is overlaid, a video stream jump operation is performed, or the current decoding data source is replaced in the rendering pipeline of the main video playback thread.

[0030] A video segment-level content management and control system includes the following modules:

[0031] The discrete mapping construction module is used to obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video time axis. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period.

[0032] An asynchronous look-ahead detection module is used to calculate the look-ahead time based on the current playback time during video playback using an asynchronous look-ahead thread independent of the main playback progress thread, and to read the target raster data corresponding to the look-ahead time from the time-series state index structure.

[0033] The preprocessing and instruction caching module is used to execute the preprocessing logic corresponding to the control identifier based on the control identifier present in the target raster data to generate an execution instruction object, and push the execution instruction object into the instruction circular queue in timestamp order;

[0034] The frame-level synchronization execution module is used to check the head of the instruction circular queue when the main thread of video playback renders each frame, and apply the execution instruction object if the current playback time matches the execution instruction object at the head of the instruction circular queue.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] 1. This invention establishes an asynchronous lookahead thread independent of the main playback progress thread, thereby separating complex rule determination, network requests, and resource loading from the main thread. The main thread only needs to perform lightweight instruction circular queue reading operations, which significantly reduces the CPU usage of video playback and eliminates the slight stuttering caused by the main thread processing time-consuming logic. This architecture enables the system to simultaneously handle complex business control logic and a smooth viewing experience in long video streaming scenarios.

[0037] 2. This invention calculates the look-ahead time based on the current playback time and executes preprocessing logic in advance before the playback progress reaches the target. This mechanism effectively utilizes the playback time difference, hiding network jitter and resource loading time that might otherwise cause playback interruption in the background. When the playback progress actually reaches the trigger point, the authentication result or replacement material is already ready, thus achieving seamless zero-latency response. Especially when the network environment is poor or the system load is high, it can still ensure the accurate execution of business logic.

[0038] 3. This invention maps the video segment control rule set into a temporal state index structure corresponding to the video timeline and adopts a sparse mapping-based storage method. Time periods without rules are marked as empty or not stored. This discretized storage strategy greatly saves memory space and avoids storing large amounts of invalid data in long video scenarios. Simultaneously, by utilizing the efficient characteristics of hash lookup, it ensures that the look-ahead detection process can quickly locate target raster data, meeting the performance requirements of high-frequency detection.

[0039] 4. This invention achieves instruction debouncing and compression by detecting whether multiple consecutive time grids have the same control identifier and merging the corresponding multiple execution instruction objects into a single persistent instruction object. This mechanism avoids generating a large number of redundant instructions when facing dense control rules within a continuous time period, prevents instruction circular queue overflow, and significantly reduces the frequency of main thread reading and processing instructions. Furthermore, combined with the atomic operation mechanism in the dynamic update step, it ensures that the system remains stable and robust under hot rule updates or high-concurrency scenarios. Attached Figure Description

[0040] The present invention will be further explained below with reference to the accompanying drawings and embodiments:

[0041] Figure 1 This is a flowchart of the method of the present invention;

[0042] Figure 2 This is a structural diagram of the system of the present invention. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.

[0044] Example 1:

[0045] Please see Figure 1 A method for video segment-level content management and control includes the following steps:

[0046] Obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video timeline. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period.

[0047] During video playback, an asynchronous lookahead thread, independent of the main playback progress thread, calculates the lookahead time based on the current playback time and reads the target raster data corresponding to the lookahead time from the time-series state index structure.

[0048] Based on the control identifiers present in the target raster data, the preprocessing logic corresponding to the control identifiers is executed to generate execution instruction objects, and the execution instruction objects are pushed into the instruction circular queue in the order of timestamps.

[0049] While the main video playback thread renders each frame, it checks the head of the instruction circular queue and, if the current playback time matches the instruction object at the head of the instruction circular queue, applies the instruction object to execute.

[0050] This embodiment details the execution architecture of a video segment-level content management and control method, aiming to resolve the contradiction between high-precision control and smooth playback. The system executes the step of constructing a temporal state index structure, obtaining a video segment control rule set containing version information from the server, i.e., a JSON (JavaScript Object Notation) data set describing the control logic for a specific time period of the video. The system maps the video segment control rule set to a temporal state index structure corresponding to the video timeline. This bitmap discretizes the continuous timeline into a spatially dimensional index structure. Specifically, the temporal state index structure divides the video duration into discrete time grids, with each time grid storing the control identifier corresponding to that time period. The index mapping relationship follows the following formula:

[0051]

[0052] in, : Derived from calculation results, its physical meaning is the index key value of the time raster in the bitmap; symbol This represents the function for rounding down;

[0053] : Derived from video metadata, its physical meaning is the absolute timestamp in the video stream. To ensure consistency in calculation units, the timestamp needs to be uniformly converted to milliseconds here;

[0054] This parameter is derived from system configuration and its physical meaning is the preset time grid granularity, measured in milliseconds. As an example, it can be set to 100ms. The specific value is a configurable parameter set by balancing the system's available memory budget with the minimum control precision required by the business; specifically, if the business scenario requires frame-level precision control, then... The value should be close to the duration of a single frame, for example, set to 40ms. If only a rough control at the second level is needed, a larger value can be used, for example, set to 1000ms, to reduce the memory usage of the bitmap.

[0055] Based on this, the system initiates an asynchronous lookahead detection process; during video playback, a virtual shadow cursor is established through an asynchronous lookahead thread independent of the main video playback thread; this thread calculates the lookahead time based on the current playback time, and the calculation logic is as follows:

[0056]

[0057] in, Derived from the calculation results, its physical meaning is look-ahead time, which is the current time point that the shadow cursor is pointing to;

[0058] It originates from feedback from the player engine and its physical meaning is the current playback time, that is, the timestamp of the frame that the screen is currently rendering;

[0059] These parameters originate from the system's preset dynamic buffering strategy and physically represent the look-ahead offset. To satisfy the variable-formula tracking principle and ensure the effectiveness of look-ahead detection, these parameters... The value of strictly follows the following inequality model:

[0060]

[0061] in, The keyframe interval for video encoding can be 2000ms as an example value. The specific value can be obtained by parsing the video stream header information, such as the SPS (Sequence Parameter Set) parameter set in the H.264 format, or by reading the setting value of the transcoding configuration file.

[0062] The size of the network jitter buffer window is 500ms, which can be taken as an example. The specific value is calculated by the client network module in real time by statistically analyzing the fluctuation variance of the round-trip latency of data packets in a recent period. For example, the P99 value, which is the 99th percentile, represents that 99% of the network latency data points are lower than this value.

[0063] The estimated maximum time consumption of the business preprocessing logic in the example is derived from the maximum response time obtained by offline stress testing of the relevant business interfaces or the statistical peak value of online historical logs, for example, it is set to 800ms.

[0064] The preprocessing logic includes, but is not limited to: the authentication time for initiating a network request to the authorization server and waiting for a response, the time for downloading and decoding replacement materials from the CDN, and the time for loading and compiling the GPU shader program; For safety, an exemplary value of 1.5 is used. This is a configurable empirical constant set according to the system's tolerance for stuttering risks, and its value is typically recommended to be between 1.2 and 2.0 to cover unforeseen system scheduling delays during runtime. Based on this inequality model, this embodiment clarifies the look-ahead offset. The specific formula and assignment logic are as follows: The system calculates the boundary values ​​on the right side of the inequality in real time.

[0065]

[0066] in, This is the theoretical minimum look-ahead offset calculated based on system variables. Its physical meaning is the lower limit of the calculation time required to ensure that the business logic can complete before the playback progress reaches its target. Considering... Parameters such as these may fluctuate frequently; if we directly set them... This may occur during each scan. Backtracking or jumping occurs, disrupting the continuity of the look-ahead, in which... The assignment operator indicates that the right-hand side will be assigned a value. The value is assigned to the variable on the left. Therefore, this embodiment introduces a monotonicity constraint strategy with a reset mechanism:

[0067] System maintenance lead time of the previous cycle And calculate the current recommended value. Under normal playback conditions, the final result is... This logic implicitly smooths out The changes ensure that the look-ahead scanning cursor monotonically increases on the time axis;

[0068] To ensure compatibility with user drag-and-drop and playback operations, the system listens for the player kernel's status callbacks; when a playback timestamp is detected... A mutation occurs and the absolute value of the difference exceeds a preset threshold, for example... When the system detects a redirection event, a forced reset is performed. That is, when a jump event occurs, the system resets the lookahead baseline, making Equals the new playback time after the jump To unlock monotonicity and allow follow Backtracking is performed; this formula ensures that even when an asynchronous lookahead thread performs time-consuming I / O operations, the generated instructions will still be earlier than the playback progress. Arrival in the queue eliminates the risk of timing races;

[0069] The thread reads the target raster data corresponding to the look-ahead time from the timing state index structure; based on the control identifiers present in the target raster data, i.e., binary markers indicating regularity, the system executes the preprocessing logic corresponding to the control identifiers to generate execution instruction objects; this preprocessing logic involves I / O operations or complex calculations, and the generated execution instruction objects contain trigger timestamps, action types, and payload data; then, the system pushes the execution instruction objects into the instruction circular queue in timestamp order, which serves as a thread-safe FIFO buffer, connecting the producer and consumer;

[0070] In the main video playback thread, i.e. the aforementioned main video playback thread, when rendering each frame, the head of the instruction circular queue is checked, and if the execution instruction object matches the head of the instruction circular queue at the current playback time, the execution instruction object is applied to complete the synchronization with the rendering pipeline.

[0071] In long-video streaming scenarios, this embodiment uses time-series discrete mapping and asynchronous lookahead guard mechanisms to decouple complex rule determination and time-consuming business logic from the main playback thread. The main thread only needs to perform lightweight queue reading operations, thereby significantly reducing the CPU usage of video playback, eliminating micro-stuttering caused by main thread blocking, and ensuring precise triggering of control logic at the frame level. Furthermore, in calculating lookahead time... At that time, the system introduced boundary check logic: if the calculated boundary check result is... Greater than the total video length Then Cut off as Alternatively, it can be marked as an invalid scan to prevent bitmap index out-of-bounds access, ensuring program robustness in video tail scenes.

[0072] Map the video segment control rule set to a temporal state index structure corresponding to the video timeline, including:

[0073] Parse the start timestamp, end timestamp, and control type in the video segment control rule set;

[0074] Establish a sparse mapping structure with time code as the index key and control type as the value as the time-series state index structure;

[0075] For time periods not included in the video segment control rule set, they are marked as empty in the sparse mapping structure.

[0076] This embodiment further specifies the mapping construction steps, aiming to optimize memory usage and query efficiency. The system performs rule parsing operations, parsing the start timestamp, end timestamp, and control type in the video segment control rule set, and extracting discrete control segment data. The system uses hash mapping technology to establish a time-based raster index. It is a sparse mapping structure with index keys and control types as values, which logically serves as the physical implementation of a temporal state index structure.

[0077] During this process, the system performs range discretization: based on the parsed start timestamp and end timestamp Calculate the corresponding starting raster index With End Raster Index ; Traverse closed intervals All integer indices within key-value pairs Insert rules one by one into the hash map to ensure continuous coverage of rules over time. The enumeration values ​​indicate specific business types, including permission verification, material replacement, or content masking. During this mapping construction process, in order to solve the data source problem of parameter backtracking in subsequent steps, the system synchronously maintains a rule metadata table.

[0078] Specifically, in indexing While inserting sparse mappings, the system serializes the specific business parameters corresponding to the rule set, such as the material URL, authentication token, and mask coordinate set, into metadata objects and uses the same index. The key is stored in this metadata table; this dual hash table structure, which separates control types from business parameters, ensures that high-frequency look-ahead probing only needs to access the lightweight time-series state index structure, while heavyweight parameter acquisition is only performed on demand during the instruction generation stage; this sparse mapping structure only stores valid data. If there are no control rules for a certain period of time, the index corresponding to that period of time will not exist in the structure; furthermore, for time periods not included in the video segment control rule set, the system marks them as empty in the sparse mapping structure, that is, if the key does not exist during the query, it will return an empty value by default, without the need to explicitly store the no-rule mark;

[0079] In processing long videos containing a few ads or interactive elements, this embodiment uses a sparse mapping structure instead of a continuous array, which greatly saves memory space and avoids storing a large amount of invalid idle time period data. It also utilizes hash lookup... The time complexity characteristics ensure the efficiency and low latency of the forward-looking detection process.

[0080] Based on the control identifiers present in the target raster data, the preprocessing logic corresponding to the control identifiers is executed to generate execution instruction objects, including:

[0081] Identify the specific business type of the control identifier, where the business type includes permission verification, material replacement, or content masking;

[0082] In an asynchronous lookahead thread, asynchronously execute time-consuming operations corresponding to the business type and obtain the operation results;

[0083] The operation result is encapsulated into an execution instruction object containing the trigger timestamp and the action to be performed.

[0084] This embodiment further specifies the preprocessing logic, aiming to preload business logic. The system identifies the specific business type of the control identifier, where the business type includes permission verification, material replacement, or content masking. It should be noted that, because the time-series state index structure is optimized for memory and only stores the control type enumeration value, the system performs a crucial parameter backtracking operation at this stage: utilizing the currently hit time grid index... Used as the key (index key), it queries the rule metadata table built during the rule parsing phase to obtain the specific set of business parameters. ;

[0085] For example, when the type is material replacement, the system extracts... ;in, Replace the web address of the target material. Use the checksum of the source files to ensure their integrity. This refers to the bitrate information of the replacement material;

[0086] When the type is permission verification, the system extracts... ;in, This is the access endpoint address for the authorization server. The identity token for the user's current session;

[0087] When the type is content mask, the system extracts:

[0088]

[0089] in, The set of values ​​is ; This is the download link for the masking material; This represents the transparency value of the mask layer;

[0090] The normalized layout coordinate rectangle for the masking within the video frame contains four key parameters: (The ratio of the top left corner of the mask to the width of the viewport) (The ratio of the vertical starting position of the upper left corner of the mask to the viewport height) (The ratio of mask width to viewport width) and (The ratio of mask height to viewport height);

[0091] This is the duration of a single frame for dynamic content; for static images, this value is 0 or default. This step resolves the issues of not being able to initiate specific network requests based solely on the control type and the lack of rendering resources.

[0092] In response to the business type being permission verification, the system utilizes... Initiate a server-side authentication request; in response to a business type of material replacement, the system utilizes... Download and decode the resource; responding to a business type of content masking, if If the value is Image, corresponding to an image sticker, then asynchronous texture download and decoding are performed. If the value is Blur, corresponding to a blur effect, then the corresponding GPU fragment shader program object is pre-compiled. The system asynchronously executes the time-consuming operation corresponding to the business type in the asynchronous lookahead thread and obtains the operation result, such as authentication token, decoded texture object or shader handle.

[0093] The system encapsulates the operation result into an execution instruction object containing a trigger timestamp and the action to be performed, and puts it in a state of pending execution;

[0094] In weak network environments or high-load playback scenarios, this embodiment utilizes look-ahead time difference to hide network requests and resource loading operations that might otherwise cause playback stuttering before the playback progress is reached. This allows the authentication results or replacement materials to be presented instantly when the user reaches a specific point in the playback, achieving a smooth experience with zero latency.

[0095] Pushing execution instruction objects into the instruction circular queue in timestamp order also includes:

[0096] Detect whether multiple consecutive time grids read by the asynchronous lookahead thread have the same control identifier;

[0097] When multiple execution instruction objects have the same control identifier, they are merged into a single persistent instruction object.

[0098] Push persistent instruction objects into the instruction circular queue for the main thread to read the playback progress.

[0099] This embodiment further specifies the instruction enqueueing logic, introducing instruction debouncing and merging mechanisms. To physically detect multiple consecutive time grids, the system employs a sliding scan window algorithm in the asynchronous lookahead thread, instead of single-point sampling. The system sets the window size to [size missing]. This parameter The physical meaning is the number of time grids covered in a single scan, for example... This parameter The value is usually set by the developers based on the CPU performance benchmark results of the target running device:

[0100] On high-performance devices A larger value, such as 50-100, can be used to reduce the scanning frequency. On low-performance devices, a smaller value, such as 10-20, should be used to avoid thread blocking caused by excessively long single scan loop times. The corresponding time span is... ms; each read interval The grid state within; to prevent window access from going out of bounds in scenes at the end of the video, the system calculates the effective scan length:

[0101]

[0102] in, The maximum index value of the time-series state index structure is defined as follows: ,in, The total video duration is given; based on this, the system executes run-length encoding logic.

[0103] To accurately describe the continuous matching mechanism implemented by the algorithm and eliminate ambiguity in the mathematical expression, this embodiment uses the following logical definition of run length. The system starts from the current position. Begin by checking subsequent offsets. The grid state at that location makes The largest integer that satisfies the following universal quantifier constraints, and :

[0104]

[0105] in, For universal quantifiers, the interval is... any integer in This means that the condition must remain true throughout the entire period to be merged;

[0106] This represents the type enumeration value of the control identifier. The hash signature representing the rule's metadata;

[0107] This indicates a logical equivalence check, used to verify whether the attribute value of the currently scanned time grid is strictly consistent with the attribute value of the starting position grid;

[0108] This represents a logical AND operation, which requires that both the Type and MetaID be the same, and neither can be omitted. This ensures that only fragments with completely consistent business logic will be merged into a continuous instruction.

[0109] Based on the calculated look-ahead time The mapped time raster index is explicitly defined as This represents the starting position of the current scanning window; a double consistency check is used here: it requires not only that the control types be the same, but also that the rule unique identifier be obtained by querying the rule metadata table. To maintain consistency; although mathematically described using universal quantifiers, in engineering implementation by those skilled in the art, this logic is translated into a specific sequential scan and blocking process:

[0110] , , ,

[0111] in, : Indicates the control type of the current merging window starting point, which serves as the benchmark value for comparison; : Represents the rule metadata feature code of the starting point of the current merging window, which serves as the benchmark value for comparison; : Indicates the current scanning cursor The control type of the position is a decision item that needs to be verified for consistency with the baseline value; : Indicates the current scanning cursor The location rule metadata feature code is a decision item that needs to be verified for consistency with the baseline value;

[0112] System initialization counter ,from Start the loop, utilizing the pre-generated maps from the map building phase. The hash values ​​are compared; once the first mismatched grid is encountered, i.e., the condition... If the value is false, the loop terminates immediately, and the current count becomes the result. This explicit loop-blocking logic eliminates ambiguity in continuity judgments, ensuring that only segments with completely identical business parameters are merged.

[0113] To clarify, the unique identifier MetaID for a rule is not a parameter generated out of thin air. Rather, it refers to the unique feature code generated during the mapping construction phase by serializing and calculating the hash value of specific business parameter objects contained in the rule set, such as material URLs, authentication tokens, and mask coordinate sets, using methods such as MD5 (Message Digest Algorithm Version 5, a widely used cryptographic hash function) or MurmurHash64 (64-bit version of the Murmur hash algorithm, a non-encryption high-performance hash algorithm). This MetaID is stored as a field in the rule metadata table and associated with the time raster index to ensure that merging only occurs when the business logic parameters are completely consistent.

[0114] This logical definition intuitively reflects the algorithm's characteristic of stopping counting when encountering the first mismatch; the above logic is implemented as a loop-based conditional statement in the actual code: the system starts from... Begin iterating, and increment the counter when the above conditions are met. Once a non-match is detected, a break statement is immediately executed to interrupt the loop, thus obtaining the length of consecutive matches. ;

[0115] This improvement effectively prevents the incorrect merging of adjacent rules with different business logic, such as two consecutive different advertisements; the calculated merging time is... When multiple consecutive time grids read by the asynchronous lookahead thread have the same control identifier, the system merges the corresponding multiple execution instruction objects into a single persistent instruction object. This object, in addition to containing the start time, also explicitly writes the duration field calculated by the above formula. The system pushes persistent instruction objects into the instruction circular queue for the main thread to read the playback progress.

[0116] In addition, to prevent the asynchronous lookahead thread from repeatedly scanning the same raster area during time lags caused by playback pauses or network buffering, or from generating overlapping instructions during sliding window advancement, the system introduces a leading-edge cursor. As a state variable, it records the position of the last time grid cell that has been scanned and processed; before each scan, the system performs a positional abrupt change detection:

[0117] Check the currently calculated starting index With state variables Does the difference exceed a preset discontinuity threshold, for example? This system identifies whether the user has performed a drag-and-drop operation, i.e., a navigation action; if a navigation action is detected, a forced reset is performed. This allows for rescanning of new locations; it is worth noting that the location mutation detection logic specifically covers the scenario of dragging backwards, i.e., playback:

[0118] If detected , This is a tolerance threshold, a configurable parameter derived from the player kernel's statistics on the timestamp jitter range after a jump operation. For example, setting it to 3 to 5 grid units can filter out minor, non-human-caused progress jumps. The system will still recognize this as a jump and reset the cursor, thus avoiding issues caused by... The optimization strategy of skipping the scan leads to instruction loss during playback;

[0119] Thread checks current Is it greater than or equal to? ;like If no redirection occurs, skip this scan; if To prevent skipping intermediate grids due to thread scheduling delays causing the scan window to jump, the system forcibly anchors the starting index of this scan to [index missing]. Instead of the currently calculated The scanning coverage extends to To ensure that the progress is caught up;

[0120] After successfully generating a span of After generating persistent instruction objects for each grid cell and pushing them into the queue, immediately update the cursor: This update clarifies the mechanism for determining the sliding step size of the sliding scan window after a single merge:

[0121] The effective starting position for the next scan, i.e., the new Anchored after the end position of the current merge instruction, i.e., the step size is... Instead of a fixed step size This dynamic step size logic ensures seamless coverage of the video timeline, avoiding rule omissions due to excessively large step sizes or duplicate processing due to excessively small step sizes; this closed-loop logic ensures the idempotency of instruction production, preventing overflow of the instruction queue and logical confusion in downstream consumers.

[0122] In scenarios with dense control rules within a continuous time period, this embodiment effectively prevents overflow of the instruction circular queue through the instruction merging mechanism implemented by the RLE algorithm described above, significantly reducing the frequency of instruction processing by the main thread and the overhead of context switching. At the same time, by explicitly encapsulating the duration attribute in the instruction object, it provides the necessary data support for the main thread to maintain the effective state of instructions in the rendering pipeline.

[0123] The method also includes a dynamic update step:

[0124] In response to receiving a new rule version number from the server, a new time-series state index structure is constructed in a background thread;

[0125] Atomic operations are used to replace the pointer to the old time-series state index structure with a pointer to the new time-series state index structure.

[0126] In the next scan performed by the asynchronous lookahead thread, the target raster data is read based on the new temporal state index structure.

[0127] This embodiment supplements the rule hot update mechanism, aiming to realize dynamic changes in strategy during playback. In response to receiving a new rule version number from the server, the system constructs a new time-series state index structure in a background thread. This process does not affect the old bitmap currently in use. The system uses atomic operations, namely CPU-level Compare-and-Swap instructions, to replace the pointer to the old time-series state index structure with a pointer to the new time-series state index structure. The formula is expressed as follows:

[0128]

[0129] in, Originating from the global memory space, its physical meaning is a global pointer to the currently effective bitmap; Originating from the background build thread, its physical meaning is a pointer to the newly built bitmap;

[0130] In the next scan performed by the asynchronous lookahead thread, the system naturally reads the target raster data based on the new temporal state index structure, and the old bitmap objects are handled by the garbage collection mechanism or the smart pointer reference counting mechanism.

[0131] In video playback scenarios such as live streaming or real-time operational activities, this embodiment solves the read / write contention problem in a multi-threaded environment. It eliminates the need for high-overhead locking mechanisms, ensuring that the player will not crash, stutter, or reset the buffer when rules are updated, and achieving dynamic policy changes that are imperceptible to the user.

[0132] While the main video playback thread renders each frame, it checks the head of the instruction circular queue, including:

[0133] Read the trigger timestamp of the execution instruction object at the head of the instruction circular queue;

[0134] The current playback time is compared with the trigger timestamp: if the current playback time is greater than or equal to the trigger timestamp, the match is considered successful and the execution instruction object is removed from the instruction circular queue; if the current playback time is less than the trigger timestamp, the state of the instruction circular queue remains unchanged.

[0135] Application execution instruction objects include:

[0136] Depending on the action type in the execution instruction object, a mask layer is overlaid in the rendering pipeline of the main video playback thread, a video stream jump operation is performed, or the current decoding data source is replaced.

[0137] This embodiment details the specific logic of frame-level synchronous execution and instruction application, focusing on solving the lifecycle management problem after an instruction is removed from the queue; the main thread reads the trigger timestamp of the execution instruction object at the head of the instruction circular queue in a non-blocking manner;

[0138] The system compares the current playback time with the trigger timestamp; to handle the potential backlog of commands caused by user dragging, the decision logic employs a loop-based catch-up mechanism, defining queue operation states. as follows:

[0139]

[0140] in, It originates from the logical judgment result and has the physical meaning of queue operation status; This information is derived from player feedback and its physical meaning is the current playback time. It originates from the instruction object and its physical meaning is the trigger timestamp. This timestamp is the absolute time point on the video timeline after the start time defined by the rule is mapped.

[0141] If the current playback time is greater than or equal to the trigger timestamp, the system performs a second precise check here, taking into account the rounding error that may be introduced by the raster index: reading the original millisecond-level precise trigger time stored in the instruction object. Only when Only when the system determines that a match is successful will the execution instruction object be removed from the instruction circular queue.

[0142] During this process, to prevent the execution of outdated historical instructions due to long-distance dragging (i.e., jump operations), and to correctly handle continuous instructions interrupted midway, the system performs a dual-modal timeliness check: For instantaneous instructions, such as video jumps: if For example, 1000ms. This parameter is defined based on the objective technical specifications of the video stream, and its specific value is half of the keyframe interval of the video stream. Or configured as look-ahead offset A fixed ratio, such as This provides an objective judgment standard based on system processing capabilities and video coding structure, avoiding the uncertainty of subjective judgment. If a video is found to be completely expired, it is judged to be completely expired and discarded directly.

[0143] For persistent commands, such as masking and interstitial commands: extract the duration. Check if If true, it is considered completely expired; if If it is determined to be a backtracking activation, the instruction is retained and the elapsed time is calculated. For use in subsequent state synchronization;

[0144] If the instruction has not expired and contains a backtracking active state, the system immediately applies the instruction and continues to check the new queue head until the queue is empty or the timestamp of the next instruction is greater than the current time; this mechanism ensures that all instructions that should be triggered can be processed in a single rendering callback.

[0145] Building upon this, to ensure that persistent instructions removed from the queue continue to be effective for the predetermined duration, the system introduces an Active Effect Registry (AER) as a state container for the rendering pipeline; the system performs the following routing processing based on the action type in the instruction object:

[0146] Overlay masking layer: If the action is visual occlusion, the system extracts the duration parameter carried in the command. and normalized coordinate parameters The masking object is then registered in the AER (Autowired Environment); at this point, the system uses the preloaded... Parameters, bound to the corresponding texture ID or shader program; if backtracking duration exists. Furthermore, the mask is defined as a dynamic sequence of frames, and the system uses a formula... Calculate the current texture frame index to be rendered, ensuring strict synchronization between the animation and the timeline; while rendering each frame, AER traverses all currently active nodes and calculates their remaining lifecycle.

[0147]

[0148] Only when The system only performs rendering operations at a specific time; therefore, it is necessary to clearly define the boundary conditions for the end time point: this embodiment uses a left-closed, right-open time interval definition. Therefore, when the time has elapsed... Exactly equal to the total duration At this time The system determines that the instruction cycle has ended and stops rendering; this strict... The decision logic has been eliminated. Ambiguity in whether the time is displayed, while ensuring consistency with the basis. The logic for calculating animation frame indices is typically 0-based index (i.e., array indices start counting from 0), ensuring precise alignment and preventing array out-of-bounds errors.

[0149] During rendering, in order to map the normalized coordinates to the pixel coordinate system of the current player window, the system obtains the width and height of the current rendering viewport. The unit is pixels, and the following coordinate transformation formula is applied:

[0150]

[0151]

[0152]

[0153]

[0154] A mask texture is drawn on the frame buffer after the video frame is rendered using calculated pixel rectangles; if If so, the node will be unregistered from AER, thus ending the mask display;

[0155] Perform video stream jump: If the action is to skip content, the player kernel interface is called directly to perform the video stream jump operation, perform keyframe alignment, and clear the current decoding buffer.

[0156] Replace decoding data source: If the action is content insertion, then execute the stream placeholder replacement process; to ensure the logical closed loop of content management, the system performs context state temporary storage before performing the replacement: the current playback address of the main video stream is stored. and interruption timestamp Push it onto the state stack;

[0157] Replace the current decoding data source and utilize the duration. Register an active node of stream placeholder type in AER; to ensure the continuity of the timeline and to resolve the inconsistency between the video stream time base and the player clock unit, the system executes a strict PTS remapping algorithm:

[0158]

[0159] in, The value of the original timestamp decoded from the new stream after being expanded to 64 bits, in units based on... The number of clock ticks; The unfolded timestamp of the first frame of the new stream, in units based on The number of clock ticks; The last displayed timestamp, in milliseconds, is maintained as the primary display time during the switching process. The time base denominator for the newly inserted video stream is typically 90000, or 90kHz, in an MPEG-TS stream; by converting millisecond-level timestamps to seconds and multiplying them by the frequency base, the system forces the timeline of the new stream to continue smoothly from where the main stream was interrupted.

[0160] When AER detects the remaining lifetime of the stream placeholder node Approaching the preset seamless connection threshold For example, a pre-buffering threshold of 200ms can be set. This parameter is determined by the average decoder startup latency measured during the device initialization phase by running a decoder benchmark test, or configured to a conservative empirical value that covers the decoding latency of mainstream devices. In this case, the system initializes the decoder for the main content in advance and pre-buffers it in a background thread. exist Keyframe data at the location;

[0161] when When the system triggers context recovery logic, it directly switches the input source of the rendering pipeline to the preheated main decoder and destroys the interstitial stream decoder, thereby achieving seamless continuation of the main content after the interstitial stream ends, eliminating the black screen gap caused by traditional jump operations.

[0162] If the current playback time is less than the trigger timestamp, the state of the instruction circular queue remains unchanged, and the current check is exited.

[0163] Example 2:

[0164] Please see Figure 2 A video segment-level content management and control system, comprising the following modules:

[0165] The discrete mapping construction module is used to obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video time axis. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period.

[0166] The asynchronous look-ahead detection module is used to calculate the look-ahead time based on the current playback time during video playback using an asynchronous look-ahead thread that is independent of the main playback progress thread, and to read the target raster data corresponding to the look-ahead time from the time-series state index structure.

[0167] The preprocessing and instruction caching module is used to execute the preprocessing logic corresponding to the control identifier based on the control identifier present in the target raster data to generate an execution instruction object, and push the execution instruction object into the instruction circular queue in timestamp order;

[0168] The frame-level synchronization execution module is used to check the head of the instruction circular queue when the main video playback thread renders each frame, and apply the execution instruction object if the execution instruction object at the head of the instruction circular queue matches the current playback time.

[0169] This embodiment provides a hardware and software architecture for a video segment-level content management and control system. The various modules of this system work collaboratively to execute the methods described above. The discrete mapping construction module is responsible for maintaining the lifecycle of the temporal state index structure and handling the parsing and mapping construction of rule sets. The asynchronous lookahead detection module contains an independent daemon thread responsible for performing lookahead calculations and business preprocessing. It acts as a bridge connecting static rules and dynamic instructions through an asynchronous lookahead thread independent of the main playback thread. The preprocessing and instruction caching module manages the instruction circular queue, performs instruction merging and optimization, and ensures the orderliness and compactness of instructions. The frame-level synchronous execution module is embedded in the rendering loop of the main video playback thread, responsible for time comparison and instruction application, and directly affects the user-visible view layer.

[0170] In cross-platform player integration scenarios, this embodiment separates probing and execution on physical threads, enabling the system architecture to achieve high cohesion and low coupling among various functional components. It can be easily integrated into various existing player kernels without modifying the underlying decoding logic of the player, exhibiting extremely high versatility and scalability.

[0171] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for video segment-level content management and control, characterized in that, The method includes the following steps: Obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video timeline. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period. During video playback, an asynchronous lookahead thread, independent of the main playback progress thread, calculates the lookahead time based on the current playback time and reads the target raster data corresponding to the lookahead time from the time-series state index structure. Based on the control identifier present in the target raster data, the preprocessing logic corresponding to the control identifier is executed to generate an execution instruction object, and the execution instruction object is pushed into the instruction circular queue in timestamp order; When the main video playback thread renders each frame, it checks the head of the instruction circular queue, and if the current playback time matches the execution instruction object at the head of the instruction circular queue, it applies the execution instruction object.

2. The method according to claim 1, characterized in that, The step of mapping the video segment control rule set to a temporal state index structure corresponding to the video timeline includes: The start timestamp, end timestamp, and control type of the video segment control rule set are parsed. Establish a sparse mapping structure with time code as the index key and the control type as the value as the time-series state index structure; For time periods not included in the video segment control rule set, they are marked as empty in the sparse mapping structure.

3. The method according to claim 1, characterized in that, The step of generating an execution instruction object by executing the preprocessing logic corresponding to the control identifier existing in the target raster data includes: Identify the specific business type of the control identifier, wherein the business type includes permission verification, material replacement, or content masking; In the asynchronous lookahead thread, the time-consuming operation corresponding to the business type is executed asynchronously, and the operation result is obtained; The operation result is encapsulated into an execution instruction object containing a trigger timestamp and an execution action.

4. The method according to claim 3, characterized in that, The step of pushing the execution instruction objects into the instruction circular queue in timestamp order further includes: Detect whether multiple consecutive time grids read by the asynchronous lookahead thread have the same control identifier; When multiple execution instruction objects have the same control identifier, they are merged into a single persistent instruction object. The persistent instruction object is pushed into the instruction circular queue for the main thread of playback progress to read.

5. The method according to claim 1, characterized in that, The method also includes a dynamic update step: In response to receiving a new rule version number from the server, a new time-series state index structure is constructed in a background thread; Atomic operations are used to replace the pointer to the old time-series state index structure with a pointer to the new time-series state index structure. In the next scan performed by the asynchronous lookahead thread, the target raster data is read based on the new temporal state index structure.

6. The method according to claim 1, characterized in that, The step of checking the head of the instruction circular queue when rendering each frame on the main video playback thread includes: Read the trigger timestamp of the executed instruction object from the head of the instruction circular queue; The current playback time is compared with the trigger timestamp: if the current playback time is greater than or equal to the trigger timestamp, the match is considered successful, and the execution instruction object is removed from the instruction circular queue; if the current playback time is less than the trigger timestamp, the state of the instruction circular queue remains unchanged.

7. The method according to claim 6, characterized in that, The application of the execution instruction object includes: Based on the action type in the execution instruction object, a mask layer is overlaid, a video stream jump operation is performed, or the current decoding data source is replaced in the rendering pipeline of the main video playback thread.

8. A video segment-level content management and control system, characterized in that, Includes the following modules: The discrete mapping construction module is used to obtain the video segment control rule set containing version information issued by the server, and map the video segment control rule set into a time-series state index structure corresponding to the video time axis. The time-series state index structure divides the video duration into discrete time grids, and each time grid stores the control identifier corresponding to the time period. An asynchronous look-ahead detection module is used to calculate the look-ahead time based on the current playback time during video playback using an asynchronous look-ahead thread independent of the main playback progress thread, and to read the target raster data corresponding to the look-ahead time from the time-series state index structure. The preprocessing and instruction caching module is used to execute the preprocessing logic corresponding to the control identifier based on the control identifier present in the target raster data to generate an execution instruction object, and push the execution instruction object into the instruction circular queue in timestamp order; The frame-level synchronization execution module is used to check the head of the instruction circular queue when the main thread of video playback renders each frame, and apply the execution instruction object if the current playback time matches the execution instruction object at the head of the instruction circular queue.