Skip to content

Commit

Permalink
fix bug video not saved if add audio not enabled (FujiwaraChoki#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
neker97 authored Feb 11, 2024
1 parent 0bd5101 commit c5a59f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ def generate():
except HttpError as e:
print(f"An HTTP error {e.resp.status} occurred:\n{e.content}")

video_clip = VideoFileClip(f"../temp/{final_video_path}")
if use_music:
# Select a random song
song_path = choose_random_song()

# Add song to video at 30% volume using moviepy
video_clip = VideoFileClip(f"../temp/{final_video_path}")
original_duration = video_clip.duration
original_audio = video_clip.audio
song_clip = AudioFileClip(song_path).set_fps(44100)
Expand All @@ -297,6 +297,8 @@ def generate():
video_clip = video_clip.set_fps(30)
video_clip = video_clip.set_duration(original_duration)
video_clip.write_videofile(f"../{final_video_path}", threads=n_threads or 1)
else:
video_clip.write_videofile(f"../{final_video_path}", threads=n_threads or 1)


# Let user know
Expand Down

0 comments on commit c5a59f2

Please sign in to comment.