|
| 1 | +# 🎬 Video RAG Usage Guide |
| 2 | + |
| 3 | +This guide will help you get started with the Video RAG demo using Google's Gemini API. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### 1. Setup Environment |
| 8 | + |
| 9 | +```bash |
| 10 | +# Clone or navigate to the video-rag-gemini directory |
| 11 | +cd video-rag-gemini |
| 12 | + |
| 13 | +# Install dependencies |
| 14 | +pip install -r requirements.txt |
| 15 | + |
| 16 | +# Test your setup |
| 17 | +python test_setup.py |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. Get Gemini API Key |
| 21 | + |
| 22 | +1. Visit [Google AI Studio](https://aistudio.google.com/app/apikey) |
| 23 | +2. Sign in with your Google account |
| 24 | +3. Click "Create API Key" |
| 25 | +4. Copy your API key |
| 26 | + |
| 27 | +### 3. Configure API Key |
| 28 | + |
| 29 | +**Option A: Environment Variable (Recommended)** |
| 30 | +```bash |
| 31 | +# Create .env file |
| 32 | +cp .env.example .env |
| 33 | + |
| 34 | +# Edit .env file and add your API key |
| 35 | +GEMINI_API_KEY=your_actual_api_key_here |
| 36 | +``` |
| 37 | + |
| 38 | +**Option B: Enter in App** |
| 39 | +- You can also enter the API key directly in the Streamlit sidebar |
| 40 | + |
| 41 | +### 4. Run the Application |
| 42 | + |
| 43 | +```bash |
| 44 | +streamlit run app.py |
| 45 | +``` |
| 46 | + |
| 47 | +The app will open in your browser at `http://localhost:8501` |
| 48 | + |
| 49 | +## Using the App |
| 50 | + |
| 51 | +### Step 1: Enter API Key |
| 52 | +- If you haven't set up the environment variable, enter your Gemini API key in the sidebar |
| 53 | +- The key is masked for security |
| 54 | + |
| 55 | +### Step 2: Upload Video |
| 56 | +- Click "Choose a video file" in the sidebar |
| 57 | +- Supported formats: MP4, AVI, MOV, MKV, WEBM |
| 58 | +- File size limit: ~100MB (larger files may fail) |
| 59 | +- Wait for the video to be processed (this can take several minutes) |
| 60 | + |
| 61 | +### Step 3: Start Chatting |
| 62 | +- Once processing is complete, you'll see example questions |
| 63 | +- Click on example questions or type your own |
| 64 | +- Ask anything about the video content! |
| 65 | + |
| 66 | +## Example Questions |
| 67 | + |
| 68 | +### General Analysis |
| 69 | +- "What is happening in this video?" |
| 70 | +- "Summarize the main events" |
| 71 | +- "Describe the overall scene" |
| 72 | + |
| 73 | +### People & Objects |
| 74 | +- "Who are the people in this video?" |
| 75 | +- "What objects can you see?" |
| 76 | +- "Describe the clothing or appearance of people" |
| 77 | + |
| 78 | +### Actions & Events |
| 79 | +- "What actions are taking place?" |
| 80 | +- "What is the sequence of events?" |
| 81 | +- "What happens at the beginning/middle/end?" |
| 82 | + |
| 83 | +### Environment & Setting |
| 84 | +- "What is the setting or location?" |
| 85 | +- "Describe the environment" |
| 86 | +- "What time of day is it?" |
| 87 | + |
| 88 | +### Specific Details |
| 89 | +- "What colors are prominent in the video?" |
| 90 | +- "What sounds might be present?" (Note: Gemini analyzes visual content) |
| 91 | +- "What emotions are expressed?" |
| 92 | + |
| 93 | +## Tips for Best Results |
| 94 | + |
| 95 | +### Video Quality |
| 96 | +- Use clear, well-lit videos |
| 97 | +- Avoid very shaky or blurry footage |
| 98 | +- Higher resolution generally works better |
| 99 | + |
| 100 | +### Question Types |
| 101 | +- Be specific in your questions |
| 102 | +- Ask about visual elements (Gemini can't hear audio) |
| 103 | +- Break complex questions into simpler parts |
| 104 | + |
| 105 | +### File Management |
| 106 | +- Keep video files under 100MB when possible |
| 107 | +- Use common formats (MP4 is most reliable) |
| 108 | +- Compress large files if needed |
| 109 | + |
| 110 | +## Troubleshooting |
| 111 | + |
| 112 | +### Common Issues |
| 113 | + |
| 114 | +**"Error uploading video"** |
| 115 | +- Check file format and size |
| 116 | +- Ensure stable internet connection |
| 117 | +- Try a different video file |
| 118 | + |
| 119 | +**"Video processing failed"** |
| 120 | +- File may be too large or corrupted |
| 121 | +- Try compressing the video |
| 122 | +- Check if format is supported |
| 123 | + |
| 124 | +**"Error generating response"** |
| 125 | +- API key may be invalid or expired |
| 126 | +- Check your API quota/billing |
| 127 | +- Try a simpler question first |
| 128 | + |
| 129 | +**App is slow or unresponsive** |
| 130 | +- Large videos take time to process |
| 131 | +- Wait a few minutes before trying again |
| 132 | +- Refresh the page if needed |
| 133 | + |
| 134 | +### Getting Help |
| 135 | + |
| 136 | +1. **Check Setup**: Run `python test_setup.py` |
| 137 | +2. **Verify API Key**: Make sure it's correct and has quota |
| 138 | +3. **Test with Small Video**: Try a short, small video first |
| 139 | +4. **Check Logs**: Look at the Streamlit terminal for error messages |
| 140 | + |
| 141 | +## Advanced Usage |
| 142 | + |
| 143 | +### Command Line Demo |
| 144 | +```bash |
| 145 | +# Run the command-line demo |
| 146 | +python demo.py |
| 147 | +``` |
| 148 | + |
| 149 | +### Environment Variables |
| 150 | +```bash |
| 151 | +# Set API key for session |
| 152 | +export GEMINI_API_KEY=your_key_here |
| 153 | + |
| 154 | +# Run app |
| 155 | +streamlit run app.py |
| 156 | +``` |
| 157 | + |
| 158 | +### Custom Configuration |
| 159 | +You can modify `app.py` to: |
| 160 | +- Change the Gemini model (e.g., gemini-1.5-flash for faster responses) |
| 161 | +- Adjust file size limits |
| 162 | +- Customize the UI theme |
| 163 | +- Add additional video formats |
| 164 | + |
| 165 | +## API Limits & Costs |
| 166 | + |
| 167 | +- **Free Tier**: Limited requests per minute/day |
| 168 | +- **File Size**: ~100MB per file |
| 169 | +- **Processing Time**: Varies by video length and complexity |
| 170 | +- **Rate Limits**: May need to wait between requests |
| 171 | + |
| 172 | +Check [Gemini API pricing](https://ai.google.dev/pricing) for current limits and costs. |
| 173 | + |
| 174 | +## Security Notes |
| 175 | + |
| 176 | +- Never share your API key publicly |
| 177 | +- Use environment variables for production |
| 178 | +- The app doesn't store videos permanently |
| 179 | +- Videos are uploaded to Google's servers for processing |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +*Happy video chatting! 🎬✨* |
| 184 | + |
0 commit comments