Alex Volkov commited on
Commit
6e73d37
1 Parent(s): 4e4fd21

Poppins doesn't support Korean!

Browse files
Files changed (2) hide show
  1. download.py +1 -1
  2. utils/subs.py +8 -3
download.py CHANGED
@@ -91,7 +91,7 @@ def download_generator(url, translate_action=True, source_language='Autodetect',
91
  subbed_video_path = tempdir / f"{meta['id']}_translated.mp4"
92
 
93
  fontsdir = Path('fonts')
94
- bake_subs(video, subbed_video_path.absolute() , srt_path.absolute(), fontsdir)
95
  yield {"message": f"Subtitled video ready!", "sub_video": str(subbed_video_path.absolute()), "meta": meta}
96
  except ffmpeg.Error as e:
97
  print('stdout:', e.stdout.decode('utf8'))
 
91
  subbed_video_path = tempdir / f"{meta['id']}_translated.mp4"
92
 
93
  fontsdir = Path('fonts')
94
+ bake_subs(video, subbed_video_path.absolute() , srt_path.absolute(), fontsdir, translate_action)
95
  yield {"message": f"Subtitled video ready!", "sub_video": str(subbed_video_path.absolute()), "meta": meta}
96
  except ffmpeg.Error as e:
97
  print('stdout:', e.stdout.decode('utf8'))
utils/subs.py CHANGED
@@ -7,10 +7,15 @@ from typing import Iterator, TextIO
7
 
8
 
9
 
10
- def bake_subs(input_file, output_file, subs_file, fontsdir):
11
  print(f"Baking {subs_file} into video... {input_file} -> {output_file}")
12
 
13
- fontfile = fontsdir / 'Lato-Black.ttf'
 
 
 
 
 
14
  watermarkfile = fontsdir / 'watermark_new.png'
15
 
16
  video = ffmpeg.input(input_file)
@@ -22,7 +27,7 @@ def bake_subs(input_file, output_file, subs_file, fontsdir):
22
  ih = int(video_stream['height'])
23
  print(f"width {iw} and height {ih}")
24
  sub_size = 18 if iw > ih else 8
25
- fontstyle = f'Fontsize={sub_size},OutlineColour=&H40000000,BorderStyle=3,FontName=Poppins,Bold=1'
26
  (
27
  ffmpeg.concat(
28
  video.filter('subtitles', subs_file, fontsdir=fontfile, force_style=fontstyle),
 
7
 
8
 
9
 
10
+ def bake_subs(input_file, output_file, subs_file, fontsdir, translate_action):
11
  print(f"Baking {subs_file} into video... {input_file} -> {output_file}")
12
 
13
+ fontfile = fontsdir / 'arial.ttf'
14
+ fontname = 'Arial'
15
+ if translate_action:
16
+ fontfile = fontsdir / 'Poppins-Black.ttf'
17
+ fontname = 'Poppins'
18
+
19
  watermarkfile = fontsdir / 'watermark_new.png'
20
 
21
  video = ffmpeg.input(input_file)
 
27
  ih = int(video_stream['height'])
28
  print(f"width {iw} and height {ih}")
29
  sub_size = 18 if iw > ih else 8
30
+ fontstyle = f'Fontsize={sub_size},OutlineColour=&H40000000,BorderStyle=3,FontName={fontname},Bold=1'
31
  (
32
  ffmpeg.concat(
33
  video.filter('subtitles', subs_file, fontsdir=fontfile, force_style=fontstyle),