mirror of
https://github.com/linyqh/NarratoAI.git
synced 2026-01-24 12:38:15 +00:00
feat(update_script): 添加视频路径并更新打印信息
- 在 item_copy 中初始化 video 字段为空字符串- 根据 item_id 或 orig_timestamp 在 video_result 中查找并添加视频路径 - 更新打印信息,增加视频路径输出
This commit is contained in:
parent
6001e8038f
commit
ba4871715c
@ -109,6 +109,7 @@ def update_script_timestamps(
|
|||||||
# 初始化音频和字幕路径为空字符串
|
# 初始化音频和字幕路径为空字符串
|
||||||
item_copy['audio'] = ""
|
item_copy['audio'] = ""
|
||||||
item_copy['subtitle'] = ""
|
item_copy['subtitle'] = ""
|
||||||
|
item_copy['video'] = "" # 初始化视频路径为空字符串
|
||||||
|
|
||||||
# 如果提供了音频结果字典且ID存在于音频结果中,直接使用对应的音频路径
|
# 如果提供了音频结果字典且ID存在于音频结果中,直接使用对应的音频路径
|
||||||
if audio_result:
|
if audio_result:
|
||||||
@ -124,6 +125,12 @@ def update_script_timestamps(
|
|||||||
elif orig_timestamp in subtitle_result:
|
elif orig_timestamp in subtitle_result:
|
||||||
item_copy['subtitle'] = subtitle_result[orig_timestamp]
|
item_copy['subtitle'] = subtitle_result[orig_timestamp]
|
||||||
|
|
||||||
|
# 添加视频路径
|
||||||
|
if item_id and item_id in video_result:
|
||||||
|
item_copy['video'] = video_result[item_id]
|
||||||
|
elif orig_timestamp in video_result:
|
||||||
|
item_copy['video'] = video_result[orig_timestamp]
|
||||||
|
|
||||||
# 更新时间戳和计算持续时间
|
# 更新时间戳和计算持续时间
|
||||||
current_duration = 0.0
|
current_duration = 0.0
|
||||||
if item_id and item_id in id_timestamp_mapping:
|
if item_id and item_id in id_timestamp_mapping:
|
||||||
@ -232,4 +239,4 @@ if __name__ == '__main__':
|
|||||||
print(
|
print(
|
||||||
f"ID: {item['_id']} | Picture: {item['picture'][:20]}... | Timestamp: {item['timestamp']} | " +
|
f"ID: {item['_id']} | Picture: {item['picture'][:20]}... | Timestamp: {item['timestamp']} | " +
|
||||||
f"SourceTimeRange: {item['sourceTimeRange']} | EditedTimeRange: {item.get('editedTimeRange', '')} | " +
|
f"SourceTimeRange: {item['sourceTimeRange']} | EditedTimeRange: {item.get('editedTimeRange', '')} | " +
|
||||||
f"Duration: {item['duration']} 秒 | Audio: {item['audio']} | Subtitle: {item['subtitle']}")
|
f"Duration: {item['duration']} 秒 | Audio: {item['audio']} | Video: {item['video']} | Subtitle: {item['subtitle']}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user