-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalpha.py
41 lines (26 loc) · 1.05 KB
/
alpha.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import cv2
import moviepy.editor as mpe
lowerThird = "video/lt2.mov"
videoFile = "video/high-winds-trouble-fire-fighters.mp4"
outputFile = "alpha.mp4"
''' ***** ***** ***** ***** ***** ***** *****
Write VDO with Alpha Lower Third - Start
***** ***** ***** ***** ***** ***** ***** '''
def vdo_with_alpha(lowerThird, videoFile, outputFile):
tmpVid = cv2.VideoCapture(videoFile)
framespersecond = float(tmpVid.get(cv2.CAP_PROP_FPS))
video_clip = mpe.VideoFileClip(videoFile, target_resolution=(1080, 1920))
overlay_clip = mpe.VideoFileClip(lowerThird, has_mask=True, target_resolution=(1080, 1920))
final_video = mpe.CompositeVideoClip([video_clip, overlay_clip])
final_video.write_videofile(
outputFile,
fps=framespersecond,
remove_temp=True,
codec="libx264",
audio_codec="aac",
threads=6
)
''' ***** ***** ***** ***** ***** ***** *****
Write VDO with Alpha Lower Third - End
***** ***** ***** ***** ***** ***** ***** '''
vdo_with_alpha(lowerThird, videoFile, outputFile)