Skip to content

Commit 55d87e4

Browse files
committed
Switched to ✔ ffmpeg from ❌ moviepy
1 parent db779f8 commit 55d87e4

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

downloader.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
print("Wrong Input! Try Again!")
4848
sys.exit()
4949

50-
# for stream in streams:
51-
# stream.download(filename=f"{yt.title}.mp4", output_path=mediaPath)
52-
# print("Resolution_code : MP4 Downloaded.✔")
53-
54-
55-
5650
# print("-------AUDIOS-------")
5751
for stream in yt.streams.filter(only_audio=True, abr="128kbps"):
5852
stream.download(filename=f"{yt.title}.mp3", output_path=mediaPath)
@@ -63,7 +57,7 @@
6357
videoFileName = f"{yt.title}_{videoID}"
6458

6559
# Merge the Audio & Video File
66-
vidmerge.merge(title=f"{yt.title}", outVidTitle=f"{videoFileName}_{videoID}")
60+
vidmerge.merge(title=f"{yt.title}", outVidTitle=videoFileName)
6761

6862
# Remove Seperate Media Files
6963
os.remove(f"{mediaPath}/{yt.title}.mp4")
@@ -77,3 +71,4 @@
7771

7872

7973

74+

modules/vidmerge.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11

22
import os
3-
from moviepy.editor import VideoFileClip, AudioFileClip
3+
# from moviepy.editor import VideoFileClip, AudioFileClip
4+
import ffmpeg
45

56
def merge(title, outVidTitle):
67

78
input_video = os.path.join(os.getcwd(), "vids",f"{title}.mp4")
89
input_audio = os.path.join(os.getcwd(), "vids",f"{title}.mp3")
910

10-
# Load the video and audio clips
11-
video_clip = VideoFileClip(input_video)
12-
audio_clip = AudioFileClip(input_audio)
11+
f_vid = ffmpeg.input(input_video)
12+
f_aud = ffmpeg.input(input_audio)
1313

14-
# Combine them
15-
final_clip = video_clip.set_audio(audio_clip)
14+
ffmpeg.concat(f_vid, f_aud, v=1, a=1).output(f"vids/{outVidTitle}.mp4").run()
1615

17-
# Write the final clip to a new file
18-
final_clip.write_videofile(f"vids/{outVidTitle}.mp4", codec="libx264")
1916

2017

2118

0 commit comments

Comments
 (0)