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:
Ricardo Constantino 2017-02-10 19:43:32 +00:00
parent d0f1d382e6
commit 6ac3d77e90
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531
1 changed files with 6 additions and 4 deletions

View File

@ -88,7 +88,7 @@ local function extract_chapters(data, video_length)
return ret
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
msg.debug("No fragments to join into EDL")
return nil
@ -98,7 +98,7 @@ local function edl_track_joined(fragments, protocol)
local offset = 1
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
edl = edl .. "!mp4_dash,init=" .. edl_escape(fragments[1].url) .. ";"
offset = 2
@ -303,7 +303,8 @@ mp.add_hook("on_load", 10, function ()
if not (json["requested_formats"] == nil) then
for _, track in pairs(json.requested_formats) do
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
-- audio track
mp.commandv("audio-add",
@ -317,7 +318,8 @@ mp.add_hook("on_load", 10, function ()
elseif not (json.url == nil) then
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
streamurl = edl_track or json.url