Automate YouTube Shorts creation locally — script generation, stock video search, TTS voiceover, subtitles, background music, and social media scheduling.
- AI Script Generation — uses g4f (free) or Gemini to generate video scripts
- Stock Video Search — auto-downloads matching clips from Pexels
- Multi-Voice TTS — Supertonic (local, 10 voices, 33 languages), TikTok TTS (fallback), KittenTTS
- Subtitle Templates — 10 presets (classic, modern_glow, bold_outline, minimal, cinematic, neon, social_viral, floating, news_ticker, karaoke_highlight)
- Background Music — auto-mix from your music library or extract from a video
- Image Stitching — upload multiple images to stitch at the start of the video with configurable duration per image (default 5s)
- Frame Extraction — extract a frame from any generated video for thumbnails
- Aspect Ratios — 9:16, 16:9, 1:1, 4:5, 21:9
- Multi-Business MagicSync — configure multiple API keys for different businesses; select which one to use when scheduling
- Social Media Scheduling — schedule posts to Instagram, TikTok, Facebook, LinkedIn, YouTube via MagicSync
- Hardware Acceleration — auto-detects GPU for faster ffmpeg encoding
YouTube or click on the image.

git clone https://github.com/leamsigc/ShortsGenerator.git
cd ShortsGenerator
cp .env.example .env
# Edit .env — at minimum set PEXELS_API_KEY and IMAGEMAGICK_BINARY
docker compose up -dOpen http://localhost:5000 or http://localhost:3000 for the frontend.
pip install -r requirements.txt
cp .env.example .env
# Fill in PEXELS_API_KEY, IMAGEMAGICK_BINARY, etc.
cd Backend
python main.pycd UI
npm install
npm run devThe frontend depends on the backend running on port 8080.
| Variable | Required | Description |
|---|---|---|
PEXELS_API_KEY |
Yes | Stock video search |
IMAGEMAGICK_BINARY |
Yes | Path to ImageMagick convert (e.g. /usr/bin/convert) |
TIKTOK_SESSION_ID |
No | TikTok TTS fallback |
GOOGLE_API_KEY |
No | Gemini AI model |
ASSEMBLY_AI_API_KEY |
No | Cloud subtitle generation |
OPENAI_API_KEY |
No | OpenAI models |
MAGICSYNC_BASE_URL |
No | Default MagicSync server URL |
MAGICSYNC_API_TOKEN |
No | Default MagicSync API token |
See EnvironmentVariables.md for the full list.
- Generate a script — enter a video subject, select a script template, click Generate
- Review & edit — modify the script, add search keywords, select subtitle template
- Upload images (optional) — upload images that will be stitched at the start of the video; set duration per image
- Select voice — choose TTS engine and voice style
- Set aspect ratio — 9:16 (default), 16:9, 1:1, or 4:5
- Generate video — downloads stock clips, generates TTS, combines everything with subtitles
- Add music — pick from your music library or extract audio from a video
- Schedule — in the Videos page, click "Schedule Upload", select a business and platforms, set date/time, and post via MagicSync
In the Generate page, click the Images section and upload one or more images. Each image becomes a video segment at the start of the final video. Adjust the global duration (default 5s) or set per-image duration. Images are scaled and cropped to match the selected aspect ratio.
In Settings → MagicSync Integration, add API keys for each business. Each business has its own MagicSync URL, API token, and video base URL. When scheduling a video, select which business to use — the correct credentials are sent automatically.
POST /api/extract-frame extracts a frame from any generated video at a given timestamp. Use this to generate custom thumbnails.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/generate |
Full video generation pipeline |
| POST | /api/script |
Generate script only |
| POST | /api/search-and-download |
Search + download + TTS + combine |
| POST | /api/cancel |
Cancel generation |
| POST | /api/addAudio |
Add background music to video |
| POST | /api/upload-music |
Upload music file |
| POST | /api/download-music-url |
Download & extract audio from URL |
| POST | /api/upload-video |
Upload video files |
| POST | /api/upload-image |
Upload images for video stitching |
| POST | /api/extract-frame |
Extract a frame from a video |
| GET | /api/getVideos |
List generated videos |
| GET | /api/getSongs |
List available music |
| GET | /api/models |
List TTS voices |
| GET | /api/settings |
Get global settings |
| POST | /api/settings |
Update global settings |
| POST | /api/magicsync/accounts |
List MagicSync accounts |
| POST | /api/schedule-to-magicsync |
Schedule a post |
| GET | /api/video/<filename> |
Serve generated video |
| GET | /static/generated_videos/<file> |
Static video files |
Backend/
├── main.py # Flask app, all API routes
├── video.py # Video processing, ffmpeg, subtitles, images
├── settings.py # Global defaults
├── gpt.py # AI script generation
├── search.py # Pexels stock video search
├── tiktokvoice.py # TikTok TTS
├── classes/
│ └── Shorts.py # Core pipeline orchestrator
UI/
├── pages/
│ ├── generate/index.vue # Video generation workspace
│ ├── videos/index.vue # Gallery + scheduling
│ └── settings.vue # Global settings + MagicSync
├── composables/
│ ├── useVideoSettings.ts # Video generation state
│ └── useGlobalSettings.ts # App-wide settings
└── stores/
Pull requests are welcome. For major changes, please open an issue first.
See LICENSE for details.


