Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include DASH for default max resolution selection & download #1643

Closed
himadri0327 opened this issue Oct 23, 2013 · 7 comments
Closed

Include DASH for default max resolution selection & download #1643

himadri0327 opened this issue Oct 23, 2013 · 7 comments
Labels

Comments

@himadri0327
Copy link

@himadri0327 himadri0327 commented Oct 23, 2013

When the highest resolution is DASH, automatically download & mux max-res DASH-VIDEO (say 137) with max bitrate DASH-AUDIO (say 141) as part of the default max resolution selection & download algorithm.

Currently I manually determine if 1080p is only in DASH format and if so run a cmd-script (like below) and thought it could probably be included in youtube-dl itself.

set URL=%*
youtube-dl --get-filename %URL% >tmpfile
set /p fname= <tmpfile
del tmpfile
echo %fname%
youtube-dl --no-mtime --retries 20 -f 137 %URL% -o tmp.vid
youtube-dl --no-mtime --retries 20 -f 141 %URL% -o tmp.aud
ffmpeg -i tmp.vid -i tmp.aud -c copy "%fname%"
del tmp.vid
del tmp.aud

@jonathanong
Copy link

@jonathanong jonathanong commented Oct 25, 2013

+1 i just started using youtube-dl and was wondering why everything was in 720p :(

@davidscholberg
Copy link

@davidscholberg davidscholberg commented Nov 11, 2013

For *nix users, this is a sh script that does basically the same thing as the cmd script above:

#!/bin/sh

set -e

VIDEO_NAME=$(youtube-dl --get-filename "$1")
echo "$VIDEO_NAME"

VIDEO_ID=$(youtube-dl --get-id "$1")

youtube-dl -f 137 -o '%(id)s.vid' "$1"
youtube-dl -f 141 -o '%(id)s.aud' "$1"

ffmpeg -i "$VIDEO_ID.vid" -i "$VIDEO_ID.aud" -c copy "$VIDEO_NAME"

rm "$VIDEO_ID".*

I think if this functionality is integrated into youtube-dl, it should probably be an option rather than default behavior, since ffmpeg seems to be an optional dependency.

@diffycat
Copy link

@diffycat diffycat commented Nov 12, 2013

This script will download and merge >1080p or 1080 video, otherwise fallback to default youtube-dl behaviour. Just tweak it's options.

#! /usr/bin/env bash

default_options='-o "$HOME/incom/youtube/%(title)s-%(id)s.%(ext)s"'
download_dir="$HOME/incom/youtube/"
temp_dir=/tmp/youtube-dl/

if command -v ffmpeg >/dev/null 2>&1; then

  if youtube-dl -F "$1" | grep -q 138 ; then

    video_id=$(youtube-dl --get-id "$1")
    video_name=$(youtube-dl --get-filename "$1")

    youtube-dl -f 138 -o "$temp_dir"'%(id)s.vid' "$1"
    youtube-dl -f 141 -o "$temp_dir"'%(id)s.aud' "$1"

    ffmpeg -i "$temp_dir$video_id.vid" -i "$temp_dir$video_id.aud" -c copy "$download_dir$video_name"

  elif youtube-dl -F "$1" | grep -q 137 ; then

    video_id=$(youtube-dl --get-id "$1")
    video_name=$(youtube-dl --get-filename "$1")

    youtube-dl -f 137 -o "$temp_dir"'%(id)s.vid' "$1"
    youtube-dl -f 141 -o "$temp_dir"'%(id)s.aud' "$1"

    ffmpeg -i "$temp_dir$video_id.vid" -i "$temp_dir$video_id.aud" -c copy "$download_dir$video_name"

  else
    youtube-dl "$1" "$default_options"
  fi

else
  youtube-dl "$1" "$default_options"
fi
@mikilion
Copy link

@mikilion mikilion commented Nov 17, 2013

Based on the davidscholberg's script I'd suggest this modify:

#!/bin/sh

set -e

VIDEO_NAME=$(youtube-dl --get-filename "$1")
echo "$VIDEO_NAME"

UA=$(youtube-dl --dump-user-agent)
URL_V=$(youtube-dl -g -f 137 "$1")
URL_A=$(youtube-dl -g -f 141 "$1")

ffmpeg -i "$URL_V" -i "$URL_A" -user-agent "$UA" -multiple_requests 1  -c copy "$VIDEO_NAME"
@Strayer
Copy link

@Strayer Strayer commented Nov 24, 2013

Since you can't download whole playlists with these helper scripts, I built a small python script that lists all playlist video URLs. This, combined with xargs, allows the download of full playlists.

Source: https://gist.github.com/Strayer/7627277
Usage: youtube-playlist-links PL_gF8zzsamW5WwU-e6_5PP5r8Lir-NHS6 | xargs -l 1 youtube-dash-dl

I also made some changes to the script of davidscholberg to avoid incomplete files and skip fully downloaded ones:
https://gist.github.com/Strayer/7989654

Edit: Small change to the youtube-dl-dash script since I stumbled upon a video id that begins with a -, which is interpreted as a command line option and breaks the script.

Edit no. 2: The script now uses the best formats available and is not hardcoded to 1080p anymore, falls back to default youtube-dl if there are no DASH Video sources. (Are there actually any videos without DASH now?)

@Hrxn
Copy link

@Hrxn Hrxn commented Jun 5, 2016

Zombie issue found. Needs to be closed ASAP.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jun 5, 2016

This has been the default behaviour for a long time. Closing.

Thanks @Hrxn.

@jaimeMF jaimeMF closed this Jun 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.