Automatically merges a set of music files and video files into an unique .mp4 video with faded transitions.
Overrides video files' audio with audio from audio files. Useful for creating music videos (examples at the end of this document).
This script is not intended to be used as a video merge tool (audio will always be overwritten). For this purpose, you may use this script instead.
- MoviePy - python module used for programmatic video editing.
- Clone the repository:
$ git clone https://github.com/tngaspar/automerge-video-audio.git
- Install dependencies:
$ pip install -r requirements.txt
(Optional) - install dependencies in a virtual environment.
- (Optional) Edit setup variables in the beginning of
main.py
according to your preferences. Alternatively, you can leave it as is and use the default settings.
# ### SETTINGS - Modify this to your preferences ###
video_speed = 1 # Speed for all videos. Leave as 1 for normal speed
video_fade_secs = 1 # Video fade in and out duration in seconds.
audio_fade_secs = 1 # Audio fade in and out duration in seconds.
audio_overlap_secs = 0 # Number of seconds between audio clips where both clips overlap. Leave as 0 for no overlap.
- Drop your
.mp3
audio files into theaudio/
directory and your.mp4
video files into thevideo/
directory.
video/
├── ...
├── sample-video1.mp4
├── sample-video2.mp4
└── sample-video3.mp4
audio/
├── ...
├── sample-audio1.mp3
└── sample-audio2.mp3
- Run the
main.py
script:
$ python main.py
and wait for the execution to complete.
You are able to see how long the execution will take to complete on the right side of the of the progress bar.
This 2 lengths should match:
Audio length: 16.04 seconds
Video length: 16.04 seconds
Moviepy - Building video output/final_21.11.18_01.08.2022.mp4.
MoviePy - Writing audio in final_21.11.18_01.08.2022TEMP_MPY_wvf_snd.mp3
MoviePy - Done.
Moviepy - Writing video output/final_21.11.18_01.08.2022.mp4
t: 70%|████████████████████████████ | 338/482 [00:36<00:08, 16.11it/s, now=None]
- After the execution is finished, you should find the final output .mp4 file on the
output/
directory.
https://www.youtube.com/watch?v=yEbXGs8g9PI