Skip to content

Video Merger #1099

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AutomationScripts/Video_Merger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Video Merger
## How it Works:-
This script is useful to merge small videos (mp4 only) into a single video. Here you have to enter the full path of where the videos are located and the script displayes the all the mp4 videos and starts merging them. Also you have to specify which location you want the video to be in.
## Author:-
Ambush Neupane
17 changes: 17 additions & 0 deletions AutomationScripts/Video_Merger/listvideos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#this script returns the list of videos (.mp4) from the path you choose.
import os
pathOfVideo=input("Enter the full path where videos are located.")

def array_Of_Videos():
fileExists= os.path.exists(pathOfVideo) #returns a boolen

if fileExists:
dirList= sorted(os.listdir(pathOfVideo)) #returns list of files inside the path
return [files for files in dirList if files.endswith(".mp4") ]

else:
print(f"No such path as {pathOfVideo}")

videoslist= array_Of_Videos()
print(f'If the sequence of the videos doesn\'t look like Following. You can press Control + C to kill the program.\n{videoslist}')
7 changes: 7 additions & 0 deletions AutomationScripts/Video_Merger/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from renderVideo import renderFinalVideo

def main():
renderFinalVideo()

if __name__ == '__main__':
main()
20 changes: 20 additions & 0 deletions AutomationScripts/Video_Merger/renderVideo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from moviepy.editor import VideoFileClip,concatenate_videoclips
from listvideos import videoslist,pathOfVideo
import os


def renderFinalVideo():
videoNames=[VideoFileClip(os.path.join(pathOfVideo, video)) for video in videoslist]
final_video = concatenate_videoclips(videoNames,method='compose')
filePath= input("Enter location to save file:-")
filePathExists= os.path.exists(filePath)
if filePathExists:
fileName= input("Enter file name;-")

if fileName.endswith(".mp4"):
final_video.write_videofile(os.path.join(filePath,fileName))
else:
print("Sorry the extension must be .mp4")

else:
print(f"Sorry Error Occured!!!Make sure this path exists:- {filePath}")
2 changes: 2 additions & 0 deletions AutomationScripts/Video_Merger/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Libraries used: moviepy, os