Say I have multiple videos sorted out in a list that I'll call "sub_videos" based on its video length:
# sub_videos ____________________________________________________________________________________
ten_second_or_below_videos = [ten_sec_video1, ten_sec_video2, ...]
twenty_second_or_below_videos = [twenty_sec_video10, twenty_sec_video12, ...]
thirty_second_or_below_videos = [thirty_sec_video10, thirty_sec_video12, ...]
forty_second_or_below_videos = [forty_sec_video15, forty_sec_video17, ...]
fifty_second_or_below_videos = [fifty_sec_video13, fifty_sec_video14, ...]
sixty_or_more_second_videos = [sixty_sec_video100, sixty_sec_video101, ...]
# ^^^^^^^^^^^^^ everything above this will be called "sub_videos" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ten_second_or_below_videos variable contains a list of videos that are 10 seconds or less long, the twenty_second_or_below_videos has a list that contains videos that are 20 seconds or less long, but not below or equal 10 seconds, the thirty_second_or_below_videos contains videos that are 30 seconds or less long, but not below or equal 20 seconds and so on...
And say I have another list of videos that have varying video lengths but are unsorted, which I'll call "main_videos":
main_videos = [ten_second_video1, twenty_second_video2, ten_second_video2, ...]
I want to be able to splice together one of the videos in "main_videos" with any of the videos on "sub_videos" with moviepy
, but the final output should be just below or equal a desired time limit, which for my case; is 60 seconds. I have no clue on how to do it, so please help. The output should look like this somehow:
FINAL_OUTPUT = [ten_second_main_video, ten_second_sub_video,ten_second_sub_video,
ten_second_sub_video, ten_second_sub_video, ten_second_sub_video]
or
FINAL_OUTPUT = [EXACTLY_twenty_second_main_video, EXACTLY_twenty_second_sub_video, EXACTLY_twenty_second_sub_video]
# the capitalized EXACTLY is used to indicate that the video is exactly twenty second
or
FINAL_OUTPUT = [ten_second_main_video, EXACTLY_thirty_second_sub_video,
ten_second_sub_video, EXACTLY_ten_second_sub_video]
etc...
concatenate_videoclips(FINAL_OUTPUT).write_videofile('video.mp4') # the saved file should be just below or equal 60 seconds