mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-01-31 05:33:44 +00:00
Merge pull request #302 from ambushneupane/VideoMerger
Added Video Merger
This commit is contained in:
commit
dff26209bb
25
scripts/Video_Merger/README.md
Normal file
25
scripts/Video_Merger/README.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
### Video Merger
|
||||
Simple script that combines many videos into a single Video.
|
||||
## How to use
|
||||
1) Clone the Repo
|
||||
2) Install Packages mentioned inside requirements.txt
|
||||
3) python main.py
|
||||
|
||||
## NOTE
|
||||
As of now you can only merge videos that have extension (.mp4)
|
||||
|
||||
# Author
|
||||
Ambush Neupane
|
||||
### Video Merger
|
||||
Simple script that combines many videos into a single Video.
|
||||
## How to use
|
||||
1) Clone the Repo
|
||||
2) Install Packages mentioned inside requirements.txt
|
||||
* ```pip install moviepy```
|
||||
3) python main.py
|
||||
|
||||
## NOTE
|
||||
As of now you can only merge videos that have extension (.mp4)
|
||||
|
||||
# Author
|
||||
Ambush Neupane
|
17
scripts/Video_Merger/listvideos.py
Normal file
17
scripts/Video_Merger/listvideos.py
Normal file
|
@ -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
scripts/Video_Merger/main.py
Normal file
7
scripts/Video_Merger/main.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from renderVideo import renderFinalVideo
|
||||
|
||||
def main():
|
||||
renderFinalVideo()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
20
scripts/Video_Merger/renderVideo.py
Normal file
20
scripts/Video_Merger/renderVideo.py
Normal file
|
@ -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
scripts/Video_Merger/requirements.txt
Normal file
2
scripts/Video_Merger/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
moviepy
|
||||
os
|
Loading…
Reference in New Issue
Block a user