This is a Python-based YouTube Video Downloader that allows users to download high-quality MP4 (H.264) video and M4A (AAC) audio formats from YouTube. It utilizes yt-dlp for efficient extraction and downloading while ensuring minimal API calls.
- Supports 720p, 1080p, 2K, 4K, and 8K resolutions (if available).
- Efficient execution – Fetches video metadata only once to reduce redundant API calls.
- Auto-merging of video & audio formats (into a single MP4 file).
- User-friendly format selection.
- Automatic sanitization of filenames (removes invalid characters).
- Cross-platform compatibility – Works on Windows, macOS, and Linux.
Before running the script, ensure you have the following installed:
- Download and install Python from the official website: python.org/downloads
- During installation, check the box "Add Python to PATH" for easy access from the command line.
- Verify installation by running:
python --version
2️⃣ FFmpeg (Required for merging audio & video) FFmpeg is a multimedia framework used for processing audio and video files.
🛠 Windows Installation: Download the latest FFmpeg build from: https://ffmpeg.org/download.html
Extract the files to a location (e.g., C:\ffmpeg).
Add FFmpeg to your system's PATH:
Search for "Environment Variables" in the Windows Start Menu.
Under System Variables, find Path, then click Edit.
Click New and add the bin folder path (e.g., C:\ffmpeg\bin).
Click OK to save the changes.
Verify installation by running:
sh Copy Edit ffmpeg -version 🛠 Linux / macOS Installation: For Debian/Ubuntu:
sh Copy Edit sudo apt update && sudo apt install ffmpeg For macOS (using Homebrew):
sh Copy Edit brew install ffmpeg Verify installation with:
sh Copy Edit ffmpeg -version Once both Python and FFmpeg are installed, you're ready to run the script! 🚀
markdown Copy Edit
Install the required dependencies using:
pip install -r requirements.txt- Run the script:
python youtube_downloader.py
- Enter the YouTube video URL when prompted.
- Choose a resolution from the available options.
- The video will be downloaded and saved in the specified folder.
- Clone the repository (or download the script):
git clone https://github.com/yourusername/youtube-downloader.git cd youtube-downloader - Install dependencies:
pip install -r requirements.txt
- Run the script:
python youtube_downloader.py
By default, videos are saved in:
D:\YouTubeVideoDownloader
You can change this path by modifying the DESTINATION_DIRECTORY variable inside the script.
This script uses:
yt-dlp– for extracting and downloading YouTube videos.FFmpeg– for merging audio and video files.urllib– for URL parsing.os– for handling file paths.re– for sanitizing filenames.
This script is intended for personal use only. Downloading videos without permission may violate YouTube’s Terms of Service. Use responsibly.
This project is open-source under the MIT License.
Pull requests are welcome! Feel free to submit improvements or bug fixes. 😊