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

How can I add background music to a video? #94

Open
alexdo83 opened this issue Nov 3, 2023 · 5 comments
Open

How can I add background music to a video? #94

alexdo83 opened this issue Nov 3, 2023 · 5 comments

Comments

@alexdo83
Copy link

alexdo83 commented Nov 3, 2023

How can I add background music to a video?

@sebbourgeois
Copy link
Contributor

On my end, I have a "post-treatment" script that I use on every video generated, that adds copyright free music in the background.

@alexlaverty
Copy link
Owner

alexlaverty commented Nov 9, 2023

Have pushed some updates, pull the latest code and try these out :

Enable background music that will be randomly selected from the assets/music folder :

python app.py --enable-background-music

or specify a file to use as the background music

python app.py --background-music-path "E:\Music\Colter Wall - Cowpoke.mp3"

@sebbourgeois
Copy link
Contributor

@alexlaverty I started today trying that new feature.
First video generated, got an error :

Creating background music audio
2023-11-19 12:08:46 INFO     Randomly Selected Background Music : assets/music/Across the Savannah - Aaron Kenny.mp3
Traceback (most recent call last):
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 440, in <module>
    process_submissions(submissions)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 64, in process_submissions
    process_submission(submission)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 118, in process_submission
    vid.create(
  File "/home/sb/videos-creation/python-reddit-youtube-bot/video_generation/video.py", line 779, in create
    background_music_audio = background_music_audio.volumex(0).loop(-1, duration=v.duration)
AttributeError: 'AudioFileClip' object has no attribute 'loop'

@alexlaverty
Copy link
Owner

alexlaverty commented Nov 29, 2023

@sebbourgeois can you share the reddit url and the command you used to generate, will try to reproduce

@sebbourgeois
Copy link
Contributor

sebbourgeois commented Dec 2, 2023

@alexlaverty
python app.py --url https://www.reddit.com/r/AskReddit/comments/188rpps/what_is_the_grossest_hygiene_issue_you_overlooked/

In the settings,py :

...
enable_background_music = True
background_music_path = ""
background_music_volume = 0.1
music_directory = str(Path(assets_directory, "music"))
...

Just tried with this recent subreddit, same error :

...
2023-12-02 23:40:40 INFO     Created Audio File : assets/work_dir/188rpps/kbnzvzb.mp3
2023-12-02 23:40:40 INFO     Reached Maximum Video Length : 900
2023-12-02 23:40:40 INFO     Used 74/99 comments
2023-12-02 23:40:40 INFO     === Finished Processing Comments ===
2023-12-02 23:40:40 INFO     ===== Adding Background Clip =====
2023-12-02 23:40:40 INFO     Background : assets/backgrounds/NO COPYRIGHT MOTION GRAPHICS_ssfuvE-8dRk.mp4
Creating background music audio
2023-12-02 23:40:40 INFO     Randomly Selected Background Music : assets/music/Outlaw's Farewell (part I) - Reed Mathis.mp3
Traceback (most recent call last):
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 440, in <module>
    process_submissions(submissions)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 64, in process_submissions
    process_submission(submission)
  File "/home/sb/videos-creation/python-reddit-youtube-bot/app.py", line 118, in process_submission
    vid.create(
  File "/home/sb/videos-creation/python-reddit-youtube-bot/video_generation/video.py", line 779, in create
    background_music_audio = background_music_audio.volumex(0).loop(-1, duration=v.duration)
AttributeError: 'AudioFileClip' object has no attribute 'loop'

For the sake of testing, I've switched enable_background_music to False in the settings,py file and did a
python app.py --enable-background-music --url https://www.reddit.com/r/AskReddit/comments/188rpps/what_is_the_grossest_hygiene_issue_you_overlooked/

Same result.

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

3 participants