Skip to content

Instantly share code, notes, and snippets.

@andyeff
Last active December 30, 2015 04:59
Show Gist options
  • Save andyeff/7779814 to your computer and use it in GitHub Desktop.
Save andyeff/7779814 to your computer and use it in GitHub Desktop.
Dashtube in Cygwin
#!/bin/bash
id_pre=$(youtube-dl --no-playlist --get-id -- $1)
if [[ $? -ne 0 ]]; then
exit $?
fi
id=$(echo $id_pre | tr -d '\r')
desc=$(youtube-dl --no-playlist --get-title -- $1 | tr -cd '[:alnum:][:space:]' | tr -d '\r')
echo
echo "id is ${id}"
echo "input is ${1}"
echo "title is ${desc}"
# Try for 1440p,
# Then 60fps 1080p / 720p,
# Then 1080p / 720p,
# Then 480p
# http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
youtube-dl --no-playlist -f 264/299/298/137/136/135 -o "dl_${id}_v.mp4" -- $1
if [[ $? -ne 0 ]]; then
exit $?
fi
# Try for 256kbit, then 128kbit, then 48kbit AAC - http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
youtube-dl --no-playlist -f 141/140/139 -o "dl_${id}_a.m4a" -- $1
if [[ $? -ne 0 ]]; then
exit $?
fi
ffmpeg.exe -i "dl_${id}_v.mp4" -i "dl_${id}_a.m4a" -vcodec copy -acodec copy "dl_${id}_muxed.mp4" 2>/dev/null
echo
mv "dl_${id}_muxed.mp4" "/cygdrive/e/video/_dump/${desc}.mp4"
if [[ $? -ne 0 ]]; then
exit $?
else
rm "dl_${id}_v.mp4"
rm "dl_${id}_a.m4a"
echo "All Done - ${desc}.mp4"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment