MCPcopy Create free account
hub / github.com/Holasyb918/HeyGem-Linux-Python-Hack / process_video

Method process_video

app.py:168–208  ·  view source on GitHub ↗
(
        self, audio_file, video_file, watermark=False, digital_auth=False
    )

Source from the content-addressed store, hash-verified

166 logger.error(f"初始化 trans_dh_service 失败: {e}")
167
168 def process_video(
169 self, audio_file, video_file, watermark=False, digital_auth=False
170 ):
171 while not self.is_initialized:
172 logger.info("服务尚未完成初始化,等待 1 秒...")
173 time.sleep(1)
174 work_id = str(uuid.uuid1())
175 code = work_id
176 temp_dir = os.path.join(GlobalConfig.instance().temp_dir, work_id)
177 result_dir = GlobalConfig.instance().result_dir
178 video_writer_thread = None
179 final_result = None
180
181 try:
182 cap = cv2.VideoCapture(video_file)
183 width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
184 height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
185 fps = cap.get(cv2.CAP_PROP_FPS)
186 cap.release()
187
188 audio_path = audio_file
189 video_path = video_file
190
191 self.task.task_dic[code] = ""
192 self.task.work(audio_path, video_path, code, 0, 0, 0, 0)
193
194 result_path = self.task.task_dic[code][2]
195 final_result_dir = os.path.join("result", code)
196 os.makedirs(final_result_dir, exist_ok=True)
197 os.system(f"mv {result_path} {final_result_dir}")
198 os.system(
199 f"rm -rf {os.path.join(os.path.dirname(result_path), code + '*.*')}"
200 )
201 result_path = os.path.realpath(
202 os.path.join(final_result_dir, os.path.basename(result_path))
203 )
204 return result_path
205
206 except Exception as e:
207 logger.error(f"处理视频时发生错误: {e}")
208 raise gr.Error(str(e))
209
210
211if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected