|
@@ -40,7 +40,7 @@ dir_subtitle = 'subtitle/'
|
|
|
dir_anchor = 'anchor_raw/'
|
|
|
tmp_video_dir = 'tmp_video/'
|
|
|
video_sub_folder = 'ai_anchor_video/'
|
|
|
-
|
|
|
+mode ='run'
|
|
|
dir_list = [dir_sound,dir_photo,dir_text,dir_video,dir_title,dir_subtitle,dir_anchor,tmp_video_dir]
|
|
|
|
|
|
def notify_group(msg):
|
|
@@ -173,7 +173,6 @@ def file_prepare(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
|
|
|
#make title as image
|
|
|
txt2image_title(name, dir_title+name_hash+".png",lang)
|
|
|
|
|
|
-
|
|
|
def file_prepare_long(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
|
|
|
make_dir(name_hash)
|
|
|
img_num = 1
|
|
@@ -714,11 +713,11 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,multiLang,avatar):
|
|
|
print(multiLang)
|
|
|
file_prepare(name, name_hash, text_content,image_urls,multiLang)
|
|
|
sub_list=generate_subtitle_image(name_hash,text_content)
|
|
|
-
|
|
|
- for fname in range(len(text_content)):
|
|
|
- call_anchor(name_hash+"/"+str(fname),avatar)
|
|
|
- print('step finish')
|
|
|
- print('called............................................')
|
|
|
+ if mode!='test':
|
|
|
+ for fname in range(len(text_content)):
|
|
|
+ call_anchor(name_hash+"/"+str(fname),avatar)
|
|
|
+ print('step finish')
|
|
|
+ print('called............................................')
|
|
|
|
|
|
ck=cKey(0,254,0,270)
|
|
|
ck_anchor=cKey(0,255,1,320)
|
|
@@ -756,13 +755,20 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,multiLang,avatar):
|
|
|
|
|
|
idx = 0
|
|
|
for p in listdir(dir_photo+name_hash):
|
|
|
-
|
|
|
- anchor_list[idx] = openshot.FFmpegReader(dir_anchor+name_hash+"/"+str(idx)+".mp4")
|
|
|
- clip_duration = anchor_list[idx].info.duration
|
|
|
- anchor_list[idx].Open()
|
|
|
- anchor_clip_list[idx] = video_photo_clip(vid=anchor_list[idx],layer=4,scale_x=0.65,scale_y=0.65,
|
|
|
- location_x=0.35,location_y=0.25,position=main_timer, end=clip_duration,ck=ck_anchor,audio=False)
|
|
|
- t.AddClip(anchor_clip_list[idx])
|
|
|
+ audio_list[idx] = openshot.FFmpegReader(dir_sound+name_hash+"/"+str(idx)+".mp3")
|
|
|
+ audio_list[idx].Open()
|
|
|
+ clip_duration = audio_list[idx].info.duration
|
|
|
+ audio_clip_list[idx] = openshot.Clip(audio_list[idx])
|
|
|
+ audio_clip_list[idx].Position(main_timer)
|
|
|
+ audio_clip_list[idx].End(clip_duration)
|
|
|
+ t.AddClip(audio_clip_list[idx])
|
|
|
+ if mode != 'test':
|
|
|
+ anchor_list[idx] = openshot.FFmpegReader(dir_anchor+name_hash+"/"+str(idx)+".mp4")
|
|
|
+ #clip_duration = anchor_list[idx].info.duration
|
|
|
+ #anchor_list[idx].Open()
|
|
|
+ #anchor_clip_list[idx] = video_photo_clip(vid=anchor_list[idx],layer=4,scale_x=0.65,scale_y=0.65,
|
|
|
+ # location_x=0.35,location_y=0.25,position=main_timer, end=clip_duration,ck=ck_anchor,audio=False)
|
|
|
+ # t.AddClip(anchor_clip_list[idx])
|
|
|
|
|
|
img_list[idx] = openshot.FFmpegReader(dir_photo+name_hash+'/'+p)
|
|
|
img_list[idx].Open()
|
|
@@ -771,15 +777,11 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,multiLang,avatar):
|
|
|
t.AddClip(photo_clip_list[idx])
|
|
|
img_list[idx].Close()
|
|
|
|
|
|
- audio_list[idx] = openshot.FFmpegReader(dir_sound+name_hash+"/"+str(idx)+".mp3")
|
|
|
- audio_list[idx].Open()
|
|
|
- audio_clip_list[idx] = openshot.Clip(audio_list[idx])
|
|
|
- audio_clip_list[idx].Position(main_timer)
|
|
|
- audio_clip_list[idx].End(clip_duration)
|
|
|
- t.AddClip(audio_clip_list[idx])
|
|
|
+
|
|
|
|
|
|
img_list[idx].Close()
|
|
|
- anchor_list[idx].Close()
|
|
|
+ if mode != 'test':
|
|
|
+ anchor_list[idx].Close()
|
|
|
audio_list[idx].Close()
|
|
|
|
|
|
sub_img_list[idx] = [None] * len(sub_list[idx])
|
|
@@ -835,7 +837,10 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,multiLang,avatar):
|
|
|
t.AddClip(title_clip)
|
|
|
|
|
|
####start building
|
|
|
- w = openshot.FFmpegWriter(tmp_video_dir+name_hash+".mp4")
|
|
|
+ if mode == 'test':
|
|
|
+ w = openshot.FFmpegWriter("./out.mp4")
|
|
|
+ else:
|
|
|
+ w = openshot.FFmpegWriter(tmp_video_dir+name_hash+".mp4")
|
|
|
w.SetAudioOptions(True, "aac", 44100, 2, openshot.LAYOUT_STEREO, 3000000)
|
|
|
w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720,
|
|
|
openshot.Fraction(1, 1), False, False, 3000000)
|