|
@@ -42,7 +42,7 @@ class AGC():
|
|
|
"""
|
|
|
@classmethod
|
|
|
def zw_concatenate_videos(cls, videos, audio_duration, audio_video, platform, s_path, v_path, mark, v_oss_path):
|
|
|
-
|
|
|
+ Common.logger("video").info(f"{mark}的{platform}渠道获取待拼接视频")
|
|
|
video_files = cls.concat_videos_with_subtitles(videos, audio_duration, platform, mark)
|
|
|
Common.logger("video").info(f"{mark}的{platform}视频文件:{video_files}")
|
|
|
|
|
@@ -133,8 +133,14 @@ class AGC():
|
|
|
["ffprobe", "-v", "error", "-show_entries", "format=duration",
|
|
|
"-of", "default=noprint_wrappers=1:nokey=1", video_file],
|
|
|
capture_output=True, text=True)
|
|
|
- return float(result.stdout)
|
|
|
-
|
|
|
+ if not result.stdout.strip():
|
|
|
+ print("错误:ffprobe 没有返回任何输出。")
|
|
|
+ return 0
|
|
|
+ try:
|
|
|
+ return float(result.stdout.strip())
|
|
|
+ except ValueError:
|
|
|
+ print(f"{video_file}视频无法从输出中解析时长:'{result.stdout.strip()}'")
|
|
|
+ return 0
|
|
|
"""计算需要拼接的视频"""
|
|
|
@classmethod
|
|
|
def concat_videos_with_subtitles(cls, videos, audio_duration, platform, mark):
|
|
@@ -375,6 +381,7 @@ class AGC():
|
|
|
while True:
|
|
|
# 清空所有文件
|
|
|
cls.clear_mp4_files(mark)
|
|
|
+ time.sleep(10)
|
|
|
s_path, v_path, video_path_url, v_oss_path = cls.create_folders(mark)
|
|
|
|
|
|
if pj_count == 10:
|
|
@@ -425,6 +432,7 @@ class AGC():
|
|
|
videos = [str(videos)]
|
|
|
video_id = random.choice(videos)
|
|
|
video_url = PQ.get_audio_url(video_id)
|
|
|
+ time.sleep(10)
|
|
|
Common.logger("video").info(f"{mark}的{platform}渠道获取视频链接成功")
|
|
|
download_video = Oss.download_url(video_url, video_path_url, str(video_id))
|
|
|
if download_video:
|
|
@@ -443,8 +451,10 @@ class AGC():
|
|
|
user_id = sqlHelp.get_user_id(channel, mark)
|
|
|
url_list, user = sqlHelp.get_url_list(user_id, mark, "50")
|
|
|
videos = [list(item) for item in url_list]
|
|
|
+ Common.logger("video").info(f"{mark}的{platform}渠道下载视频")
|
|
|
videos = Oss.get_oss_url(videos, video_path_url)
|
|
|
- Common.logger("video").info(f"{mark}的{platform}渠道获取视频链接成功")
|
|
|
+ time.sleep(10)
|
|
|
+ Common.logger("video").info(f"{mark}的{platform}渠道下载视频成功")
|
|
|
video_files = cls.zw_concatenate_videos(videos, audio_duration, audio_video, platform, s_path, v_path,
|
|
|
mark, v_oss_path)
|
|
|
|