Script implementation method based on timeline random distribution
By employing a timeline-based random distribution script system in video post-production, and utilizing an improved Poisson disk sampling algorithm and various adjustable parameters, the problems of low layer element distribution efficiency, uncontrollable randomness, and inflexible parameter adjustment are solved, achieving efficient and controllable layer distribution operations and preset management.
Patent Information
- Application Number
- CN202511021571.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-11-18
AI Technical Summary
In current video post-production, the random distribution of layer elements on the timeline suffers from problems such as low efficiency, uncontrollable random effects, inflexible parameter adjustment, lack of a visual interface, and inability to save presets.
A timeline-based random distribution script system is adopted, including a user interface module, a core algorithm module, and a preset management module. It uses an improved Poisson disk sampling algorithm to achieve random and uniform distribution of layer elements and provides a variety of adjustable parameters and preset management functions.
It significantly improves the efficiency of layer distribution, ensures the scientific controllability of random distribution, offers flexible and diverse parameter adjustments, is user-friendly and intuitive to operate, and supports preset management to avoid repetitive operations and improve CG production efficiency.
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of video post-processing, in particular to a timeline random distribution script implementation method for Adobe After Effects software, mainly used for efficient and intelligent random distribution processing of layer elements in the video production process. BACKGROUND
[0002] In the existing video post-production process, especially when using Adobe After Effects (hereinafter referred to as AE) for animation production, designers often need to perform random distribution processing of a large number of layer elements on the timeline. The traditional method has the following technical defects:
[0003] Manual adjustment is inefficient: when dealing with hundreds of layers, designers need to adjust the position of each layer on the timeline, which is time-consuming and laborious.
[0004] Random effect is uncontrollable: manual random distribution cannot guarantee the uniformity and randomness of time intervals, and may cause element accumulation or uneven distribution.
[0005] Parameter adjustment is not flexible: most existing scripts use fixed algorithms, which cannot adjust random distribution parameters according to different project requirements.
[0006] Lack of visual interface: most scripts require parameter modification through code, which is not user-friendly for non-technical personnel.
[0007] Cannot save presets: each use requires reconfiguration of parameters, and common configurations cannot be saved.
[0008] Based on this, the present application is proposed. SUMMARY
[0009] The purpose of the present application is to provide a timeline random distribution script implementation method to solve the above problems.
[0010] A timeline random distribution script implementation method is implemented by using an AE script system, which includes a user interface module, a core algorithm module, a data processing module, and a preset management module.
[0011] Further improvement, the core algorithm module uses an improved Poisson disc sampling algorithm to realize random and uniform distribution of the timeline.
[0012] Further improvement, the improved Poisson disc sampling algorithm includes the following steps:
[0013] Step S1, initialize the time grid;
[0014] Step S2, generating initial random points;
[0015] Step S3, expanding sampling points through activity list;
[0016] Step S4, dynamically adjusting sampling radius;
[0017] Step S5, processing boundary conditions.
[0018] Further improvement, the user interface module provides at least 4 adjustable parameters, including time range, minimum interval, random intensity, distribution mode.
[0019] Further improvement, the preset management module supports preset saving, loading, exporting and sharing functions.
[0020] Further improvement, the method implemented by the AE script system comprises the following steps:
[0021] Step P1, obtaining selected layer information;
[0022] Step P2, receiving user parameter input;
[0023] Step P3, applying core algorithm to calculate distribution position;
[0024] Step P4, detecting and solving layer conflicts;
[0025] Step P5, applying results to timeline.
[0026] Further improvement, in step P4, the layer conflict detection adopts a multi-layer grid detection algorithm, including two stages of rough detection and accurate detection.
[0027] Further improvement, a storage medium having a computer program stored thereon, the program being executed by a processor to implement the above method.
[0028] Compared with the prior art, the present application has the following beneficial effects:
[0029] 1. Significantly improve work efficiency: processing 100 layer random distribution only needs 3-5 seconds, compared with manual adjustment, the efficiency is improved by more than 50 times.
[0030] 2. Random distribution is scientific and controllable: improved Poisson disc sampling algorithm is adopted to ensure that the time interval is both random and uniform.
[0031] 3. Flexible and diverse parameter adjustment: 12 adjustable parameters are provided to meet different project requirements.
[0032] 4. Friendly and intuitive operation interface: complex timeline random distribution operation can be completed without programming knowledge.
[0033] 5. Convenient and fast preset management: common configurations can be saved, and preset sharing between teams is supported.
[0034] 6. Avoiding repeated operations and improving CG production efficiency. DETAILED DESCRIPTION
[0035] The application will be further described in detail below through specific examples.
[0036] Example 1
[0037] 1. System architecture implementation
[0038] The system is developed using ExtendScript language and is deeply integrated with AE software. The overall architecture is divided into four layers:
[0039] Presentation layer: provides a graphical user interface (GUI) and is implemented using AE's ScriptUI technology.
[0040] Logic layer: contains core algorithms and business logic processing.
[0041] Data layer: responsible for layer information collection and parameter storage.
[0042] Interface layer: provides an interactive interface with AE software API.
[0043] 2. Core algorithm implementation
[0044] 2.1. Timeline random distribution main algorithm
[0045] The timeline random distribution main algorithm is the core control process of the system, responsible for coordinating various sub-modules to complete the complete process from parameter input to final application. The algorithm uses a hierarchical processing architecture to ensure that the time distribution meets the randomness requirements and conforms to various constraint conditions set by the user.
[0046] Detailed processing flow:
[0047] 1) Parameter acquisition stage:
[0048] All user-set parameters are collected from the GUI interface, including:
[0049] Time range parameters (start time / end time);
[0050] Distribution control parameters (minimum interval / random intensity);
[0051] Advanced options (distribution mode / conflict handling strategy);
[0052] Standardize the parameters and convert them to frame-based time representation;
[0053] Verify parameter logic validity (e.g. end time cannot be earlier than start time);
[0054] 2) Layer pre-processing phase:
[0055] Get the selected layer set in the current AE composition;
[0056] Filter out locked and invisible layers (according to user settings);
[0057] Sort layers by name or creation time (optional);
[0058] Calculate the duration of each layer (considering in-point / out-point);
[0059] 3) Spatial calculation phase:
[0060] Calculate the theoretical average interval based on the number of layers and time span;
[0061] Invoke Poisson Disc Sampling algorithm to generate time position sequence;
[0062] Adjust distribution density with user-set random intensity factor;
[0063] Handle boundary conditions (special position requirements for first and last layers);
[0064] 4) Conflict resolution phase:
[0065] Invoke conflict detection algorithm to identify all time overlaps;
[0066] Handle conflicts according to user-selected strategy:
[0067] Shift strategy: move overlapping layers backward;
[0068] Compression strategy: shorten layer duration;
[0069] Skip strategy: remove severely overlapping layers;
[0070] Iterate until conflict rate is below threshold (default <1%);
[0071] 5) Result application phase:
[0072] Map calculated time positions to actual layers;
[0073] Batch set in-point properties for layers;
[0074] Add optional effect keyframes (e.g. fade-in / fade-out);
[0075] Generate operation report (including processed layer count / conflict count, etc.);
[0076] 6) Special handling mechanisms:
[0077] Dynamic adjustment mechanism: When detecting that the parameter combination cannot meet the distribution requirements, automatically relax the constraint conditions and prompt the user;
[0078] Progressive preview: When processing a large number of layers, update the preview picture every 20% completed;
[0079] Undo stack management: Automatically save the state before application, support one-key undo;
[0080] 2.2, Poisson disc sampling algorithm improvement
[0081] The traditional Poisson disc sampling algorithm is used to generate a random and uniform distribution of point sets in a two-dimensional plane. The invention improves it and applies it to one-dimensional timeline distribution, and makes a number of optimizations for AE special needs.
[0082] Improvement points:
[0083] 1), Dimension adaptation improvement:
[0084] Simplify the two-dimensional grid to a one-dimensional time grid;
[0085] The cell size is automatically calculated according to the minimum interval;
[0086] Linearize all neighborhood query operations.
[0087] Dynamic radius mechanism:
[0088] Basic sampling radius = user-set minimum interval;
[0089] Dynamic adjustment factor = 1 + (randomness*rand(-1,1));
[0090] Randomness is a user-set random intensity parameter (0-1);
[0091] Actual sampling radius = basic radius x adjustment factor;
[0092] Boundary processing optimization:
[0093] Start time zone (first 10%) and end time zone (last 10%) are handled specially:
[0094] Allow higher point density than the middle area;
[0095] But forced to maintain the minimum interval constraint;
[0096] Prevent points from concentrating too much near the boundary;
[0097] Acceleration strategy:
[0098] Precompute candidate list: 30 candidates per active point;
[0099] Early termination: terminate current point attempt when 10 consecutive candidates fail;
[0100] Grid space index: use 1D array for fast neighbor lookup;
[0101] Full algorithm steps:
[0102] Initialize:
[0103] Create grid array of size (timeRange / cellSize);
[0104] All grid initially -1 (empty);
[0105] Generate first random point and put into active list;
[0106] Main loop:
[0107] while active list not empty AND num generated points < required:
[0108] a. Randomly select active point p;
[0109] b. Try to generate new point:
[0110] fork = 1 to 30:
[0111] Generate random angle (0-2π);
[0112] Compute dynamic radius r;
[0113] New point q = p + r*cos(angle);
[0114] if q within time range:
[0115] Compute grid index gridX;
[0116] if grid gridX is empty:
[0117] Check neighborhood 2r for no collision:
[0118] if no collision:
[0119] Record new point q;
[0120] Update grid;
[0121] Add to active list;
[0122] Break;
[0123] c. If number of failures > threshold:
[0124] Remove p from the activity list;
[0125] Fill phase:
[0126] while the number of generated points < the number of required points:
[0127] Generate a completely random point;
[0128] Only check the minimum interval constraint;
[0129] Join the result set;
[0130] Post-processing:
[0131] Sort the result point set;
[0132] Apply the final boundary adjustment;
[0133] Return the time position array;
[0134] Performance optimization:
[0135] Use TypedArray to improve grid access speed;
[0136] Cache trigonometric function calculation results;
[0137] Batch processing neighborhood queries.
[0138] 2.3, Layer conflict detection algorithm
[0139] Accurately identify all layer pairs that overlap in the time dimension and quantify the degree of overlap to provide data support for subsequent conflict resolution.
[0140] Detection principle:
[0141] Based on the interval intersection theory, each layer is regarded as an interval [inPoint, outPoint] on the time axis, and when the intersection of two intervals is non-empty, it is determined as a conflict.
[0142] Multi-level detection architecture:
[0143] Fast screening layer:
[0144] Based on layer type filtering (such as audio tracks and video tracks by default not to detect conflicts);
[0145] Use spatial index (segmented by 100 frames) to quickly exclude obviously non-overlapping layer pairs;
[0146] Accurate detection layer:
[0147] Accurate time interval detection for layers that may overlap;
[0148] Calculate the actual number of overlapping frames;
[0149] Record conflict details;
[0150] Performance optimization measures:
[0151] Sort by start time first, use temporal locality to reduce comparison times;
[0152] Use space jump technique: when detecting a certain layer has no conflict with subsequent multiple layers, skip a certain range of detection;
[0153] Parallel processing: use Web Worker to detect independently;
[0154] Conflict data output structure:
[0155] Each conflict record contains:
[0156] Layer ID pair;
[0157] Overlap type;
[0158] Overlap time amount (frame number);
[0159] Conflict time interval;
[0160] Severity score (based on overlap ratio);
[0161] Special processing:
[0162] Special detection of audio waveform conflict (considering sound aliasing effect);
[0163] Duration prediction of nested composite layers;
[0164] Time expansion processing of pre-composite layers;
[0165] The algorithm can achieve: 1000 layers of full detection time <500ms in actual test;
[0166] Conflict detection accuracy >99.9%;
[0167] Memory usage linear growth (O(n)).
[0168] 3、User interface implementation
[0169] The user interface is built with the AE ScriptUI framework, mainly including the following areas: time range setting area:
[0170] Start time input box;
[0171] End time input box;
[0172] Time unit selector (frame / second / minute);
[0173] Random parameter setting area:
[0174] Minimum interval setting;
[0175] Random intensity slider (0-100%);
[0176] Distribution mode selection (uniform / cluster / custom);
[0177] Layer filtering area:
[0178] Filter by name;
[0179] Filter by type (video / audio / text, etc.);
[0180] Filter by tag color;
[0181] Preview control area:
[0182] Real-time preview switch;
[0183] Conflict highlight;
[0184] Timeline zoom control;
[0185] Preset management area:
[0186] Preset save button;
[0187] Preset load dropdown menu;
[0188] Preset export / import function;
[0189] 4. Parameter explanation;
[0190] The system provides the following adjustable parameters:
[0191] Basic parameters:
[0192] Time range (start time / end time);
[0193] Minimum time interval (frame number or second);
[0194] Random intensity (0-100%);
[0195] Advanced parameters:
[0196] Distribution mode (uniform / cluster / custom curve);
[0197] Time offset (overall forward / backward);
[0198] Layer duration processing (keep original / uniform length); Special effect parameters:
[0199] Interleaving offset;
[0200] Random scaling factor;
[0201] Cross-fade effect;
[0202] 5. Workflow
[0203] 5.1. Initialization phase:
[0204] Load AE current project;
[0205] Scan timeline layers;
[0206] Initialize user interface;
[0207] 5.2. Parameter setting phase:
[0208] User sets distribution parameters;
[0209] System verifies parameter validity;
[0210] Generate preview effect;
[0211] 5.3. Execution phase:
[0212] Apply core algorithm to calculate time position; detect and resolve layer conflicts;
[0213] Apply results to timeline;
[0214] 5.4. Post-processing phase:
[0215] Save current configuration as preset;
[0216] Generate operation report;
[0217] Clean up temporary data;
[0218] 6. Exception handling mechanism
[0219] System contains the following exception handling functions: parameter verification:
[0220] Check time range validity;
[0221] Verify minimum interval reasonableness;
[0222] Ensure that the random intensity is within a reasonable range; conflict resolution:
[0223] Automatically adjust overlapping layers;
[0224] Provide multiple resolution strategies (offset / shorten / skip); generate conflict report;
[0225] Error recovery:
[0226] Operation history record;
[0227] Undo / redo function;
[0228] Automatic backup mechanism.
[0229] Example 2
[0230] User selects 50 text layers in AE;
[0231] Open this script interface;
[0232] Set the time range to 0-10 seconds;
[0233] Set the minimum interval to 0.2 seconds;
[0234] Set the random intensity to 70%;
[0235] Click the "Apply" button;
[0236] The system completes the random distribution of all layers within 1.2 seconds.
[0237] Example 3
[0238] Advanced cluster distribution;
[0239] User selects 120 graphic layers;
[0240] Set the time range to 5-30 seconds;
[0241] Select the "cluster" distribution mode;
[0242] Set 3 cluster center points;
[0243] Adjust the density and range of each cluster;
[0244] Enable the "automatic conflict resolution" option;
[0245] The system completes the complex distribution within 3.5 seconds.
[0246] The above is only the preferred embodiment of the present application, and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A script implementation method based on random distribution over a timeline, characterized in that: It is implemented using an After Effects (AE) scripting system, which includes a user interface module, a core algorithm module, a data processing module, and a preset management module.
2. The script implementation method based on random distribution over time as described in claim 1, characterized in that: The core algorithm module employs an improved Poisson disk sampling algorithm to achieve a random yet uniform distribution of the timeline.
3. The script implementation method based on random distribution over time as described in claim 2, characterized in that: The improved Poisson disk sampling algorithm includes the following steps: Step S1: Initialize the time grid; Step S2: Generate initial random points; Step S3: Expand sampling points using the activity list; Step S4: Dynamically adjust the sampling radius; Step S5: Handle boundary conditions.
4. The script implementation method based on random distribution over time as described in claim 1, characterized in that: The user interface module provides at least four adjustable parameters, including time range, minimum interval, random intensity, and distribution pattern.
5. The script implementation method based on random distribution over time as described in claim 1, characterized in that: The preset management module supports preset save, load, export, and share functions.
6. The script implementation method based on random distribution over time as described in claim 1, characterized in that: The method implemented using the AE scripting system includes the following steps: Step P1: Obtain information about the selected layer; Step P2: Receive user parameter input; Step P3: Apply the core algorithm to calculate the distribution location; Step P4: Detect and resolve layer conflicts; Step P5: Apply the results to the timeline.
7. The script implementation method based on random distribution over time as described in claim 6, characterized in that: In step P4, layer conflict detection employs a multi-layer mesh detection algorithm, which includes two stages: coarse detection and precise detection.
8. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by the processor, it implements the method as described in any one of claims 1-7.