Understanding Long YouTube Videos with Gemini

Hi,
I’m woking on an agent on n8n to analyze one hour long youtube videos with Gemini 2.0 models.
It seems the long videos return 500 error and doesn’t give me an output.
Any ideas or advice you can give?
Thank you!

I am using a prompt structure like this:

return {
contents: [
{
role: “user”,
parts: [
{
fileData: {
mimeType: “video/*”,
fileUri: $input.first().json.videoUrl
}},
{text: `
Think like a successful strategic planner working at an advertising agency. Analyze this video:

Please answer the following two questions:
What is the strategic main message of this video?
Which Reasons to Believe (RTBs) support this main message?

Write each answer clearly and concisely in 1–2 sentences. Do not include any introductory text or additional content. Provide your answers under the following two headings, and make sure these headings are bold:

Strategic Message:
RTB:

Do not leave any line breaks between them.`
}]}],
generationConfig: {
responseMimeType: “text/plain”
}};

HTTP Request URL (POST):
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=KEY

1 Like

Hey @Goktug_Yurt , seems like an intermittent issue. I tried passing a YT video longer than 1 hour using the 2.0 model, and it worked fine. Let me know if you are still facing the issue.

Thanks

1 Like

Hey @GUNAND_MAYANGLAMBAM
Thanks for your time and your feedback.
Is it possible for you to share the prompt code you posted to Gemini?
I just want to be shure if I’m using the right structure.

Thanks!

I followed the format below to pass the YouTube URL.

{
      "contents": [{
        "parts":[
            {"text": "summarize the video."},
            {
              "file_data": {
                "file_uri": "https://www.youtube.com/watch?v=jGwO_UgTS7I&list=PLoROMvodv4rMiGQp3WXShtMGgzqpfVfbU"
              }
            }
        ]
      }]
    }