Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MoviePy CrossFadeIn and CrossFadeOut only displayed as black box #2308

Closed
gerritlo opened this issue Jan 1, 2025 · 4 comments
Closed

MoviePy CrossFadeIn and CrossFadeOut only displayed as black box #2308

gerritlo opened this issue Jan 1, 2025 · 4 comments
Labels
bug Issues that report (apparent) bugs.

Comments

@gerritlo
Copy link

gerritlo commented Jan 1, 2025

I'm using Moviepy2 to render a video based on images. There is one image that should be the background image the whole video. Multiple images should be faded in, showed for a few seconds and faded out again sequentially.

My code generates the video but the foreground_clip is not faded in and out. During the fading I only see a black box.

def create_video(background_image_path, foreground_images_folder, output_video_path):
    # Load and resize the background image
    background_clip = ImageClip(background_image_path)
    print(background_clip)
    print(background_clip.size)
    background_clip = background_clip.resized(VIDEO_RESOLUTION).with_duration(IMAGE_DISPLAY_DURATION)

    # List all images in the foreground images folder
    foreground_images = [os.path.join(foreground_images_folder, img) for img in os.listdir(foreground_images_folder) if img.endswith(('png', 'jpg', 'jpeg'))]

    # Create video clips for each foreground image
    clips = []
    for img_path in foreground_images:
        print(f"Processing image: {img_path}")
        foreground_clip = ImageClip(img_path).resized(0.8).with_duration(IMAGE_DISPLAY_DURATION)
        foreground_clip = foreground_clip.with_position('center').with_effects([vfx.CrossFadeIn(1)]).with_effects([vfx.CrossFadeOut(1)])
        composite_clip = CompositeVideoClip([background_clip, foreground_clip])
        clips.append(composite_clip)
        #clips.append(foreground_clip)

    # Concatenate all clips
    final_clip = concatenate_videoclips(clips, method="compose")

    # Write the final video to a file
    final_clip.write_videofile(output_video_path, fps=24)

Expected Behavior

I would expect to see my background image and a fading in foreground image.

Actual Behavior

During the fade in and out time I see only a black box

Steps to Reproduce the Problem

Specifications

  • Python Version: 3.12.3
  • MoviePy Version: 2.1.1
  • Platform Name: Ubuntu
  • Platform Version: 24.04.1 LTS
@gerritlo gerritlo added the bug Issues that report (apparent) bugs. label Jan 1, 2025
@OsaAjani
Copy link
Collaborator

It seems I cannot reproduce the problem with your code, could you provide the resources (videos, images, etc.) you are using ? Also you might need to set use_bgclip = True in composite.

@OsaAjani
Copy link
Collaborator

@gerritlo any news ?

@OsaAjani
Copy link
Collaborator

Hi @gerritlo any update or should I close this one ?

@OsaAjani
Copy link
Collaborator

Cannot reproduce and no news, so I close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

2 participants