Skip to content

Automatically merges a set of audio files and video files into an unique mp4 video with faded transitions.

License

Notifications You must be signed in to change notification settings

tngaspar/automerge-video-audio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automerge Video & Audio

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).

Merging video files

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.

Requirements

  • MoviePy - python module used for programmatic video editing.

Installation

  1. Clone the repository:
$ git clone https://github.com/tngaspar/automerge-video-audio.git
  1. Install dependencies:
$ pip install -r requirements.txt

(Optional) - install dependencies in a virtual environment.

Execution

  1. (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.
  1. Drop your .mp3 audio files into the audio/ directory and your .mp4 video files into the video/ directory.
video/
├── ...
├── sample-video1.mp4
├── sample-video2.mp4
└── sample-video3.mp4
audio/
├── ...
├── sample-audio1.mp3
└── sample-audio2.mp3
  1. 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]
  1. After the execution is finished, you should find the final output .mp4 file on the output/ directory.

Examples:

https://www.youtube.com/watch?v=yEbXGs8g9PI

Alt text

https://www.youtube.com/watch?v=OZPk7gKwtak

Alt text

(back to top)

About

Automatically merges a set of audio files and video files into an unique mp4 video with faded transitions.

Topics

Resources

License

Stars

Watchers

Forks

Languages