Skip to content

Instantly share code, notes, and snippets.

@erickyun
Forked from Ryu1845/clip.sh
Last active September 4, 2022 13:43
Show Gist options
  • Save erickyun/37ea4d35579c903895154fdc06e4a434 to your computer and use it in GitHub Desktop.
Save erickyun/37ea4d35579c903895154fdc06e4a434 to your computer and use it in GitHub Desktop.
Download only part of a youtube video
#!/data/data/com.termux/files/usr/bin/bash
echo "Enter URL here:"
read URL
echo "Enter START_TIME here:"
read START_TIME
echo "Enter END_TIME here:"
read END_TIME
echo "Enter END_FILENAME here:"
read END_FILENAME
AUDIO_URL="$(yt-dlp "${URL}" -g -f bestaudio)"
VIDEO_URL="$(yt-dlp "${URL}" -g -f bestvideo)"
ffmpeg \
-ss "${START_TIME}" -i "${VIDEO_URL}" -to "${END_TIME}" \
-ss "${START_TIME}" -i "${AUDIO_URL}" -to "${END_TIME}" \
-map 0:0 -map 1:0 -c copy -shortest -y "/storage/emulated/0/download/${END_FILENAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment