mirror of
https://github.com/mpv-player/mpv
synced 2025-02-09 08:27:18 +00:00
ytdl_hook: support livestream segmented DASH VODs
Seen with a VOD of a recently ended livestream on Youtube. They seem to use segmented DASH but unlike normal Youtube segmented DASH, the segments don't seem to need the initialization segment. The video actually fails to start to play if the init segment is prepended with a lot of 'Found duplicated MOOV Atom. Skipped it' errors popping up.
This commit is contained in:
parent
d0f1d382e6
commit
6ac3d77e90
@ -88,7 +88,7 @@ local function extract_chapters(data, video_length)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local function edl_track_joined(fragments, protocol)
|
local function edl_track_joined(fragments, protocol, is_live)
|
||||||
if not (type(fragments) == "table") or not fragments[1] then
|
if not (type(fragments) == "table") or not fragments[1] then
|
||||||
msg.debug("No fragments to join into EDL")
|
msg.debug("No fragments to join into EDL")
|
||||||
return nil
|
return nil
|
||||||
@ -98,7 +98,7 @@ local function edl_track_joined(fragments, protocol)
|
|||||||
local offset = 1
|
local offset = 1
|
||||||
|
|
||||||
if (protocol == "http_dash_segments") and
|
if (protocol == "http_dash_segments") and
|
||||||
not fragments[1].duration then
|
not fragments[1].duration and not is_live then
|
||||||
-- assume MP4 DASH initialization segment
|
-- assume MP4 DASH initialization segment
|
||||||
edl = edl .. "!mp4_dash,init=" .. edl_escape(fragments[1].url) .. ";"
|
edl = edl .. "!mp4_dash,init=" .. edl_escape(fragments[1].url) .. ";"
|
||||||
offset = 2
|
offset = 2
|
||||||
@ -303,7 +303,8 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
if not (json["requested_formats"] == nil) then
|
if not (json["requested_formats"] == nil) then
|
||||||
for _, track in pairs(json.requested_formats) do
|
for _, track in pairs(json.requested_formats) do
|
||||||
local edl_track = nil
|
local edl_track = nil
|
||||||
edl_track = edl_track_joined(track.fragments,track.protocol)
|
edl_track = edl_track_joined(track.fragments,
|
||||||
|
track.protocol, json.is_live)
|
||||||
if track.acodec and track.acodec ~= "none" then
|
if track.acodec and track.acodec ~= "none" then
|
||||||
-- audio track
|
-- audio track
|
||||||
mp.commandv("audio-add",
|
mp.commandv("audio-add",
|
||||||
@ -317,7 +318,8 @@ mp.add_hook("on_load", 10, function ()
|
|||||||
|
|
||||||
elseif not (json.url == nil) then
|
elseif not (json.url == nil) then
|
||||||
local edl_track = nil
|
local edl_track = nil
|
||||||
edl_track = edl_track_joined(json.fragments, json.protocol)
|
edl_track = edl_track_joined(json.fragments, json.protocol,
|
||||||
|
json.is_live)
|
||||||
|
|
||||||
-- normal video or single track
|
-- normal video or single track
|
||||||
streamurl = edl_track or json.url
|
streamurl = edl_track or json.url
|
||||||
|
Loading…
Reference in New Issue
Block a user