Skip to main content

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.


Installation

pip install ytmedia

Or install from source (for development):

git clone https://github.com/yourusername/ytmedia
cd ytmedia
pip install -e .

Quick Setup

After installing, run the init command once to set up ffmpeg and all required dependencies automatically:

ytmedia init

This will:

  • Install and activate a prebuilt ffmpeg binary (no manual system install needed)
  • Install yt-dlp-ejs JS challenge solver scripts for full YouTube format support
  • Check for a Node.js or Deno JS runtime and guide you if missing

Note: For best quality (1080p/4K), a JS runtime is recommended. Install Node.js from nodejs.org if you don't have it.


Requirements

  • Python 3.10+
  • Node.js (recommended) — for full YouTube format support

Everything else (ffmpeg, yt-dlp-ejs) is handled automatically by ytmedia init.


Usage

As a Python library

from ytmedia import init, download_mp4, download_mp3, download_playlist_mp4, get_info

# Run once after install to set up dependencies
init()

# 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 MP4 without audio (video only)
download_mp4("https://youtu.be/xxxx", audio=False)

# 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:

# Set up dependencies (run once after install)
ytmedia init

# 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 MP4 without audio
ytmedia mp4 https://youtu.be/xxxx --no-audio

# Download MP3 at 320kbps
ytmedia mp3 https://youtu.be/xxxx

# Download MP3 at 192kbps into a specific folder
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
--no-audio Download MP4 without audio track off

Notes

  • URLs containing &list= (e.g. from YouTube autoplay) are treated as single-video downloads by default. Use ytmedia playlist <url> or pass allow_playlist=True in Python to download the full playlist.
  • Without ffmpeg, MP4 downloads fall back to a pre-merged single stream, usually capped at 720p. Run ytmedia init to fix this automatically.
  • MP3 conversion always requires ffmpeg.
  • MP4 audio is encoded as AAC during the merge step, ensuring compatibility with Windows Media Player, QuickTime, and mobile devices.

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

ytmedia-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytmedia-0.2.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file ytmedia-0.2.0.tar.gz.

File metadata

  • Download URL: ytmedia-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ytmedia-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a663125736d536f954061ff842b6875940690172bfefc2425ca2290d0e847422
MD5 6d2ed6d69c8c9e853f4a6d156437eb61
BLAKE2b-256 f8155ef9aa873d0eb530badf008bc7896e99f78489c3488597ed33536707b482

See more details on using hashes here.

File details

Details for the file ytmedia-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ytmedia-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ytmedia-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29a49fcf8c3c67175929284cd60ee0b7cf1521df74834d76397bcf00db756a6b
MD5 f485ebf4104165492b3e5766b3fe7d25
BLAKE2b-256 5752b74e6abc718f3179e5c625ad16b54d1ae6b511372714a2a1c15394e32a98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page