Install and Run yt-dlp on Android with Termux
Quick answer
yt-dlp runs natively on Android through Termux — no root, no PC. Install Termux from F-Droid rather than the Play Store, then four commands. The storage step is the one people skip and then cannot find their files:
pkg update && pkg upgrade -y
pkg install -y python ffmpeg
pip install -U yt-dlp
termux-setup-storage
Get Termux from the right place
The Play Store build was abandoned in 2020 and its package repositories no longer resolve. It
looks identical and fails at pkg install, which is why so many Termux problems turn
out to be this.
Install from F-Droid or the GitHub releases. If you already have the Play Store one, uninstall it first — they cannot coexist.
Storage, and where files land
termux-setup-storage triggers Android's permission dialog and creates
~/storage. Without it, downloads land in Termux's private directory where no other
app can see them:
termux-setup-storage
ls ~/storage
~/storage/shared is the phone's normal storage — the one your gallery and file
manager index. Download there:
yt-dlp -P ~/storage/shared/Download/yt-dlp -o "%(title)s.%(ext)s" "URL"
A config file worth having
Typing long flags on a phone keyboard is its own punishment. Set them once:
-P ~/storage/shared/Download/yt-dlp
-o %(title)s.%(ext)s
--restrict-filenames
--embed-metadata
--embed-thumbnail
--no-playlist
--sleep-requests 1.5
Create it with mkdir -p ~/.config/yt-dlp && nano ~/.config/yt-dlp/config.
The config guide covers precedence and what else is
worth putting there.
Sharing a URL into Termux
Copying a link out of the YouTube app and typing it is miserable. Install Termux:API and make a shortcut instead:
pkg install -y termux-api
mkdir -p ~/bin
cat > ~/bin/dl <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
url="$(termux-clipboard-get)"
yt-dlp "$url"
EOF
chmod +x ~/bin/dl
Copy a link in the YouTube app, switch to Termux, type dl. You will also need the
Termux:API companion app from the same source as Termux itself.
Downloads stopping when the screen turns off
Android suspends background processes aggressively. Two things stop it:
termux-wake-lock
# …run the download…
termux-wake-unlock
And exempt Termux from battery optimisation in Android's app settings. The wake lock alone is often not enough on Samsung and Xiaomi builds, which are more aggressive than stock Android.
Audio, for podcasts and music
The most common reason to run yt-dlp on a phone at all:
yt-dlp -x --audio-format m4a --embed-thumbnail --embed-metadata \
-P ~/storage/shared/Music \
-o "%(artist,uploader)s/%(title)s.%(ext)s" \
"URL"
m4a rather than mp3 because YouTube's audio is already m4a — extracting it needs no re-encoding, which on a phone means seconds instead of minutes and no second generation of loss. The audio guide covers when mp3 is worth it anyway.
Keeping it updated
pip install -U yt-dlp
pkg upgrade -y
Termux's pip environment is yours, so there is no externally-managed-environment error here — unlike on a desktop Linux.
If it still fails
-
pkg installcannot resolve anything. The Play Store build. Reinstall from F-Droid. -
Permission denied writing to storage.
termux-setup-storagewas never run, or the dialog was dismissed. Run it again. -
Files download but no app can see them. They are in Termux's private
directory. Use
-P ~/storage/shared/.... -
ffmpeg missing.
pkg install ffmpegis a separate step from installing yt-dlp; without it everything caps at 360p. - Rate limited on mobile data. Carrier-grade NAT puts thousands of subscribers behind one address. See HTTP 429; wifi usually resolves it.
Frequently asked
Where do I get Termux?
Why can my gallery not see the downloads?
Does it stop when the screen turns off?
Is there a GUI instead?
Related
- Install ffmpeg for yt-dlp on Windows, macOS and Linux Without ffmpeg yt-dlp is capped at whatever single file a site offers — usually 360p. How to install it on eac...
- yt-dlp Output Templates: Name and Sort Files Automatically The -o template turns a folder of random filenames into a library. Every field worth using, the numeric and da...
- yt-dlp: pip, pipx, Binary or Nightly — Which to Install The install method decides how fast you get extractor fixes, and extractor fixes are the whole game. A straigh...