Download MP4 (video+audio) and MP3 from YouTube at the highest possible quality
Project description
ytmedia
Download MP4 (video + audio) and MP3 from YouTube at the highest possible quality, powered by yt-dlp.
Requirements
- Python 3.10+
- ffmpeg — required for 1080p/4K video and MP3 conversion
Installing ffmpeg
| OS | Command |
|---|---|
| Windows | winget install ffmpeg |
| macOS | brew install ffmpeg |
| Ubuntu/Debian | sudo apt install ffmpeg |
Don't want to install ffmpeg manually? Install with the bundled ffmpeg option:
pip install "ytmedia[ffmpeg]"
Installation
pip install ytmedia
Or install from source (for development):
git clone https://github.com/yourusername/ytmedia
cd ytmedia
pip install -e .
Usage
As a Python library
from ytmedia import download_mp4, download_mp3, download_playlist_mp4, get_info
# Download best quality MP4 (video + audio)
download_mp4("https://youtu.be/xxxx")
# Download MP4 capped at 1080p
download_mp4("https://youtu.be/xxxx", resolution="1080")
# Download to a specific folder
download_mp4("https://youtu.be/xxxx", output_dir="./videos")
# Download MP3 at 320kbps
download_mp3("https://youtu.be/xxxx")
# Download MP3 at a lower bitrate
download_mp3("https://youtu.be/xxxx", quality="192", output_dir="./music")
# Download an entire playlist as MP4
download_playlist_mp4("https://youtube.com/playlist?list=xxxx")
# Get video metadata without downloading
info = get_info("https://youtu.be/xxxx")
print(info["title"], info["duration"])
As a CLI tool
After installation, the ytmedia command is available globally:
# Download MP4 (best quality)
ytmedia mp4 https://youtu.be/xxxx
# Download MP4 at 1080p into a specific folder
ytmedia mp4 https://youtu.be/xxxx -r 1080 -o ./videos
# Download MP3 at 320kbps
ytmedia mp3 https://youtu.be/xxxx
# Download MP3 at 192kbps
ytmedia mp3 https://youtu.be/xxxx -q 192 -o ./music
# Download an entire playlist
ytmedia playlist https://youtube.com/playlist?list=xxxx
# Print video metadata
ytmedia info https://youtu.be/xxxx
CLI options
| Flag | Description | Default |
|---|---|---|
-o, --output |
Output directory | ./downloads |
-r, --resolution |
Max video height (e.g. 1080, 720) |
best |
-q, --quality |
MP3 bitrate in kbps (e.g. 320, 192) |
320 |
Notes
- URLs containing
&list=(e.g. from YouTube autoplay) are treated as single-video downloads by default. Useytmedia playlist <url>or passallow_playlist=Truein Python to download the full playlist. - Without ffmpeg, MP4 downloads fall back to a pre-merged single stream, which is usually capped at 720p.
- MP3 conversion always requires ffmpeg.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ytmedia-0.1.0.tar.gz.
File metadata
- Download URL: ytmedia-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08ad40e6a4db5ad24800eeaad97e10f498cf4ef3d233c2069129f61f0be1c4b2
|
|
| MD5 |
9880d7e6e7029f4f9eff1c3a4741bdeb
|
|
| BLAKE2b-256 |
6cde631870c1ba387e7510f42616a772d77404dd33b78950c891ec0f8eae8342
|
File details
Details for the file ytmedia-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ytmedia-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add818b9c489af2814e7fd78d01f7d0c39e2351106ec67b8d738577921092977
|
|
| MD5 |
83fe8bd8f23e179bd9eacf1b26ccb841
|
|
| BLAKE2b-256 |
38381b23446c32241dc852b82bc6c0d3d7e417c896164043e65531a45310376f
|