Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions player/lua/ytdl_hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,11 @@ local function formats_to_edl(json, formats, use_all_formats)
elseif sub.media_type == "audio" then
props = props .. ",samplerate=" .. as_integer(track.asr)
end
hdr[#hdr + 1] = "!delay_open,media_type=" .. sub.media_type ..
",codec=" .. (sub.codec or "null") .. props

if not is_default then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not delay_open anymore? I think you should be initializing duration as documentation says, instead of removing this flag

Using multiple segments requires you to specify all offsets and durations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already sets the duration below but it doesn't work for bilibili.tv.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why setting duration doesn't work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bilibili.tv it's not present in the JSON (e.g. yt-dlp -J https://www.bilibili.com/video/BV1tywge6EWy/ > /tmp/bilibili.json). I don't know if other extractors share this problem.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see duration. It also works in mpv. Is your installation broken?

"duration": 14020.729
"duration_string": "3:53:40"

@kasper93 kasper93 May 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. What's the issue though? It fetches whole timeline pretty quickly.

You could always skip delay-open when there is no duration, but this will fetch all formats, which is slower.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you testing a short video? It only updates duration up until where the cache is filled.

is_default is only true for the tracks in the selected format. Others are still delayed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you testing a short video?

43 minutes, it's not so long, but should be enough, no?

It only updates duration up until where the cache is filled.

I tested with --no-cache

is_default is only true for the tracks in the selected format. Others are still delayed.

And what about other tracks, they still don't have duration set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With --no-cache duration is only the current time-pos + 1 for me.

The duration is preserved after changing to a delayed track.

@kasper93 kasper93 May 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead reevaluate the coded parameters of delayed tracks when they are selected/opened for the first time?

This not only involves duration, but also codec and dozen other fields in mp_codec_params which are not populated for delayed open.

You can see that we show null codec for all those tracks, if they are not mapped upfront. You can do this to test:

--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -556,7 +556,7 @@ local function formats_to_edl(json, formats, use_all_formats)
                     props = props .. ",samplerate=" .. as_integer(track.asr)
                 end
                 hdr[#hdr + 1] = "!delay_open,media_type=" .. sub.media_type ..
-                    ",codec=" .. (sub.codec or "null") .. props
+                    ",codec=null" .. props

                 -- Add bitrate information etc. for better user selection.
                 local byterate = 0

hdr[#hdr + 1] = "!delay_open,media_type=" .. sub.media_type ..
",codec=" .. (sub.codec or "null") .. props
end

-- Add bitrate information etc. for better user selection.
local byterate = 0
Expand Down
Loading