Skip to content

How to get a scene with a movie? #45

@eyildiz-ugoe

Description

@eyildiz-ugoe

Hi, I have the following (from the tutorial):

from vapory import *
from moviepy.editor import VideoFileClip
from moviepy.video.io.ffmpeg_writer import ffmpeg_write_image

# set the light source, background and surface
light = LightSource([10, 15, -20], [1.3, 1.3, 1.3])

# synthetic objects to be displayed
sphere1 = Sphere([0, 0, 0], 2.0, Pigment('color', [0, 0, 1]),
                                           Finish('phong', 0.8))
sphere2 =Sphere([-3, 0, 0], 1.0, Texture('T_Ruby_Glass'),
                Interior('ior',2))

# scene description
scene = Scene( Camera("location", [0, 0, -10], "look_at", [0, 0, 0]),
               objects = [sphere1, sphere2, light],
               included=["glass.inc"] )

# render command
scene.render("objects.png", width=800, height=480 )


# we would like to embed a video stream as a background in our scene
def embed_in_scene(image):

    ffmpeg_write_image("__temp__.png", image)
    screen = Box([0, 0, 0], [1, 1, 0], Texture(
                    Pigment( ImageMap('png', '"__temp__.png"', 'once')),),
                 'scale', [10, 10, 10])
    new_scene = scene.add_objects([screen])
    return new_scene.render(width=800, height=480, antialiasing=0.001)


clip = (VideoFileClip("scenes/dis1.mp4") # File containing the original video
        .subclip(0, 1) # cut between t=23 and 47 seconds
        .fl_image(embed_in_scene))  # <= The magic happens

clip.write_videofile("scenes/dis1-edited.mp4",bitrate='8000k')

However I don't get the video fullscreen in the background. I want the whole scene to be the video, added the objects at the locations specified.

How to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions