|
@@ -305,53 +305,19 @@ class ExtractVideoBestFrame:
|
|
|
|
|
|
case "ACTIVE":
|
|
|
# video process successfully
|
|
|
- try:
|
|
|
- best_frame_time_ms = google_ai.fetch_info_from_google_ai(
|
|
|
- prompt=extract_best_frame_prompt(),
|
|
|
- video_file=google_file,
|
|
|
- )
|
|
|
- print(best_frame_time_ms)
|
|
|
- if best_frame_time_ms:
|
|
|
- self.set_extract_result(
|
|
|
- task_id=task["id"],
|
|
|
- file_state="ACTIVE",
|
|
|
- best_frame_time_ms=best_frame_time_ms.strip(),
|
|
|
- )
|
|
|
- else:
|
|
|
- update_task_queue_status(
|
|
|
- db_client=self.db_client,
|
|
|
- task_id=task["id"],
|
|
|
- task="extract",
|
|
|
- ori_status=const.PROCESSING_STATUS,
|
|
|
- new_status=const.FAIL_STATUS,
|
|
|
- )
|
|
|
- # delete local file and google file
|
|
|
- if os.path.exists(video_local_path):
|
|
|
- os.remove(video_local_path)
|
|
|
-
|
|
|
- google_ai.delete_video(file_name)
|
|
|
- log(
|
|
|
- task=const.TASK_NAME,
|
|
|
- function="extract_best_frame_with_gemini_ai",
|
|
|
- message="video process successfully",
|
|
|
- data={
|
|
|
- "task_id": task["id"],
|
|
|
- "file_name": file_name,
|
|
|
- "state": state,
|
|
|
- "best_frame_time_ms": best_frame_time_ms,
|
|
|
- },
|
|
|
- )
|
|
|
- except Exception as e:
|
|
|
- log(
|
|
|
- task=const.TASK_NAME,
|
|
|
- function="extract_best_frame_with_gemini_ai",
|
|
|
- message="task_failed_inside_cycle",
|
|
|
- data={
|
|
|
- "task_id": task["id"],
|
|
|
- "track_back": traceback.format_exc(),
|
|
|
- "error": str(e),
|
|
|
- },
|
|
|
+ # try:
|
|
|
+ best_frame_time_ms = google_ai.fetch_info_from_google_ai(
|
|
|
+ prompt=extract_best_frame_prompt(),
|
|
|
+ video_file=google_file,
|
|
|
+ )
|
|
|
+ print(best_frame_time_ms)
|
|
|
+ if best_frame_time_ms:
|
|
|
+ self.set_extract_result(
|
|
|
+ task_id=task["id"],
|
|
|
+ file_state="ACTIVE",
|
|
|
+ best_frame_time_ms=best_frame_time_ms.strip(),
|
|
|
)
|
|
|
+ else:
|
|
|
update_task_queue_status(
|
|
|
db_client=self.db_client,
|
|
|
task_id=task["id"],
|
|
@@ -359,6 +325,40 @@ class ExtractVideoBestFrame:
|
|
|
ori_status=const.PROCESSING_STATUS,
|
|
|
new_status=const.FAIL_STATUS,
|
|
|
)
|
|
|
+ # delete local file and google file
|
|
|
+ if os.path.exists(video_local_path):
|
|
|
+ os.remove(video_local_path)
|
|
|
+
|
|
|
+ google_ai.delete_video(file_name)
|
|
|
+ log(
|
|
|
+ task=const.TASK_NAME,
|
|
|
+ function="extract_best_frame_with_gemini_ai",
|
|
|
+ message="video process successfully",
|
|
|
+ data={
|
|
|
+ "task_id": task["id"],
|
|
|
+ "file_name": file_name,
|
|
|
+ "state": state,
|
|
|
+ "best_frame_time_ms": best_frame_time_ms,
|
|
|
+ },
|
|
|
+ )
|
|
|
+ # except Exception as e:
|
|
|
+ # log(
|
|
|
+ # task=const.TASK_NAME,
|
|
|
+ # function="extract_best_frame_with_gemini_ai",
|
|
|
+ # message="task_failed_inside_cycle",
|
|
|
+ # data={
|
|
|
+ # "task_id": task["id"],
|
|
|
+ # "track_back": traceback.format_exc(),
|
|
|
+ # "error": str(e),
|
|
|
+ # },
|
|
|
+ # )
|
|
|
+ # update_task_queue_status(
|
|
|
+ # db_client=self.db_client,
|
|
|
+ # task_id=task["id"],
|
|
|
+ # task="extract",
|
|
|
+ # ori_status=const.PROCESSING_STATUS,
|
|
|
+ # new_status=const.FAIL_STATUS,
|
|
|
+ # )
|
|
|
|
|
|
except Exception as e:
|
|
|
log(
|