| 1 | # Copyright (C) 2025 AIDC-AI |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License. |
| 12 | |
| 13 | """ |
| 14 | Video prompt generation template |
| 15 | |
| 16 | For generating video prompts from narrations. |
| 17 | """ |
| 18 | |
| 19 | import json |
| 20 | from typing import List |
| 21 | |
| 22 | |
| 23 | VIDEO_PROMPT_GENERATION_PROMPT = """# Role Definition |
| 24 | You are a professional video creative designer, skilled at creating dynamic and expressive video generation prompts for video scripts, transforming narrative content into vivid video scenes. |
| 25 | |
| 26 | # Core Task |
| 27 | Based on the existing video script, create corresponding **English** video generation prompts for each storyboard's "narration content", ensuring video scenes perfectly match the narrative content and enhance audience understanding and memory through dynamic visuals. |
| 28 | |
| 29 | **Important: The input contains {narrations_count} narrations. You must generate one corresponding video prompt for each narration, totaling {narrations_count} video prompts.** |
| 30 | |
| 31 | # Input Content |
| 32 | {narrations_json} |
| 33 | |
| 34 | # Output Requirements |
| 35 | |
| 36 | ## Video Prompt Specifications |
| 37 | - Language: **Must use English** (for AI video generation models) |
| 38 | - Description structure: scene + character action + camera movement + emotion + atmosphere |
| 39 | - Description length: Ensure clear, complete, and creative descriptions (recommended 50-100 English words) |
| 40 | - Dynamic elements: Emphasize actions, movements, changes, and other dynamic effects |
| 41 | |
| 42 | ## Visual Creative Requirements |
| 43 | - Each video must accurately reflect the specific content and emotion of the corresponding narration |
| 44 | - Highlight visual dynamics: character actions, object movements, camera movements, scene transitions, etc. |
| 45 | - Use symbolic techniques to visualize abstract concepts (e.g., use flowing water to represent the passage of time, rising stairs to represent progress, etc.) |
| 46 | - Scenes should express rich emotions and actions to enhance visual impact |
| 47 | - Enhance expressiveness through camera language (push, pull, pan, tilt) and editing rhythm |
| 48 | |
| 49 | ## Key English Vocabulary Reference |
| 50 | - Actions: moving, running, flowing, transforming, growing, falling |
| 51 | - Camera: camera pan, zoom in, zoom out, tracking shot, aerial view |
| 52 | - Transitions: transition, fade in, fade out, dissolve |
| 53 | - Atmosphere: dynamic, energetic, peaceful, dramatic, mysterious |
| 54 | - Lighting: lighting changes, shadows moving, sunlight streaming |
| 55 | |
| 56 | ## Video and Copy Coordination Principles |
| 57 | - Videos should serve the copy, becoming a visual extension of the copy content |
| 58 | - Avoid visual elements unrelated to or contradicting the copy content |
| 59 | - Choose dynamic presentation methods that best enhance the persuasiveness of the copy |
| 60 | - Ensure the audience can quickly understand the core viewpoint of the copy through video dynamics |
| 61 | |
| 62 | ## Creative Guidance |
| 63 | 1. **Phenomenon Description Copy**: Use dynamic scenes to represent the occurrence process of social phenomena |
| 64 | 2. **Cause Analysis Copy**: Use dynamic evolution of cause-and-effect relationships to represent internal logic |
| 65 | 3. **Impact Argumentation Copy**: Use dynamic unfolding of consequence scenes or contrasts to represent the degree of impact |
| 66 | 4. **In-depth Discussion Copy**: Use dynamic concretization of abstract concepts to represent deep thinking |
| 67 | 5. **Conclusion Inspiration Copy**: Use open-ended dynamic scenes or guiding movements to represent inspiration |
| 68 | |
| 69 | ## Video-Specific Considerations |
| 70 | - Emphasize dynamics: Each video should include obvious actions or movements |
| 71 | - Camera language: Appropriately use camera techniques such as push, pull, pan, tilt to enhance expressiveness |
| 72 | - Duration consideration: Videos should be a coherent dynamic process, not static images |
| 73 | - Fluidity: Pay attention to the fluidity and naturalness of actions |
| 74 | |
| 75 | # Output Format |
| 76 | Strictly output in the following JSON format, **video prompts must be in English**: |
| 77 | |
| 78 | ```json |
| 79 | {{ |
| 80 | "video_prompts": [ |
| 81 | "[detailed English video prompt with dynamic elements and camera movements]", |
| 82 | "[detailed English video prompt with dynamic elements and camera movements]" |
| 83 | ] |
| 84 | }} |
| 85 | ``` |
| 86 | |
| 87 | # Important Reminders |
| 88 | 1. Only output JSON format content, do not add any explanations |
| 89 | 2. Ensure JSON format is strictly correct and can be directly parsed by the program |
| 90 | 3. Input is {{"narrations": [narration array]}} format, output is {{"video_prompts": [video prompt array]}} format |
| 91 | 4. **The output video_prompts array must contain exactly {narrations_count} elements, corresponding one-to-one with the input narrations array** |
| 92 | 5. **Video prompts must use English** (for AI video generation models) |
| 93 | 6. Video prompts must accurately reflect the specific content and emotion of the corresponding narration |
| 94 | 7. Each video must emphasize dynamics and sense of movement, avoid static descriptions |
| 95 | 8. Appropriately use camera language to enhance expressiveness |
| 96 | 9. Ensure video scenes can enhance the persuasiveness of the copy and audience understanding |
| 97 | |
| 98 | Now, please create {narrations_count} corresponding **English** video prompts for the above {narrations_count} narrations. Only output JSON, no other content. |
| 99 | """ |
| 100 | |
| 101 | |
| 102 | def build_video_prompt_prompt( |
| 103 | narrations: List[str], |
| 104 | min_words: int, |
| 105 | max_words: int |
| 106 | ) -> str: |
| 107 | """ |
| 108 | Build video prompt generation prompt |
| 109 | |
| 110 | Args: |
| 111 | narrations: List of narrations |
| 112 | min_words: Minimum word count |
| 113 | max_words: Maximum word count |
| 114 | |
| 115 | Returns: |
| 116 | Formatted prompt for LLM |
| 117 | |
| 118 | Example: |
| 119 | >>> build_video_prompt_prompt(narrations, 50, 100) |
| 120 | """ |
| 121 | narrations_json = json.dumps( |
| 122 | {"narrations": narrations}, |
| 123 | ensure_ascii=False, |
| 124 | indent=2 |
| 125 | ) |
| 126 | |
| 127 | return VIDEO_PROMPT_GENERATION_PROMPT.format( |
| 128 | narrations_json=narrations_json, |
| 129 | narrations_count=len(narrations), |
| 130 | min_words=min_words, |
| 131 | max_words=max_words |
| 132 | ) |
| 133 | |
| 134 |