A modern web application that allows users to download videos from Facebook by providing the video URL. Built with FastAPI backend and Next.js frontend.
- π₯ Download videos from Facebook with a simple URL
- πΌοΈ Preview video thumbnails before downloading
- π― Select video quality/format
- π¨ Clean, responsive UI with Facebook's blue color scheme
- β‘ Fast and efficient video processing
- π Secure and privacy-focused
- Next.js 15 - React framework with server-side rendering
- React 19 - UI library
- Tailwind CSS - Utility-first CSS framework
- TypeScript - Type-safe JavaScript
- Radix UI - Accessible component library
- Lucide React - Beautiful icon library
- FastAPI - Modern, fast Python web framework
- yt-dlp - Powerful video downloader
- Python 3.11+ - Programming language
- Uvicorn - ASGI server
- Pydantic - Data validation
Before running this application, make sure you have:
- Python 3.11 or higher installed (Download Python)
- Node.js 18 or higher installed (Download Node.js)
- npm or pnpm package manager
git clone https://github.com/kisugez/facebook-video-dowloader.git
cd facebook-video-dowloadercd backend# On Windows
python -m venv venv
venv\Scripts\activate
# On macOS/Linux
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txt# Using the run script (recommended)
python run.py
# Or using uvicorn directly
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Or using the old main.py (backward compatible)
python main.pyThe backend API will be available at:
- API: http://localhost:8000
- API Documentation: http://localhost:8000/api/docs
- Alternative Docs: http://localhost:8000/api/redoc
- Health Check: http://localhost:8000/health
Open a new terminal window and navigate to the project root:
# From backend directory, go back to root
cd ..
# Install dependencies
npm install
# or if using pnpm
pnpm installnpm run dev
# or
pnpm devThe frontend will be available at:
- Application: http://localhost:3000
- Open the application in your browser at http://localhost:3000
- Copy a Facebook video URL (e.g.,
https://www.facebook.com/watch?v=123456789) - Paste the URL into the input field
- Click "Process Video" button
- Wait for processing - The app will extract video information
- Select quality - Choose your preferred video quality/format
- Click "Download Now" - The video will download to your browser's download folder
After downloading:
- Check your browser's download folder (usually
Downloadsdirectory) - The video file will be saved with the original Facebook video title
- Open with any video player (VLC, Windows Media Player, QuickTime, etc.)
- Most browsers allow you to drag and drop the downloaded video file into a browser tab
- Or use the browser's "Open File" option (Ctrl+O / Cmd+O)
- The video will play directly in the browser
facebook-video-dowloader/
βββ backend/ # FastAPI backend
β βββ app/ # Application package
β β βββ api/ # API routes
β β β βββ routes/
β β β βββ video.py # Video endpoints
β β βββ core/ # Core functionality
β β β βββ config.py # Configuration settings
β β β βββ logging.py # Logging setup
β β βββ schemas/ # Pydantic models
β β β βββ video.py # Video schemas
β β βββ services/ # Business logic
β β β βββ video.py # Video service
β β βββ main.py # FastAPI app initialization
β βββ downloads/ # Downloaded videos (temporary)
β βββ requirements.txt # Python dependencies
β βββ run.py # Application entry point
β βββ main.py # Legacy entry point
β βββ Dockerfile # Docker configuration
βββ app/ # Next.js app directory
β βββ page.tsx # Home page
β βββ layout.tsx # Root layout
β βββ actions.ts # Server actions
β βββ globals.css # Global styles
βββ components/ # React components
β βββ video-downloader.tsx # Main downloader component
β βββ ui/ # UI components
βββ public/ # Static files
βββ package.json # Node.js dependencies
βββ README.md # This file
The backend can be configured via environment variables. Create a .env file in the backend directory:
# API Settings
API_V1_STR=/api
PROJECT_NAME=Facebook Video Downloader API
VERSION=1.0.0
# CORS Settings
BACKEND_CORS_ORIGINS=["http://localhost:3000"]
# Server Settings
HOST=0.0.0.0
PORT=8000
RELOAD=TrueSet the backend API URL in your environment. Create a .env.local file in the root directory:
NEXT_PUBLIC_API_URL=http://localhost:8000Problem: ModuleNotFoundError: No module named 'app'
- Solution: Make sure you're running from the
backenddirectory and have activated the virtual environment
Problem: Port 8000 already in use
- Solution: Change the port in the configuration or kill the process using port 8000
Problem: yt-dlp download error or Cannot parse data
- Solution: This usually means Facebook has updated their page structure. Try these steps:
- Update yt-dlp:
pip install --upgrade yt-dlp - For Facebook Reels: Open the Reel in your browser and copy the full URL from the address bar after it loads (it will be like
https://www.facebook.com/reel/123456789) - Use the direct video URL instead of the share link
- If the issue persists, Facebook may have temporarily blocked automated downloads - try again later
- Update yt-dlp:
Problem: Requested format is not available
- Solution: The app will automatically retry with the best available format. If this fails, try selecting "Best Quality" instead of a specific resolution.
Problem: ECONNREFUSED or connection errors
- Solution: Make sure the backend server is running on port 8000
Problem: CORS errors
- Solution: Verify that
http://localhost:3000is in theBACKEND_CORS_ORIGINSconfiguration
Facebook frequently updates their page structure, which can cause temporary parsing issues with Reels:
Workaround for Facebook Reels:
- Open the Reel share link in your browser (e.g.,
https://www.facebook.com/share/r/1EVJh9rZtg/) - Wait for it to redirect to the full URL
- Copy the full URL from your browser's address bar (should look like
https://www.facebook.com/reel/791802913691439) - Use the full URL in the downloader instead of the share link
Why this happens: Facebook uses dynamic share links that redirect to the actual video. Sometimes yt-dlp cannot parse these redirects properly, especially when Facebook changes their HTML structure.
Status: The app includes automatic fallback mechanisms, but some videos may still require the full URL approach above.
- This tool is for personal use only
- Please respect copyright laws and Facebook's Terms of Service
- Downloaded videos should not be redistributed without permission
- The application does not store or track any user data
- All downloads are temporary and automatically cleaned up
# Backend tests (if available)
cd backend
pytest
# Frontend tests (if available)
npm test# Frontend linting
npm run lint
# Backend linting (requires additional tools)
cd backend
flake8 app/
black app/
mypy app/Once the backend is running, visit:
- Swagger UI: http://localhost:8000/api/docs
- ReDoc: http://localhost:8000/api/redoc
Process a Facebook video URL and extract metadata.
Request Body:
{
"url": "https://www.facebook.com/watch?v=123456789"
}Response:
{
"success": true,
"message": "Video processed successfully",
"download_id": "uuid-here",
"thumbnail_url": "https://...",
"title": "Video Title",
"duration": 120,
"formats": [...]
}Download the processed video.
Query Parameters:
url: Facebook video URL (required)format_id: Format ID to download (default: "best")
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available for personal use.
Made with β€οΈ for video enthusiasts