mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
ytdl_hook: use bitrate fields for bitrate metadata instead of file sizes
If available.
This commit is contained in:
parent
f5c1d71639
commit
af9403577a
@ -400,7 +400,14 @@ local function add_single_video(json)
|
|||||||
as_integer(track.width) .. ",h=" .. as_integer(track.height)
|
as_integer(track.width) .. ",h=" .. as_integer(track.height)
|
||||||
local size = as_integer(track["filesize"])
|
local size = as_integer(track["filesize"])
|
||||||
local byterate = 0
|
local byterate = 0
|
||||||
if size > 0 and duration > 0 then
|
for _, f in ipairs({"tbr", "vbr", "abr"}) do
|
||||||
|
local br = as_integer(track[f])
|
||||||
|
if br > 0 then
|
||||||
|
byterate = math.floor(br * 1000 / 8)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if byterate == 0 and size > 0 and duration > 0 then
|
||||||
byterate = as_integer(size / duration)
|
byterate = as_integer(size / duration)
|
||||||
end
|
end
|
||||||
hdr[#hdr + 1] = "!track_meta,title=" ..
|
hdr[#hdr + 1] = "!track_meta,title=" ..
|
||||||
|
Loading…
Reference in New Issue
Block a user