From 6ac3d77e908b9398f9f8c9b8be15a33be4ee67ea Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Fri, 10 Feb 2017 19:43:32 +0000 Subject: 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. --- player/lua/ytdl_hook.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 0a55ddb93b..d53a2ae4c1 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -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 -- cgit v1.2.3