This project allows users to generate AI-powered short videos using advanced technologies such as Gemini, Google Cloud Text-to-Speech API, Replicate Image API, and more. The frontend is built using Next.js, with backend services powered by Neon, Drizzle ORM, and Firebase.
- Frontend: Next.js
- Backend: Neon, Drizzle ORM
- Image Generation: Replicate Image API
- Text-to-Speech: Google Cloud Text-to-Speech API
- Database: Neon, Firebase
- Cloud Services: Firebase (for authentication, storage, etc.)
- Version Control: Git, Git LFS for large files
- Generate short AI-powered videos based on user input.
- Text-to-speech conversion for voice narration.
- Image generation for video visuals.
- Secure user authentication and data storage with Firebase.
Make sure you have the following installed:
- Node.js (v16 or later)
- Git
- Firebase CLI
- Google Cloud API Key (for Text-to-Speech API)
- Replicate API Key (for Image Generation)
- Neon (for database)
-
Clone the Repository
First, clone the repository:
git clone <repository-url> cd ai-short-video-generator
-
Install Dependencies
Install the necessary dependencies using npm or yarn:
npm install
-
Set Up Environment Variables
You will need to create a
.env.localfile in the root directory and add the following environment variables (replace with your actual values):DRIZZLE_DATABASE_URL="" NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="" CLERK_SECRET_KEY="" NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_GEMINI_API_KEY="" GOOGLE_API_KEY="" NEXT_PUBLIC_FIREBASE_API_KEY="" CAPTION_API="" REPLICATE_API_TOKEN="" GOOGLE_APPLICATION_CREDENTIALS=C:\Users\HP\Desktop\AI video generator\gen-lang-client-0217637627-4d1014a40fd9.json
-
Steps to Obtain a Service Account Key (
GOOGLE_APPLICATION_CREDENTIALS):-
Create a Google Cloud Project:
- If you don’t already have a project, go to the Google Cloud Console.
- Click on Select a project in the top menu, and then click New Project to create one.
-
Enable Google Cloud APIs:
- In your Google Cloud project, enable the APIs you want to use (e.g., Vision API, Translate API, Cloud Storage, etc.).
- To do this, navigate to API & Services in the left sidebar, then click Library, and search for the APIs you need. Enable them one by one.
-
Create a Service Account:
- Navigate to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Give it a name (e.g., AI Video Generator Service Account), and optionally a description.
- Click Create.
-
Assign Roles:
- Assign roles to the service account, depending on the APIs you want to access. For example, you can assign Editor or a more specific role like Cloud Vision API User depending on the access level your app needs.
-
Create the Service Account Key:
- After assigning roles, click Done.
- On the Service Accounts page, find the account you just created and click on the three dots under "Actions".
- Select Create Key.
- Choose the JSON key type and click Create.
- A JSON file will be downloaded to your computer. This is your service account key.
-
Set the
GOOGLE_APPLICATION_CREDENTIALSEnvironment Variable:- Move the downloaded JSON file to a secure location on your machine or server (for example, you can place it in your project directory).
- Set the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to point to the path of this JSON file. In your.env.localfile, you would add:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json
Replace
/path/to/your/service-account-key.jsonwith the actual path to the downloaded JSON file.
-
-
Start the Development Server
Run the development server to view the application:
npm run dev
Navigate to http://localhost:3000 in your browser to view the project.
You can containerize the Next.js app and the Remotion renderer to run builds and server-side rendering in CI or locally.
- Build the Next.js production image:
docker build -f Dockerfile -t ai-short-video-app:latest .
- Build the Remotion renderer image (includes ffmpeg/chromium):
docker build -f Dockerfile.remotion -t ai-short-video-remotion:latest .
- Run the Remotion renderer (example):
docker run --rm -v ${PWD}/remotion/out:/remotion/out ai-short-video-remotion:latest
Notes:
- The Remotion container installs ffmpeg and chromium to allow headless rendering. You may need to tweak the
Dockerfile.remotionfor your environment.
This repository includes three workflows under
.github/workflows:ci.yml— runs on push and PRs tomain; installs dependencies, runs lint/tests (if present), and builds Next.js.docker-publish.yml— builds and publishes Docker images (app + remotion) on git tag push (vX.Y.Z) or manual dispatch. It pushes to GitHub Container Registry by default.deploy-firebase.yml— builds the app and deploys to Firebase Hosting on push tomain(requiresFIREBASE_TOKEN).
Required repository secrets:
FIREBASE_TOKEN— a CI token generated viafirebase login:cifor deploying to Firebase.- (Optional) If you want to push to Docker Hub instead of GHCR, set
DOCKERHUB_USERNAMEandDOCKERHUB_TOKENand modify thedocker-publish.ymlaccordingly.
Example: create a Firebase token and add it to GitHub secrets
# Locally (your dev machine) npm i -g firebase-tools firebase login:ci # copy the printed token and add it to the repo secrets as FIREBASE_TOKEN