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

image corruption when concatenating images of different sizes #725

Closed
mattvenn opened this issue Feb 15, 2018 · 6 comments
Closed

image corruption when concatenating images of different sizes #725

mattvenn opened this issue Feb 15, 2018 · 6 comments

Comments

@mattvenn
Copy link

mattvenn commented Feb 15, 2018

If I have a portrait and a landscape image and try to make them into ImageClips and then concatenate them I get a corrupt frame for the second image.]

fps = 2
clips_with_text = []
files = [
  { 'type': 'img', 'p': 'IMG_20180215_115620141.jpg', 'd': dur_time, 't': "landscape" },                                                                                                                                      
  { 'type': 'img', 'p': 'IMG_20180215_115751222.jpg', 'd': dur_time, 't': "portrait" },     
]

for file in files:              
    video = ImageClip('./media/' + clip['p'], duration=clip['d']).set_fps(fps)
    txt_clip = TextClip(clip['t'], fontsize=140, color='white', bg_color='black', font='Liberation-Sans-Bold').set_position(("center", "bottom")).set_duration(video.duration)                                                                        
                                                                                                                                                                                                                                                          
    result = CompositeVideoClip([video, txt_clip]) # Overlay text on video                                                                                                                                                                            
                                                                                                                                                                                                                                                          
    clips_with_text.append(result)

final_clip = concatenate_videoclips(clips_with_text)
final_clip.write_videofile("final.mp4")
@tburrows13
Copy link
Collaborator

Try calling concatenate_videoclips with method=compose. That should centre the smaller videos with a black background. Alternatively, resize all the videos to the same size.

@mattvenn
Copy link
Author

Thanks, that stops the corruption.

@mattvenn
Copy link
Author

I'm not sure it should be closed though, I think there is a bug. If there are a set of video clips the same size and a set of images the same size it works as expected. With one image a different size, then it gets corrupted only on that image.

@intoro
Copy link

intoro commented Feb 22, 2018 via email

@tburrows13
Copy link
Collaborator

No, I think it is the expected behaviour. Maybe it should be better documented though, as it’s a very common issue. We could also raise a warning if it happens.

@Jeffiano
Copy link

concatenate(clip_list,method="compose") works for me , Thanks !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants