Open yuvadm opened 7 years ago
Was suggested on IRC to start from something like https://github.com/mpv-player/mpv/blob/cd893626cbab0e55ca9f9a5ef384532e978fe702/player/lua/ytdl_hook.lua#L432
06:49 graphitema| you could probably do it with a userscript in Lua quite easily
06:52 yuvadm| graphitemaster: that's an interesting idea, didn't think about it
06:52 yuvadm| so i guess i would need to use whatever lua uses to parse XML, extract the stream URL, and feed it back to mpv?
06:53 graphitema| well, Lua can't parse xml, but there's a lot of xml parsing libraries for lua
06:53 graphitema| so you could use that, parse the smil, find the url, feed it into mpv
06:54 graphitema| alternatively, if smil have an obvious format, you could forgo the xml parser completely and do it hard core
06:54 graphitema| e.g, just look for strings with .m3u8 in them or something
06:54 yuvadm| well yeah if you look at the example SMIL file I linked to it's pretty damn easy
06:55 graphitema| yeah, looking for FileURL tags seems easy
06:55 yuvadm| it's a single tag that I care about, and of course it's a .m3u8 extension
06:55 graphitema| I would look into how the ytdl stuff works in mpv, because it's taking a URL and feeding it into some Lua hook that does all the ugly crap
06:56 yuvadm| can you point me to the relevant source files? i'm assuming those are scripts that are baked into mpv?
06:56 graphitema| https://github.com/mpv-player/mpv/blob/master/player/lua/ytdl_hook.lua
06:57 graphitema| mp.add_hook is prolyl what you're after, "on_load" and mp.get_property("stream-open-filename", "")
06:58 graphitema| mpv will load the lua scripts in your user scripts folder automatically iirc
06:58 yuvadm| yep i think i already have some scripts there
06:59 yuvadm| and once I get something working, assuming we want it built in, it's just a matter of opening a pull request to add it to player/lua ?
Current plan:
~/.config/mpv/scripts/
on_load
hook to grab the SMIL URL and fetch itSMILUrl
, probably don't even need an XML parsing libWork in progress on https://github.com/yuvadm/mpv-smil-hook
Some video stream URLs are protected with timestamped tokens, making it inconvenient (or impossible) to save URLs for future use. However some streams also publish stream metadata in SMIL format, which already renders the relevant tokens inline.
If mpv would be able to accept and parse SMIL files it could support these streams without the need to care about timestamps or tokens.
One such example can be found at http://ipbc-metadata-rr-d.vidnt.com/live/ipbc/IPBCchannel11LVM/hls/metadata.xml (see the
ttl
andcdn_token
query params in each stream)