marquesafonso commited on
Commit
4a21148
·
1 Parent(s): c749ace

define temporary audio file path to fix write permission issue in space (2)

Browse files
Files changed (2) hide show
  1. utils/process_video.py +3 -2
  2. utils/subtitler.py +2 -2
utils/process_video.py CHANGED
@@ -10,11 +10,12 @@ def process_video(invideo_file: str,
10
  text_color:str,
11
  highlight_mode: bool,
12
  highlight_color: str,
13
- caption_mode:str
 
14
  ):
15
  invideo_path_parts = os.path.normpath(invideo_file).split(os.path.sep)
16
  VIDEO_NAME = os.path.basename(invideo_file)
17
  OUTVIDEO_PATH = os.path.join(os.path.normpath('/'.join(invideo_path_parts[:-1])), f"result_{VIDEO_NAME}")
18
  logging.info("Subtitling...")
19
- subtitler(invideo_file, srt_string, srt_json, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, highlight_mode, highlight_color, caption_mode)
20
  return OUTVIDEO_PATH
 
10
  text_color:str,
11
  highlight_mode: bool,
12
  highlight_color: str,
13
+ caption_mode:str,
14
+ temp_dir: str
15
  ):
16
  invideo_path_parts = os.path.normpath(invideo_file).split(os.path.sep)
17
  VIDEO_NAME = os.path.basename(invideo_file)
18
  OUTVIDEO_PATH = os.path.join(os.path.normpath('/'.join(invideo_path_parts[:-1])), f"result_{VIDEO_NAME}")
19
  logging.info("Subtitling...")
20
+ subtitler(invideo_file, srt_string, srt_json, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, highlight_mode, highlight_color, caption_mode, temp_dir)
21
  return OUTVIDEO_PATH
utils/subtitler.py CHANGED
@@ -85,7 +85,7 @@ def subtitler(video_file: str,
85
  current_x += word_clip.w + space_width
86
  video = CompositeVideoClip(size=None, clips=[clip] + subtitle_clips)
87
  video.set_audio(temp_audiofile)
88
- video.write_videofile(output_file, codec='libx264', audio_codec='aac')
89
  return
90
  # Normal mode
91
  subtitles = parse_srt(srt_string)
@@ -105,4 +105,4 @@ def subtitler(video_file: str,
105
  subtitle_clips.append(txt_clip)
106
  video = CompositeVideoClip(size=None, clips=[clip] + subtitle_clips)
107
  video.set_audio(temp_audiofile)
108
- video.write_videofile(output_file, codec='libx264', audio_codec='aac')
 
85
  current_x += word_clip.w + space_width
86
  video = CompositeVideoClip(size=None, clips=[clip] + subtitle_clips)
87
  video.set_audio(temp_audiofile)
88
+ video.write_videofile(output_file, codec='libx264', audio_codec='aac', temp_audiofile = temp_audiofile)
89
  return
90
  # Normal mode
91
  subtitles = parse_srt(srt_string)
 
105
  subtitle_clips.append(txt_clip)
106
  video = CompositeVideoClip(size=None, clips=[clip] + subtitle_clips)
107
  video.set_audio(temp_audiofile)
108
+ video.write_videofile(output_file, codec='libx264', audio_codec='aac', temp_audiofile = temp_audiofile)