zhangyong vor 1 Jahr
Ursprung
Commit
ad3fb8d5a3
2 geänderte Dateien mit 9 neuen und 9 gelöschten Zeilen
  1. 1 1
      main.py
  2. 8 8
      video_stitching/video_stitching.py

+ 1 - 1
main.py

@@ -18,7 +18,7 @@ def job_douyin_data():
 schedule.every().day.at("14:00").do(job_douyin_data)
 
 # 设置上午4点运行任务
-schedule.every().day.at("11:24").do(job_video_stitching)
+schedule.every().day.at("11:34").do(job_video_stitching)
 
 while True:
     schedule.run_pending()

+ 8 - 8
video_stitching/video_stitching.py

@@ -149,9 +149,6 @@ class VideoStitching():
             total_duration += clip.duration
             if total_duration >= duration_limit:
                 break
-            # 处理完毕后释放视频剪辑对象
-            # clip.close()
-            # Common.logger().info(f"处理完毕后释放视频剪辑对象")
 
         # 如果总时长小于等于目标时长,则不做视频拼接
         if total_duration <= duration_limit:
@@ -226,10 +223,10 @@ class VideoStitching():
         video_with_subtitles.write_videofile(output_path, codec='libx264', fps=24)
         if os.path.isfile(output_path):
             Common.logger().info("视频生成成功!生成路径为:", output_path)
-            return included_videos
+            return included_videos, video_with_subtitles
         else:
             Common.logger().info("视频生成失败,请检查代码和文件路径。")
-            return ""
+            return "", video_with_subtitles
 
 
 
@@ -297,7 +294,7 @@ class VideoStitching():
             videos = Oss.get_oss_url(videos)
             # 视频截取
             try:
-                audio_url = cls.concatenate_videos(videos, str(audio), audio_id)
+                audio_url, video_with_subtitles = cls.concatenate_videos(videos, str(audio), audio_id)
                 if len(audio_url) == 0:
                     Common.logger().info(f"视频生成失败")
                     continue
@@ -325,12 +322,15 @@ class VideoStitching():
                         time.sleep(120)
                         count += 1
                         Common.logger().info(f"视频添加到对应用户成功")
-                        if count >= 14:
+
+                        if count >= 12:
                             break
+                        # 释放视频对象
+                        video_with_subtitles.close()
             except Exception as e:
                 Common.logger().warning(f"新拼接视频发送oss失败:{e}\n")
                 continue
-            if count >= 14:
+            if count >= 12:
                 break
 
     @classmethod