File tree Expand file tree Collapse file tree 5 files changed +51
-0
lines changed
AutomationScripts/Video_Merger Expand file tree Collapse file tree 5 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Video Merger
2
+ ## How it Works:-
3
+ 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.
4
+ ## Author:-
5
+ Ambush Neupane
Original file line number Diff line number Diff line change
1
+
2
+ #this script returns the list of videos (.mp4) from the path you choose.
3
+ import os
4
+ pathOfVideo = input ("Enter the full path where videos are located." )
5
+
6
+ def array_Of_Videos ():
7
+ fileExists = os .path .exists (pathOfVideo ) #returns a boolen
8
+
9
+ if fileExists :
10
+ dirList = sorted (os .listdir (pathOfVideo )) #returns list of files inside the path
11
+ return [files for files in dirList if files .endswith (".mp4" ) ]
12
+
13
+ else :
14
+ print (f"No such path as { pathOfVideo } " )
15
+
16
+ videoslist = array_Of_Videos ()
17
+ print (f'If the sequence of the videos doesn\' t look like Following. You can press Control + C to kill the program.\n { videoslist } ' )
Original file line number Diff line number Diff line change
1
+ from renderVideo import renderFinalVideo
2
+
3
+ def main ():
4
+ renderFinalVideo ()
5
+
6
+ if __name__ == '__main__' :
7
+ main ()
Original file line number Diff line number Diff line change
1
+ from moviepy .editor import VideoFileClip ,concatenate_videoclips
2
+ from listvideos import videoslist ,pathOfVideo
3
+ import os
4
+
5
+
6
+ def renderFinalVideo ():
7
+ videoNames = [VideoFileClip (os .path .join (pathOfVideo , video )) for video in videoslist ]
8
+ final_video = concatenate_videoclips (videoNames ,method = 'compose' )
9
+ filePath = input ("Enter location to save file:-" )
10
+ filePathExists = os .path .exists (filePath )
11
+ if filePathExists :
12
+ fileName = input ("Enter file name;-" )
13
+
14
+ if fileName .endswith (".mp4" ):
15
+ final_video .write_videofile (os .path .join (filePath ,fileName ))
16
+ else :
17
+ print ("Sorry the extension must be .mp4" )
18
+
19
+ else :
20
+ print (f"Sorry Error Occured!!!Make sure this path exists:- { filePath } " )
Original file line number Diff line number Diff line change
1
+ Libraries used: moviepy, os
2
+
You can’t perform that action at this time.
0 commit comments