Skip to content

Commit

Permalink
feat: loop music if longer than clip
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Jan 6, 2024
1 parent 67fcbb2 commit 60c16f5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions bereal/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,8 @@ def generate_all_clips() -> Generator[ImageSequenceClip, Any, None]:
if music_file is not None:
music = AudioFileClip(music_file)
if music.duration < final_clip.duration:
# TODO(michaelfromyeg): implement silence padding! (or maybe repeat clip...)
raise NotImplementedError("Music is shorter than final clip, not supported")

# silence_duration = final_clip.duration - music.duration
# silence = AudioSegment.silent(duration=silence_duration * 1000) # Duration in milliseconds
# music += silence # Concatenate silence and audio
logger.warning("Music is shorter than final clip; looping music")
music = music.fx(vfx.loop, duration=final_clip.duration)
else:
logger.info("Music is longer than final clip; clipping appropriately")
music = music.subclip(0, final_clip.duration)
Expand Down

0 comments on commit 60c16f5

Please sign in to comment.