Jump to content

BluRay playlist support


sjpotter

Recommended Posts

sjpotter

looking at the tunein plugin, I think it should be fairly straight forward to write a simple http server that run on the same host as emby server and streams the requested playlist over http and lets emby server stream it to its clients.  It doesn't seem like it can be seeked within, so its not perfect, but this would  be a nice proof of concept.

Link to comment
Share on other sites

sjpotter

simple poc of streaming a bluray playlist I knocked out over an hour - http https://github.com/sjpotter/bluray-http-server/

 

idea would be to add an endpoint that enables enumerating of content and then to treat it like an "internet radio station" plugin ala the tunein plugin i mentioned above.

 

the main flaw of this implementation is that it loses the metadata (i.e. track / pgs language) as that's not carried over in m2ts it seem.  unsure it matters,  if the metadata can be provided other ways (i.e. my /metadata endpoint).

 

Edited by sjpotter
Link to comment
Share on other sites

simple poc of streaming a bluray playlist I knocked out over an hour - http https://github.com/sjpotter/bluray-http-server/

 

idea would be to add an endpoint that enables enumerating of content and then to treat it like an "internet radio station" plugin ala the tunein plugin i mentioned above.

 

the main flaw of this implementation is that it loses the metadata (i.e. track / pgs language) as that's not carried over in m2ts it seem.  unsure it matters,  if the metadata can be provided other ways (i.e. my /metadata endpoint).

 

 

 

Yes in theory it should be possible to build a channel plugin to present in this manner. It means that you would see a folder for each bluray and then a list of videos when you click into that.

Link to comment
Share on other sites

sjpotter

yes, though the point isn't to enumerate all playlists, it would to just enumerate the user defined playlists and ignore the rest.

Link to comment
Share on other sites

yes, though the point isn't to enumerate all playlists, it would to just enumerate the user defined playlists and ignore the rest.

 

Sure, the plugin could have options and then send back content to the server based on those options.

Link to comment
Share on other sites

sjpotter

any plugins you recommend looking at to learn how to do this?  I was looking at tunein, it seemed relatively simple to understand.  My other question would be, what would happen in emby if I streamed an m2ts file with multiple audio tracks / subtitle tracks,  how would emby handle that? 

Link to comment
Share on other sites

 

My other question would be, what would happen in emby if I streamed an m2ts file with multiple audio tracks / subtitle tracks,  how would emby handle that? 

 

The server will figure out the media info and the clients will make the tracks available, so nothing to worry about there.

Link to comment
Share on other sites

sjpotter

from my experience looking at this, one should be able to set parental rating on a media item level, not just at the channel level.

Link to comment
Share on other sites

sjpotter

so I learned about strm files that make things work pretty transparently, don't even need a channel.

with m2ts files there's 1 problem: it loses the metadata (i.e. language info) for the audio / subtitle tracks, but besides that it plays perfectly.  can seek and what not.

so to try and solve that, I added a getmkv endpoint.  this remuxes on the fly with ffmpeg (ugly as shell out to it).  to mkv with the metadata added back in.

This makes language metadata show up in UI, but, as its streaming out of ffmpeg, can't really seek in it that well ( have an idea for a hack on that (return the content-length as the length of the m2ts, and if range is called on request, seek into m2ts before remux to mkv starts, but dont now how emby will handle the stream ending early (or how golang http server will either)

 

so the question I'm left with, is there a way to associate language metadata to the m2ts tracks via the strm file method - that would remove the need for mkv endpoint.

https://github.com/sjpotter/bluray-http-server

Edited by sjpotter
Link to comment
Share on other sites

Automatically, no. Where is that information stored in a bluray structure? I don't think it's embedded into the m2ts because ffmpeg never finds it. I think this is where bluray specific support would be needed to accommodate that.

Link to comment
Share on other sites

sjpotter

also wrote some C code to do the same with dvds to dump to an mpeg2 file, but libdvdread is so much more complicated than libbluray its not even funny (probably as blurays are conceptually simpler).

Link to comment
Share on other sites

sjpotter

Automatically, no. Where is that information stored in a bluray structure? I don't think it's embedded into the m2ts because ffmpeg never finds it. I think this is where bluray specific support would be needed to accommodate that.

 

its part of the playlist (i.e. title).  I already parse it out (its why its able to be part of the mkv and visible in my metadata endpoint)

 

the same issue exists in DVDs (see above), when I dump the mpeg2 stream, it has the tracks, but loses the metadata of languages.

 

 

Link to comment
Share on other sites

sjpotter

also testing, when I play in my web browser, it does a lot of transcoding (was playing rogue one UHD bluray for testing) apparently my web browser doesn't support hevc (so that was being transcoded to h264) and truehd (but that was more to be expected).

when I played in vlc via the upnp support in vlc, it seems to direct play (stream?) it (i.e. vlc was getting the hevc and truhd tracks)

Link to comment
Share on other sites

sjpotter

so the question I have now is, have I POCd it enough to convince emby to run with it and include it as a first class feature? :)  You could most likely even dump all your iso mounting support then, as this reads ISOs directly.

Link to comment
Share on other sites

What are the dependencies? Can it be done in managed code rather than c? Having it in managed code would allow it to live in a plugin. Writing it in c would force us to make this part of the build process.

Link to comment
Share on other sites

Also, how much end-user input is required for it to work?  How will it deal with copy-protection schemes?

Link to comment
Share on other sites

sjpotter

What are the dependencies? Can it be done in managed code rather than c? Having it in managed code would allow it to live in a plugin. Writing it in c would force us to make this part of the build process.

 

it would depend on native DLLs/so, but one can call the native DLLs from managed code (i.e. that's what I did in go essentially, use "cgo" (i.e. call out to shared libraries) to do all the heavy lifting

 

Also, how much end-user input is required for it to work?  How will it deal with copy-protection schemes?

 

for strm files, all I do is specify an iso and a playlist. i.e. literally it works by just creating an strm file of http://localhost:port/getm2ts?file=<urlencoded path to iso>&playlist=### and it plays as described above (m2ts endpoint without langauage metadata being transmited, getmkv endpoint without the ability to seek, both to nature of PoC implementation, not inherent in their mediums)

 

for copy protection - for blurays it assumes you have decrypted them already (i.e. stored as ISOs on hard disc, not something stuck in drive).  For DVDs you could probably even work with an encrypted iso without decrypting it as long as libdvdcss is loadable by lidvdvdread as css can be brute forced (i.e. I don't even always bother decrypting my DVD ISOs anymore, I just create an image with dd (ddrescue really to avoid "structural protection" that is added creating bad sectors on a disc) and drag and drop them onto vlc and it plays them fine).

 

Link to comment
Share on other sites

sjpotter

What native libs would it depend on?

videolan's libbluray (and its dependency's).  though chances are if you are shipping ffmpeg, you already need to support most them I'd think? (ffmpeg can also be compiled against libbluray)

Link to comment
Share on other sites

Ok so we're talking about a fair amount of build impact here, but then you also expressed concern about not getting regular movie metadata, so now we're talking about integration with movies so that you can choose entries from the playlist to play. That means additions will be needed to a number of objects, the database, the api, and the user interface because we have to figure out how this will be presented.

 

So now it's a question of is this what our users want us investing our resources on...my advice as the most practical answer would be to keep things as they are and find a way to get the additional playlist entries to show up in the movie extras section. You could do this now with strm files as your extras (I'm pretty sure, and if they don't get recognized, it's an easy fix)...albeit, this would not be a first class feature like you are asking.

 

So then what is the path towards a first class feature without derailing all of our current projects and taking on added complexity to our build process? The answer to that is isolate this into a plugin, but that's not going to be easy given the native dependencies. But you could alleviate the need for that by having users bring their own Vlc. That means it would require a little user setup, but as a community plugin there would be nothing wrong with that.

Link to comment
Share on other sites

sjpotter

I have 2 tracks of development in my head. 

1 is via the strm files (then it show up as part of the library). 

2. is the channel (unsure how channels work in emby relative to libraries).  With channels I obviously have more control over the metadata (but also have to figure out the structure, as little documentation for all the magic strings)

 

the advantage of the channel is that end users wouldn't have to create strm files (though I could automate that as well), the advantage of the strm files is that they might be more native (if library and channels are fundamentally treated differently, though it does seem like searches search in channels as well?)

would it be worth adding a strm type file (strm++) that enables inclusion of language metadata?  i.e. a json file that mimics mediasource (or mediastream or whatever it is) and enables overriding detected (or unable to be detected) metadata.  just a thought, but I think that would enable lots of fancy things as well as enabling "plugin" creation in whatever language one wants as long as they can provide an http interface that provides files emby understands.

anyways, I'm sort of amazed by how much progress I made in just a few days on this working after hours.  It was a fun learning experience and a bit different from my normal kubernetes development.

Edited by sjpotter
Link to comment
Share on other sites

 

 

With channels I obviously have more control over the metadata 

There isn't really much though, right? The raw media info will come from the server core.

Link to comment
Share on other sites

sjpotter

In my continued exploration of this, I've added a remuxm2ts endpoint.  This is the mostly the same as the getm2ts endpoint, except it edits in place the first PMT packet in the TS stream.  for each PID/track in the TS file, it adds in a descriptor that associates a language with it (taking from the clipinfo of the bluray disc).

 

This is enough to get emby to enumerate the languaes correctly for audio (based on my testing), but for some reason doesn't work as well for subtitle tracks (though VLC seems to have no problem enumerating them).

 

My gut feeling is that this is the wrong "track" to go down, as really all its exporting is a simple language tag, this doesn'tt help the user understand if a track is a commentary track or what not.  (I'm guessing, haven't tested it, but if an MKV would ahve a track description, Emby would display that to the end user?)

 

What I'd like is the ability to add metadata to the STRM file or somewhow otherwise associate metadata (mostly language and chapter info).  If I made a channel, I could probably do this, but I'd also have to reinvent the wheel of all the other metadata that emby automatically does right now (i.e. episode / movie description, actors, pictures.....).

Though one possibility would be if emby had a "metadata a service" service, where one could give Emby the "filename string" and it would return all the appropriate metaata so that one could fill in the channel data from that.  I'd assume this must somewhat exist already, just perhaps not in a rest api accessible form.

thoughts?

 

https://github.com/sjpotter/bluray-http-server

 

simple instructions for use now.

1) build the server (assuming you have libbluray dev packages installed and pkg-config setup correctly) (conceptually, assuming pkg-config is setup correctly on window,s this should just build as well, but only tested on linux)

 

go build ./cmd/bluray-server

 

2) run bluray-server

./bluray-server -port <some port #>

 

3) setup a library that emby will search (i.e. some directory)

 

4) reate strm files with the "filename" that you care for emby to resolve (i.e. perhaps "Rogue One - A Star Wars Story (2018)")

the format is http://localhost:<port#>/<endpoint>?file=<url encoded full path to iso image>?playlist=<playlist #>

 

there are 3 endpoints

getm2ts (just the raw m2ts for the playlist as provided by libbluray)

getmkv (sort of hackish, trying to figure out how to remux into an mkv on the fly via ffmpeg, was part of my language tag exploration) - not really recommended for lots of reasons (even if worked perfectly, one would never be "seekable" due to the nature of trying to stream mkv's that are generated on the fly)

remuxm2ts (as described above - mostly the raw m2ts stream, but with attempts to hack in language tags with minimal interference)

experience shows me that emby will now mostly resolve the languages on the tracks and will direct stream the content if able, otherwise will transcode it.  i.e. when I try to play a UHD bluray via vlc, it gets the raw hevc / truehd tracks, but if I play it in my browser, it transcodes it to h264/aac (and causes my 8 core server to make lots of noise, probably would help if my r710 could do hardware assisted hevc10 decode)

Edited by sjpotter
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...