I am using api for generating descriptions about video snaps,each video of 5 to 8sec long.I am getting description generated for the first video without any problem but for the rest it shows the file is not in ACTIVE STATE.Why is it like that.I saved the videos in a single folder and loops through each to generate it.The code works perfectly when I’m using or running program separately for each video but when I try from a single program it does not.Anyone have any idea
Welcome to the dev forum @Abin_Mathew_Sunny
When you upload a video file to the File API, it first goes into the PROCESSING
state until it is ready for inference. Only ACTIVE
files can be used for model inference.
Thus, you must check whether the file is ACTIVE
before sending it to the model for inference—description generation in your case.
import time
# Check whether the file is ready to be used.
while video_file.state.name == "PROCESSING":
print('.', end='')
time.sleep(10)
video_file = genai.get_file(video_file.name)
if video_file.state.name == "FAILED":
raise ValueError(video_file.state.name)
More information is in the documentation.