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.3.0.tar.gz (10.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.3.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ytmedia-0.3.0.tar.gz
  • Upload date:
  • Size: 10.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.3.0.tar.gz
Algorithm Hash digest
SHA256 14db7349c7ff737703b0f30313cc13d057baad7ad2fae2a5b3549134157d0e15
MD5 589e02c2f63b2869c867246788311a5a
BLAKE2b-256 ebceaef5cdf1ec51197dab1c39ff9f104214ef5557e4ccab89e6bbcd705f7f9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ytmedia-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c376c7e6552257b1254e50162059ae4c020cd173423cba2db779dad172933f4d
MD5 d4e2d37ce3bc2a96db207da17e22d86e
BLAKE2b-256 eefb6357fd9d4b68ddc066ffaa98e26bc6f62f59793513a5ca09820bb71b0720

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