1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-12 18:02:36 +00:00

ytdl: Remove DASH hacks, use DASH by default

Thanks to rcombs, ffmpeg now properly supports DASH and we can
remove our hacks for it and use it by default whenever
available. If you don't like this for whatever reason, you
can get the "normal" streams back with --ytdl-format=best .

Closes #579
Closes #1321
Closes #2359
This commit is contained in:
ChrisK2 2015-10-11 00:35:35 +02:00
parent 46c499d02a
commit 78caf6ae86
3 changed files with 15 additions and 16 deletions

View File

@ -456,16 +456,13 @@ Program Behavior
If the script can't do anything with an URL, it will do nothing.
(Note: this is the replacement for the now removed libquvi support.)
``--ytdl-format=<best|worst|mp4|webm|...>``
Video format/quality that is directly passed to youtube-dl. The possible
values are specific to the website and the video, for a given url the
available formats can be found with the command
``youtube-dl --list-formats URL``. See youtube-dl's documentation for
available aliases. To use experimental DASH support for youtube, use
``bestvideo+bestaudio``.
(Default: ``best``)
available aliases.
(Default: youtube-dl's default, currently ``bestvideo+bestaudio/best``)
``--ytdl-raw-options=<key>=<value>[,<key>=<value>[,...]]``
Pass arbitrary options to youtube-dl. Parameter and argument should be

View File

@ -717,7 +717,7 @@ const struct MPOpts mp_default_opts = {
#if HAVE_LUA
.lua_load_osc = 1,
.lua_load_ytdl = 1,
.lua_ytdl_format = "best",
.lua_ytdl_format = NULL,
.lua_ytdl_raw_options = NULL,
#endif
.auto_load_scripts = 1,

View File

@ -2,7 +2,8 @@ local utils = require 'mp.utils'
local msg = require 'mp.msg'
local ytdl = {
path = "youtube-dl"
path = "youtube-dl",
searched = false
}
local function exec(args)
@ -60,6 +61,16 @@ mp.add_hook("on_load", 10, function ()
if (url:find("http://") == 1) or (url:find("https://") == 1)
or (url:find("ytdl://") == 1) then
-- check for youtube-dl in mpv's config dir
if not (ytdl.searched) then
local ytdl_mcd = mp.find_config_file("youtube-dl")
if not (ytdl_mcd == nil) then
msg.verbose("found youtube-dl at: " .. ytdl_mcd)
ytdl.path = ytdl_mcd
end
ytdl.searched = true
end
-- strip ytdl://
if (url:find("ytdl://") == 1) then
url = url:sub(8)
@ -183,19 +194,10 @@ mp.add_hook("on_load", 10, function ()
-- video url
streamurl = json["requested_formats"][1].url
if (json["ext"] == "mp4") and not (json.duration == nil) then
msg.info("Using DASH, expect inaccurate duration.")
msg.info("Actual duration: "..mp.format_time(json.duration))
end
-- audio url
mp.set_property("file-local-options/audio-file",
json["requested_formats"][2].url)
-- workaround for slow startup (causes inaccurate duration)
mp.set_property("file-local-options/demuxer-lavf-o",
"fflags=+ignidx")
elseif not (json.url == nil) then
-- normal video
streamurl = json.url