import cv2
def white_circle(img,radius):
cv2.circle(img,(447,63),63,(0,0,255),-1)
org_video = "../data/LawerCrush.mp4"
sub_video = "../data/LawerCrush_subtitles1.mp4"
Video = cv2.VideoCapture(org_video)
Fps_video = Video.get(cv2.CAP_PROP_FPS)
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
frame_width = int(Video.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(Video.get(cv2.CAP_PROP_FRAME_HEIGHT))
videoWriter = cv2.VideoWriter(sub_video, fourcc, Fps_video, (frame_width, frame_height))
glare_time = int(Fps_video*5)-1
glare_count = 0
frame_id = 0
w_index = 0
putword = ['He is a down-and-out lawyer','God gave him another surprise',' ']
cc_x = int(frame_width/2)
cc_y = int(frame_height/2)
while (Video.isOpened()):
ret, frame = Video.read()
if ret == True:
frame_id += 1
time_s = int(frame_id/Fps_video)
if(time_s<6):
w_index = 0
elif(time_s<16):
w_index = 1
else:
w_index =2
if 20<time_s <= 25 :
glare_count += 1
elif 25< time_s <=30:
glare_count -= 1
cv2.circle(frame,(cc_x,cc_y),int((cc_y/glare_time)*glare_count),(255,255,255),-1)
word_x = 450
word_y = int(frame_height)-18
cv2.putText(frame, '%s' %putword[w_index], (word_x, word_y), cv2.FONT_HERSHEY_SIMPLEX, 2, (255,255,255), 2)
videoWriter.write(frame)
else:
videoWriter.release()
break