ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 282 KiB |
|
After Width: | Height: | Size: 179 KiB |
|
After Width: | Height: | Size: 258 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 382 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 282 KiB |
|
After Width: | Height: | Size: 284 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 284 KiB |
|
After Width: | Height: | Size: 330 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 179 KiB |
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"request": "Cut out the shot of the large white rabbit walking alone in the sunny meadow, slow it to 1.5x duration, and add the subtitle BIG BUNNY along the bottom.",
|
||||
"target": "the single continuous shot showing the large white rabbit walking alone in a sunny green meadow, after the ONE BIG RABBIT title and before the THREE RODENTS title",
|
||||
"coarse_interval_s": 10,
|
||||
"coarse_frames": [
|
||||
{
|
||||
"timestamp_s": 0.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/coarse/frame-000.00.png",
|
||||
"sha256": "cdd5c7f27f84347a40eb467c356c5a2fda3facdad9057f246034e355b89dcfdd",
|
||||
"bytes": 1580
|
||||
},
|
||||
{
|
||||
"timestamp_s": 10.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/coarse/frame-010.00.png",
|
||||
"sha256": "bdf01683fab23e1e98099d0f6e19596eabcd96ddb1c643b3d0c6749b5f2995a9",
|
||||
"bytes": 288771
|
||||
},
|
||||
{
|
||||
"timestamp_s": 20.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/coarse/frame-020.00.png",
|
||||
"sha256": "713c2f7a5db41b01640dbae71ef4d5057c382dd1480d9e31bcc3f6d05c9da52b",
|
||||
"bytes": 183618
|
||||
},
|
||||
{
|
||||
"timestamp_s": 30.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/coarse/frame-030.00.png",
|
||||
"sha256": "ce5d5733e716607000f9d6aef75dbb9b31279dd50e7db7c6c1e714819624224a",
|
||||
"bytes": 264372
|
||||
},
|
||||
{
|
||||
"timestamp_s": 31.495,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/coarse/frame-031.50.png",
|
||||
"sha256": "57e555d305ac18228155454935f9a411a9e21ccc092348997f8e3299d4011b89",
|
||||
"bytes": 40146
|
||||
}
|
||||
],
|
||||
"coarse_result": {
|
||||
"start": 5.0,
|
||||
"end": 15.0,
|
||||
"reason": "The 10.00s frame shows the large white rabbit alone in a sunny green meadow with green grass, mountains, and clouds. The next frame at 20.00s features three rodents, indicating the rabbit shot ends before 20.00s. It starts after the 'ONE BIG RABBIT' title (before 10.00s), so the rough interval is 5.0-15.0s."
|
||||
},
|
||||
"fine_interval_s": 1,
|
||||
"fine_window": [
|
||||
0,
|
||||
20
|
||||
],
|
||||
"fine_frames": [
|
||||
{
|
||||
"timestamp_s": 0.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-000.00.png",
|
||||
"sha256": "cdd5c7f27f84347a40eb467c356c5a2fda3facdad9057f246034e355b89dcfdd",
|
||||
"bytes": 1580
|
||||
},
|
||||
{
|
||||
"timestamp_s": 1.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-001.00.png",
|
||||
"sha256": "702f6c8f994090d5f989709bea4372d9cfccb64ea4e09e8245639be85436ddc0",
|
||||
"bytes": 30336
|
||||
},
|
||||
{
|
||||
"timestamp_s": 2.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-002.00.png",
|
||||
"sha256": "0ad215be811389364b7616996f62082234c5759d2f5e489b50c2c794933dcb11",
|
||||
"bytes": 30702
|
||||
},
|
||||
{
|
||||
"timestamp_s": 3.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-003.00.png",
|
||||
"sha256": "ac7283cb0e9b36e87fffa5ef702b4ebc839c2cae9d68c2486ad6b7c6137281de",
|
||||
"bytes": 31566
|
||||
},
|
||||
{
|
||||
"timestamp_s": 4.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-004.00.png",
|
||||
"sha256": "83e61400d490cb6d008465e31f72466b14b8efbc25695003e571715a5ecf2609",
|
||||
"bytes": 391627
|
||||
},
|
||||
{
|
||||
"timestamp_s": 5.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-005.00.png",
|
||||
"sha256": "7bf0f2f437e8781ac96e6a27b41f975189c3784dbd3368672d43fd4b2d92813a",
|
||||
"bytes": 451029
|
||||
},
|
||||
{
|
||||
"timestamp_s": 6.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-006.00.png",
|
||||
"sha256": "618ee855deb607995c0be98d0a64db5614c4f851837af105e0672822947fe361",
|
||||
"bytes": 451002
|
||||
},
|
||||
{
|
||||
"timestamp_s": 7.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-007.00.png",
|
||||
"sha256": "40e9724ee1834abee7d12002cd83a4120738b0ffd0a294741c25c2135edb02b8",
|
||||
"bytes": 196294
|
||||
},
|
||||
{
|
||||
"timestamp_s": 8.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-008.00.png",
|
||||
"sha256": "1da6191f1a0c6ccc987a8e5d0682d7e664aa4ce8b8ce31d232bec5ae695b0c4e",
|
||||
"bytes": 25229
|
||||
},
|
||||
{
|
||||
"timestamp_s": 9.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-009.00.png",
|
||||
"sha256": "c0358569f2defb8cfdcd0c73393fc2e75cab6168920819a7c0d28395389132b7",
|
||||
"bytes": 26259
|
||||
},
|
||||
{
|
||||
"timestamp_s": 10.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-010.00.png",
|
||||
"sha256": "bdf01683fab23e1e98099d0f6e19596eabcd96ddb1c643b3d0c6749b5f2995a9",
|
||||
"bytes": 288771
|
||||
},
|
||||
{
|
||||
"timestamp_s": 11.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-011.00.png",
|
||||
"sha256": "c1abe47a8bd0e10472b75a472cea78ff24613c64ccc74ffba9b566d71336c4f4",
|
||||
"bytes": 290263
|
||||
},
|
||||
{
|
||||
"timestamp_s": 12.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-012.00.png",
|
||||
"sha256": "5833475f37ad6ccc7f98c953193368b11c4f3390d1633e224b0a43514c7aa2ec",
|
||||
"bytes": 23585
|
||||
},
|
||||
{
|
||||
"timestamp_s": 13.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-013.00.png",
|
||||
"sha256": "f14dca5370861a1b1f1ee95d1e00172314f27e60ec9f3451a16e08efb46cabf4",
|
||||
"bytes": 24310
|
||||
},
|
||||
{
|
||||
"timestamp_s": 14.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-014.00.png",
|
||||
"sha256": "ab5ed49e0a1267d80e53bc524db96a521aedf419d4a2e766463bd58fc2cbd96a",
|
||||
"bytes": 290328
|
||||
},
|
||||
{
|
||||
"timestamp_s": 15.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-015.00.png",
|
||||
"sha256": "101c7a220045bdad559ffabcf2345a307c4b2a8ace71c1f289f861cb5ac8dfcf",
|
||||
"bytes": 337454
|
||||
},
|
||||
{
|
||||
"timestamp_s": 16.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-016.00.png",
|
||||
"sha256": "6b674c7689ae86485ce112daa9a14cbd4334d3c41cbc12bcc8a06b0c34c3d0bd",
|
||||
"bytes": 118937
|
||||
},
|
||||
{
|
||||
"timestamp_s": 17.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-017.00.png",
|
||||
"sha256": "44134f20bffcd9fb57c3ca421a7be03fa2596962423a955140bf44e3d5c2582b",
|
||||
"bytes": 24201
|
||||
},
|
||||
{
|
||||
"timestamp_s": 18.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-018.00.png",
|
||||
"sha256": "bf44d8b974343063293c92d2933edd0e9a711802d44753f5c0c8b4f4cf3406aa",
|
||||
"bytes": 25412
|
||||
},
|
||||
{
|
||||
"timestamp_s": 19.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-019.00.png",
|
||||
"sha256": "7d2fdecd1cff9d025880e069d111c9e8aa0c488dd1e570b62f5147a136543271",
|
||||
"bytes": 78776
|
||||
},
|
||||
{
|
||||
"timestamp_s": 20.0,
|
||||
"path": "/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/frames/fine/frame-020.00.png",
|
||||
"sha256": "713c2f7a5db41b01640dbae71ef4d5057c382dd1480d9e31bcc3f6d05c9da52b",
|
||||
"bytes": 183618
|
||||
}
|
||||
],
|
||||
"fine_result": {
|
||||
"start": 9.0,
|
||||
"end": 11.0,
|
||||
"reason": "Continuous shot of large white rabbit in sunny green meadow between 'ONE BIG RABBIT' title (ends at 8.00s) and 'THREE RODENTS' title (starts at 12.00s), visible in 10.00s and 11.00s samples."
|
||||
},
|
||||
"ground_truth": {
|
||||
"start": 9.08,
|
||||
"end": 11.2
|
||||
},
|
||||
"start_error_s": 0.08,
|
||||
"end_error_s": 0.2
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import bpy
|
||||
|
||||
# Clear default objects
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.object.delete()
|
||||
|
||||
# Set up scene and sequence editor
|
||||
scene = bpy.context.scene
|
||||
scene.sequence_editor = scene.sequence_editor_create()
|
||||
se = scene.sequence_editor
|
||||
|
||||
# File paths
|
||||
input_path = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/source.mov'
|
||||
output_path = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/negative_control.mp4'
|
||||
|
||||
# Video parameters
|
||||
source_fps = 25
|
||||
trim_start_sec = 0.0
|
||||
trim_end_sec = 3.0
|
||||
trim_duration_sec = trim_end_sec - trim_start_sec
|
||||
trim_duration_frames = int(trim_duration_sec * source_fps) # 75 frames
|
||||
output_duration_sec = trim_duration_sec * 1.5 # 4.5 seconds
|
||||
output_duration_frames = int(output_duration_sec * source_fps) # 113 frames (rounded up from 112.5)
|
||||
|
||||
speed_factor = trim_duration_sec / output_duration_sec # 0.666...
|
||||
|
||||
# Add video strip
|
||||
video_strip = se.sequences.new_movie(
|
||||
name='Video',
|
||||
filepath=input_path,
|
||||
channel=2,
|
||||
frame_start=1
|
||||
)
|
||||
video_strip.frame_offset_start = 0 # Start at 0s of source
|
||||
video_strip.frame_final_duration = trim_duration_frames # Trim to 3 seconds
|
||||
|
||||
# Add audio strip
|
||||
audio_strip = se.sequences.new_sound(
|
||||
name='Audio',
|
||||
filepath=input_path,
|
||||
channel=1,
|
||||
frame_start=1
|
||||
)
|
||||
audio_strip.frame_offset_start = 0
|
||||
audio_strip.frame_final_duration = trim_duration_frames
|
||||
|
||||
# Add speed effect to video
|
||||
speed_video = se.sequences.new_effect(
|
||||
name='Speed_Video',
|
||||
type='SPEED',
|
||||
channel=3,
|
||||
frame_start=1,
|
||||
seq1=video_strip
|
||||
)
|
||||
speed_video.speed_factor = speed_factor
|
||||
speed_video.frame_final_duration = output_duration_frames
|
||||
|
||||
# Add speed effect to audio
|
||||
speed_audio = se.sequences.new_effect(
|
||||
name='Speed_Audio',
|
||||
type='SPEED',
|
||||
channel=2,
|
||||
frame_start=1,
|
||||
seq1=audio_strip
|
||||
)
|
||||
speed_audio.speed_factor = speed_factor
|
||||
speed_audio.frame_final_duration = output_duration_frames
|
||||
|
||||
# Add subtitle text strip
|
||||
text_strip = se.sequences.new_effect(
|
||||
name='Subtitle',
|
||||
type='TEXT',
|
||||
channel=4,
|
||||
frame_start=1,
|
||||
frame_end=1 + output_duration_frames - 1
|
||||
)
|
||||
text_strip.text = 'BIG BUNNY'
|
||||
text_strip.align_x = 'CENTER'
|
||||
text_strip.align_y = 'BOTTOM'
|
||||
text_strip.font_size = 48
|
||||
text_strip.color = (1.0, 1.0, 1.0, 1.0) # White text
|
||||
|
||||
# Subtitle background box
|
||||
text_strip.use_box = True
|
||||
text_strip.box_color = (0.0, 0.0, 0.0, 0.5) # Semi-transparent black
|
||||
text_strip.box_margin_left = 10
|
||||
text_strip.box_margin_right = 10
|
||||
text_strip.box_margin_top = 10
|
||||
text_strip.box_margin_bottom = 10
|
||||
|
||||
# Render settings
|
||||
scene.render.resolution_x = 854
|
||||
scene.render.resolution_y = 480
|
||||
scene.render.resolution_percentage = 100
|
||||
scene.render.fps = source_fps
|
||||
scene.render.fps_base = 1.0
|
||||
|
||||
# Output format settings
|
||||
scene.render.image_settings.file_format = 'MPEG4'
|
||||
scene.render.ffmpeg.format = 'MPEG4'
|
||||
scene.render.ffmpeg.codec = 'H.264'
|
||||
scene.render.ffmpeg.audio_codec = 'AAC'
|
||||
scene.render.ffmpeg.audio_bitrate = 192
|
||||
scene.render.ffmpeg.constant_rate_factor = 'MEDIUM'
|
||||
scene.render.filepath = output_path
|
||||
|
||||
# Set scene frame range
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = output_duration_frames
|
||||
|
||||
# Render animation
|
||||
bpy.ops.render.render(animation=True)
|
||||
@@ -0,0 +1,90 @@
|
||||
import bpy
|
||||
import math
|
||||
|
||||
# Clear default objects
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.object.delete()
|
||||
|
||||
# Set up scene
|
||||
scene = bpy.context.scene
|
||||
|
||||
# Render settings
|
||||
scene.render.resolution_x = 854
|
||||
scene.render.resolution_y = 480
|
||||
scene.render.resolution_percentage = 100
|
||||
scene.render.fps = 25
|
||||
scene.render.fps_base = 1.0
|
||||
scene.render.image_settings.file_format = 'MPEG4'
|
||||
scene.render.ffmpeg.codec = 'H264'
|
||||
scene.render.ffmpeg.audio_codec = 'AAC'
|
||||
scene.render.filepath = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/negative_control.mp4'
|
||||
|
||||
# Set up Video Sequence Editor
|
||||
if not scene.sequence_editor:
|
||||
scene.sequence_editor_create()
|
||||
scene.sequence_editor.sequences.clear()
|
||||
|
||||
# Import source movie
|
||||
input_path = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/source.mov'
|
||||
movie_strip = scene.sequence_editor.sequences.new_movie(
|
||||
name='Source',
|
||||
filepath=input_path,
|
||||
channel=1,
|
||||
frame_start=1
|
||||
)
|
||||
# Trim to 3 seconds (75 frames at 25fps)
|
||||
movie_strip.frame_final_duration = 75
|
||||
|
||||
# Add speed effect (1.5x duration = 2/3 speed)
|
||||
speed_strip = scene.sequence_editor.sequences.new_effect(
|
||||
name='Slow',
|
||||
type='SPEED',
|
||||
channel=2,
|
||||
frame_start=1,
|
||||
frame_end=movie_strip.frame_final_end,
|
||||
seq1=movie_strip
|
||||
)
|
||||
speed_strip.speed_factor = 2/3 # 3s * 1.5 = 4.5s duration
|
||||
|
||||
# Calculate scene frame range
|
||||
slowed_frames = movie_strip.frame_final_duration / speed_strip.speed_factor
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = math.ceil(scene.frame_start + slowed_frames - 1)
|
||||
|
||||
# Create sequence editor if not exists
|
||||
if not scene.sequence_editor:
|
||||
scene.sequence_editor_create()
|
||||
|
||||
# Subtitle background (semi-transparent dark box)
|
||||
color_strip = scene.sequence_editor.sequences.new_effect(
|
||||
name='SubtitleBG',
|
||||
type='COLOR',
|
||||
channel=3,
|
||||
frame_start=scene.frame_start,
|
||||
frame_end=scene.frame_end
|
||||
)
|
||||
color_strip.color = (0.0, 0.0, 0.0) # Black
|
||||
color_strip.alpha = 0.5 # Semi-transparent
|
||||
color_strip.transform.scale_x = 0.4 # Box width
|
||||
color_strip.transform.scale_y = 0.15 # Box height
|
||||
color_strip.transform.translate_y = -0.4 # Bottom position
|
||||
color_strip.transform.align_x = 'CENTER' # Center horizontally
|
||||
|
||||
# Subtitle text
|
||||
text_strip = scene.sequence_editor.sequences.new_effect(
|
||||
name='SubtitleText',
|
||||
type='TEXT',
|
||||
channel=4,
|
||||
frame_start=scene.frame_start,
|
||||
frame_end=scene.frame_end
|
||||
)
|
||||
text_strip.text = 'BIG BUNNY'
|
||||
text_strip.align_x = 'CENTER'
|
||||
text_strip.align_y = 'CENTER'
|
||||
text_strip.font_size = 40
|
||||
text_strip.color = (1.0, 1.0, 1.0) # White text
|
||||
text_strip.transform.translate_y = -0.4 # Match background Y position
|
||||
text_strip.transform.align_x = 'CENTER'
|
||||
|
||||
# Render animation
|
||||
bpy.ops.render.render(animation=True)
|
||||
@@ -0,0 +1,73 @@
|
||||
import bpy
|
||||
|
||||
# Clear existing data to start fresh
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
|
||||
# Get the current scene
|
||||
scene = bpy.context.scene
|
||||
|
||||
# Set render resolution and FPS
|
||||
scene.render.resolution_x = 854
|
||||
scene.render.resolution_y = 480
|
||||
scene.render.resolution_percentage = 100
|
||||
scene.render.fps = 25
|
||||
scene.render.fps_base = 1.0
|
||||
|
||||
# Set render output settings
|
||||
scene.render.image_settings.file_format = 'FFMPEG'
|
||||
scene.render.ffmpeg.format = 'MPEG4'
|
||||
scene.render.ffmpeg.codec = 'H264'
|
||||
scene.render.ffmpeg.audio_codec = 'AAC'
|
||||
scene.render.ffmpeg.constant_rate_factor = 'MEDIUM'
|
||||
scene.render.filepath = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/negative_control.mp4'
|
||||
|
||||
# Create sequence editor
|
||||
scene.sequence_editor_create()
|
||||
seq_ed = scene.sequence_editor
|
||||
|
||||
# Input movie path
|
||||
input_movie = '/Users/boj/book/ai-agent-book/chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-050817/source.mov'
|
||||
|
||||
# Add video strip with trim (0.000-3.000s = 0-75 frames at 25fps)
|
||||
video_strip = seq_ed.sequences.new_movie(name='Video', filepath=input_movie, channel=1, frame_start=0)
|
||||
video_strip.frame_offset_start = 0 # Start at source frame 0
|
||||
video_strip.frame_final_duration = 75 # 3s * 25fps = 75 frames
|
||||
|
||||
# Add speed effect to slow down (1.5x duration: 3s → 4.5s = 112.5 frames → 113 frames)
|
||||
speed_effect = seq_ed.sequences.new_effect(name='Speed', type='SPEED', channel=2, frame_start=0, frame_end=113, seq1=video_strip)
|
||||
speed_effect.speed_factor = 2/3 # Slows to 1.5x original duration
|
||||
|
||||
# Add audio strip from movie
|
||||
audio_strip = seq_ed.sequences.new_sound(name='Audio', filepath=input_movie, channel=1, frame_start=0)
|
||||
audio_strip.frame_offset_start = 0 # Match video trim start
|
||||
audio_strip.frame_final_duration = 75 # Match video trim duration
|
||||
|
||||
# Add speed effect to audio
|
||||
audio_speed = seq_ed.sequences.new_effect(name='AudioSpeed', type='SPEED', channel=2, frame_start=0, frame_end=113, seq1=audio_strip)
|
||||
audio_speed.speed_factor = 2/3
|
||||
audio_speed.use_audio = True
|
||||
|
||||
# Create subtitle background (semi-transparent dark box)
|
||||
bg_strip = seq_ed.sequences.new_effect(name='SubtitleBG', type='COLOR', channel=3, frame_start=0, frame_end=113)
|
||||
bg_strip.color = (0.1, 0.1, 0.1, 0.7) # Dark gray with 70% transparency
|
||||
bg_strip.align_x = 'CENTER'
|
||||
bg_strip.align_y = 'BOTTOM'
|
||||
bg_strip.transform.scale_x = 0.5 # Width of background box
|
||||
bg_strip.transform.scale_y = 0.15 # Height of background box
|
||||
bg_strip.transform.location_y = 0.03 # Position slightly above bottom edge
|
||||
|
||||
# Create subtitle text
|
||||
text_strip = seq_ed.sequences.new_effect(name='SubtitleText', type='TEXT', channel=4, frame_start=0, frame_end=113)
|
||||
text_strip.text = 'BIG BUNNY'
|
||||
text_strip.align_x = 'CENTER'
|
||||
text_strip.align_y = 'BOTTOM'
|
||||
text_strip.font_size = 48
|
||||
text_strip.color = (1.0, 1.0, 1.0) # White text
|
||||
text_strip.transform.location_y = 0.05 # Align with background box
|
||||
|
||||
# Set scene frame range to cover slowed duration (4.5 seconds = 112.5 frames → 113 frames)
|
||||
scene.frame_start = 0
|
||||
scene.frame_end = 113
|
||||
|
||||
# Render the animation
|
||||
bpy.ops.render.render(animation=True)
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"url": "https://download.blender.org/peach/trailer/trailer_480p.mov",
|
||||
"title": "Big Buck Bunny trailer (Blender Foundation Peach Open Movie Project)",
|
||||
"license": "Creative Commons Attribution 3.0",
|
||||
"license_url": "https://creativecommons.org/licenses/by/3.0/",
|
||||
"sha256": "36801b74638c12be9aa587e93cd18edfc9bc51a1c089ab2a19ee42beed9f497d",
|
||||
"probe": {
|
||||
"programs": [],
|
||||
"stream_groups": [],
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "h264",
|
||||
"codec_type": "video",
|
||||
"width": 853,
|
||||
"height": 480,
|
||||
"r_frame_rate": "25/1"
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"codec_name": "aac",
|
||||
"codec_type": "audio",
|
||||
"sample_rate": "48000",
|
||||
"channels": 6,
|
||||
"r_frame_rate": "0/0"
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
|
||||
"duration": "32.995000",
|
||||
"size": "11061011"
|
||||
}
|
||||
},
|
||||
"naturally_occurring_scenes": true,
|
||||
"ground_truth": {
|
||||
"start": 9.08,
|
||||
"end": 11.2,
|
||||
"target": "the single continuous shot showing the large white rabbit walking alone in a sunny green meadow, after the ONE BIG RABBIT title and before the THREE RODENTS title",
|
||||
"method": "Human-labeled target shot bounded by ffmpeg scene-change frames; source inspection found transitions at 9.08 and 11.20 seconds.",
|
||||
"ffmpeg_scene_threshold": 0.35
|
||||
}
|
||||
}
|
||||