I have been using this editing workflow for over two months and have iterated through no fewer than 10 versions. In this article, I will explain the complete process and details as clearly as possible for my friends.
You can follow the logic of the article or directly send this article to Codex to let the AI create a Skill for you.
Hi friends, I'm here to deliver the draft!
Last week, I wrote an introductory article about Codex, and I'm very grateful for the support—it reached over a million views.
https://x.com/xilo2991/status/2070051136187621452
At that time, many friends asked if I could share the automated editing mentioned in the article.
Of course. Today, I'm here to chat with you about how to achieve automated editing with Codex to maximize video creation efficiency.
The Underlying Logic of the Workflow
Whether you are doing content or e-commerce, the easiest way to get traffic quickly is to copy viral hits.
Because viral hits are content already verified by the market, as long as you follow them fast enough, the traffic generally won't be bad. (Of course, pay attention to the difference between copying and plagiarism.)
The core of this workflow is copying viral hits.
Suppose you see a viral video and want to make your own video following that rhythm and structure. The traditional way is to manually go into CapCut (Jianying) and frame-by-frame match the reference video, find materials, time them, and align subtitles. One video might take two or three hours.
But with this workflow, you only need to prepare the reference video and your own material library; Codex can automatically complete the rest.
Codex will automatically identify every shot transition in the reference video, find the best matching material from your library, automatically generate voiceovers and subtitles, and finally give you a CapCut draft that you can open and edit.
The whole process might take just a few minutes.
I mainly use this workflow when making Douyin product videos.
Before Codex, I could only edit 6 videos a day at most. But with Codex, I just need to find suitable viral videos as references and prepare the product materials. The rest is automatic generation, review, and fine-tuning.
I can easily finish 30 videos a day, an efficiency increase of at least five times.

But let's be clear: the positioning of this workflow is automatic production, not boutique creation.
It is suitable for mashup-style videos that require splicing multiple segments, such as e-commerce, marketing, or mashup Vlogs.
The reference video provides the structure and rhythm, your material library provides the visuals, voiceovers and subtitles are automatically generated, and the final video is produced automatically.
If you want to create high-quality original content that requires very precise cinematic language, complex transitions, and delicate emotional expression, this process might not be suitable.
Because the current automatic matching logic cannot yet achieve such precise semantic understanding and emotional control.
I am also researching how to optimize this process for original videos and will share it with friends once it's stable.
Workflow Preparation
OK, back to the automated editing workflow. Below, I will explain step-by-step how to build this workflow. Before starting, you need to prepare two things.
1. Install Corresponding Tools
This workflow is based on Codex, so you first need to have Codex. If you haven't used it, check my introductory article from last week.
Specifically, this workflow requires these core tools:
- FFmpeg: Used for underlying operations like video splitting, merging, and format conversion. This is the foundation and must be installed.
- Python Environment: Since the entire process is written in Python, you need at least Python 3.8.
- Voiceover Tools: If you want automatic voiceovers, the most stable is ByteDance's Doubao voice model; if you want to clone voices, use VoxCPM, a free open-source tool.
- CapCut (Jianying): The final generated draft is in CapCut format, so you need the desktop version installed.
Among these, FFmpeg and Python are core dependencies.
You can copy the following text to Codex to help you check the environment and install missing tools:
1Please help me check the environment needed for automated video editing:231. Check if FFmpeg is installed; if not, help me install it.42. Check if Python version is >= 3.8; if not, help me install or upgrade it.53. Check if CapCut (Jianying) Professional is installed; if not, tell me the download link.64. Install Python dependencies: opencv-python, numpy, pillow78After checking, tell me what is ready and what I need to handle manually.
For voiceovers, it depends on your needs. If you are doing e-commerce videos, the Doubao voice model is the most stable. It uses the same AI voices as CapCut. The price is low—generating a 1-minute video costs about 0.4-0.8 RMB.
If you want to use your own voice or clone someone else's, use VoxCPM. Find the link on GitHub and send it to Codex to install.
2. Create Folders
After installing these, you need to create a project folder. I usually organize it like this:
1Project Folder/2 assets/ # Your material library3 work/ # Work area, create a date folder for each edit4 final/ # Final products5 AGENTS.md # Project configuration file
The assets folder is your library. Put all potentially useful materials there. These can be AI-generated or filmed by you, but they should be prepared in advance as reusable assets.
Materials can be categorized by appearance, function, or scene.
The work folder is for active projects. Every time you make a new video, create a date folder like 2026-07-05 and put the reference video, intermediate files, and final draft there.
AGENTS.md is the configuration file containing project goals, output specs, and acceptance criteria. This is crucial because Codex uses it to understand your needs.

PS: My own AGENTS file is a bit long, so I put it at the end for reference.
Building the Editing Workflow
1. Deconstruct the Reference Video
The core goal here is to split the reference video into independent shots and extract keyframes for each shot as a basis for material matching.
Find a video you want to reference. Download it, put it in the work folder, and give it a clear name.
Then send this to Codex:
1I need to deconstruct a reference video.23Reference video location: @(input your filename)45Please help me with:61. Use FFmpeg to identify shot transitions (via inter-frame difference analysis).72. Extract keyframes for each shot and save them as images.83. Extract the audio track separately.94. Generate a recipe.json file recording start time, end time, duration, and keyframe path for each shot.105. If there is text, generate a voiceover script based on the audio, segmented by shot.1112After completion, follow AGENTS.md requirements, save to the corresponding folder, and tell me how many shots were identified.
This recipe.json file is the core of the entire process.

After deconstruction, you will see many small video clips and screenshots. Check if the split is reasonable. If not, you can ask Codex to adjust.
2. Filter and Match Materials
This step is the most critical and demonstrates the value of automation.
Traditionally, you'd search your library shot by shot. With this workflow, you just tell Codex where your library is, and it performs visual matching.
Prompt for Codex:
1I need to match and replace materials from the library.23Project info:4- recipe.json path: (path from previous step)5- Material library path: assets/6- Output path: work/(your path)78Matching requirements:91. Read keyframes from recipe.json.102. Traverse the library and extract keyframes for each asset.113. Recommend the best matching material via color, brightness, and composition (provide confidence scores).124. Apply rules: avoid using the same material for 3 consecutive shots; avoid obvious repetitive compositions.135. Generate fragment_plan.json and matches.json.146. Copy (do not move) selected materials to material/fragment01/, etc.1516Principle: If confidence is below 0.6, mark as "missing material."
Codex calculates similarity based on visual features. High-scoring materials are prioritized.

matches.json records the final results. A key principle: Better to leave a material blank than to force an irrelevant one.
3. Generate Voiceover
After matching, generate the voiceover. Since Codex uses OCR/ASR, check the script for errors first.
Prompt:
1I need to generate voiceovers. Script is @(your script.txt)23Requirements:41. Call Doubao TTS API to generate independent audio for each shot.52. Read the actual duration of each audio file.63. If the duration differs from the reference shot, record the difference.74. Merge into final_voice.mp3.85. Update recipe.json with real durations.
Codex will adjust the video rhythm based on the audio. If a voiceover takes 5 seconds for a 3-second reference shot, the final video shot will be extended to 5 seconds.

4. Generate Draft and CapCut Project
Generating the CapCut draft is complex because the format is strict regarding IDs and paths. I've included rules in the prompt to avoid errors.
Prompt:
1I need to generate the final video and CapCut draft.23Input:4- recipe.json, matches.json, material path, voiceover file, script.56Output:71. Render preview video: work/remix.mp482. Subtitle file: work/captions.srt93. CapCut draft: work/jianying_draft/1011Requirements:12- Match materials per recipe and matches.json.13- Use voiceover duration as the baseline.14- Ensure Content ID, Metadata ID, and Root Index ID are consistent and unique.15- Use absolute paths for materials.

Check if the draft opens correctly, if materials show up, and if subtitles/audio are synced.
Final Words
The entire process from reference to draft takes about 20-30 minutes. With a ready library, it can take as little as 5 minutes per video.
Once the workflow is smooth, tell Codex: Help me encapsulate this workflow into a Skill. Next time, just call the Skill.
I hope this helps. Good luck! 🍀
(AGENTS.md template omitted for brevity in this translation but included in the original text.)





