|
@@ -226,7 +226,7 @@ def file_prepare(name, name_hash,text_content,image_urls):
|
|
|
output.save(dir_sound+name_hash+".mp3")
|
|
|
print("mp3 file made")
|
|
|
#make title as image
|
|
|
- txt2image(name, dir_title+name_hash+".png")
|
|
|
+ txt2image(name, dir_title+name_hash+".png",'font.ttf',40)
|
|
|
|
|
|
def get_url_type(url):
|
|
|
req = urllib.request.Request(url, method='HEAD', headers={'User-Agent': 'Mozilla/5.0'})
|
|
@@ -296,11 +296,11 @@ def file_prepare_v2(name, name_hash,text_content,image_urls):
|
|
|
txt_idx+=1
|
|
|
print("mp3 file made")
|
|
|
#make title as image
|
|
|
- txt2image(name, dir_title+name_hash+".png")
|
|
|
+ txt2image(name, dir_title+name_hash+".png",'font.ttf',40)
|
|
|
|
|
|
-def txt2image(content, save_target):
|
|
|
+def txt2image(content, save_target,font,size):
|
|
|
unicode_text = content
|
|
|
- font = ImageFont.truetype("font.ttf", 40,encoding='big5')
|
|
|
+ font = ImageFont.truetype(font), size,encoding='big5')
|
|
|
text_width, text_height = font.getsize(unicode_text)
|
|
|
canvas = Image.new('RGBA', (500, 500), (255, 0, 0, 0) )
|
|
|
draw = ImageDraw.Draw(canvas)
|
|
@@ -408,7 +408,7 @@ def generate_subtitle_image(name_hash,text_content):
|
|
|
for step in range(math.ceil(len(text_content[idx])/sub_len)):
|
|
|
sv_path = dir_subtitle + name_hash +'/'+str(idx)+ str(step) +'.png'
|
|
|
sub = text_content[idx][step*sub_len:step*sub_len+sub_len]
|
|
|
- txt2image(sub, sv_path)
|
|
|
+ txt2image(sub, sv_path,'caption_font.ttf',20)
|
|
|
img_list[idx] += [{"count":len(sub),"path":sv_path}]
|
|
|
return img_list
|
|
|
|
|
@@ -623,7 +623,7 @@ def anchor_video_v2(name,text_content, image_urls):
|
|
|
sub_img_list[idx][sub_idx] = openshot.QtImageReader(sub_list[idx][sub_idx]['path'])
|
|
|
sub_img_list[idx][sub_idx].Open()
|
|
|
sub_duration = 0.3*sub_list[idx][sub_idx]['count']
|
|
|
- sub_clip_list[idx][sub_idx] = video_photo_clip(vid=sub_img_list[idx][sub_idx], layer=5, location_y=0.8,position=main_timer+sub_duration*sub_idx,end=sub_duration)
|
|
|
+ sub_clip_list[idx][sub_idx] = video_photo_clip(vid=sub_img_list[idx][sub_idx], layer=5, location_y=0.85,position=main_timer+sub_duration*sub_idx,end=sub_duration)
|
|
|
t.AddClip(sub_clip_list[idx][sub_idx])
|
|
|
sub_img_list[idx][sub_idx].Close()
|
|
|
|