[libbluray-devel] bd_read output m2ts and language tags

Shaya Potter spotter at gmail.com
Sun Jun 21 07:20:12 CEST 2020


so, yes.  essentially it is a rmux of the m2ts stream.  And I sort of did
it.

https://github.com/sjpotter/bluray-http-server/tree/master/pkg/pmtparser +
https://github.com/sjpotter/bluray-http-server/blob/master/pkg/readers/mt2sremuxer.go

also, when I talk about seeking, I don't mean seeking to time, I mean
seeking to byte position in file.  (as an example, libbluray can seem to
accurately seek to byte position in file, while libdvdnav cannot, for
instance, you seek to end in libdvdnav and record the position, you will
get a different value than if you just read through the whole title and
counted bytes, if I had to guess, it be because navigation oriented packets
are mixed into the stream and therefore make it impossible, but just a
guess so could be wrong)

also, m2ts does have PMT packets, but the issue is that PMT packets can be
re random.  i.e. you dont know how many PMT packets will be in a stream and
hence if you have to increase the PMT packet effective size (i.e. increased
payload adds additional 192 byte blocks) it becomes problematic as while
you can insert them on demand (i.e. store "expanded PMT" and every time you
see PMT packet 0, insert your stored amount (+ timestamp modification)
instead of the PMT packets in the stream.  But, this will cause problems
with sizing.  currently m2ts stream from libbluray is a known size.

I hacked around it, as ffmpeg (libavcodec I guess) and vlc (which probably
inherits its from libavcodec, can't speak for other players outside the
libavcodec universe) seem to only care about the first pmt payload.  i.e. I
edit that and dont touch the rest.  It will enumerate the language based on
that, and since I only edit it once, can record that one delta and then
still seek byte accurately.

at the end, my solution above is a terrible hack (as one can see from wht I
linked, the goal was to add bluray iso/bdmv folder support to things like
plex, or at least prove to them how easy it would be.  it "works", but is a
hack, should be implemented natively and then the entire discussion is
basically mute.

On Sat, Jun 20, 2020 at 11:48 AM John Stebbins <jstebbins at jetheaddev.com>
wrote:

> On Wed, 2020-04-08 at 17:29 +0300, Shaya Potter wrote:
> I know, I have all that data, that's why I know its available, I read it
> out of bd_title_info
>
> it's lost in the sense that if I dump the bd_read() data to a file, its
> lost, so if I'm streaming the m2ts (say over http), the reader (say vlc),
> doesn't have it.  vlc can enumerate the all the streams, but without the
> metadata associated with it  That's the problem I'm trying to solve.
> perhaps there's a better way.  The best option would be something that
> preserves the random seek nature that I get with the bd "file descriptor"
> of libbluray.
>
> i.e. I'd be ok with writing my own packets at the beginning of the stream
> if that was possible (and pointers given to me on how to do it) if that
> would solve the issue.
>
> On Wed, Apr 8, 2020 at 4:53 PM Hendrik Leppkes <h.leppkes at gmail.com
> <mailto:h.leppkes at gmail.com>> wrote:
> Information about languages is not "lost", it was typically never in
> those m2ts files. If you are interested in additional metadata, you
> need to get it from the playlist files, which luckily libbluray also
> reads for you, so its just a matter of calling the right API
> functions.
> Similar, chapter information is also available through the libbluray API.
>
> - Hendrik
>
> On Wed, Apr 8, 2020 at 12:19 PM Shaya Potter <spotter at gmail.com<mailto:
> spotter at gmail.com>> wrote:
> >
> > when I read a title with libbluray, i get a nice m2ts (I believe)
> stream.  However, while this stream has all the video/audio/pg streams, it
> loses the language associated with them (as part of juts the clip info I
> guess, not the raw m2ts stream).
> >
> > Now, it seems that it is possible for this info to be part of the mpegts
> stream (or at least I think), as ffmpeg can assign the metadata language to
> it, but that just works now for audio streams as ffmpeg is known to not be
> able to write hdmv_pgs streams to an mpegts container.
> >
> > Any chance libbluray could just append the language metadata itself (at
> least if asked by the api user?).
> >
> > not as important (and perhaps less possible), but what about chapters?
> >
> > thanks.
>
> What you're asking for is essentially a remux of the ts stream with this
> information added. Seems to me this is beyond the scope of what libbluray
> is meant to do. IIRC the information you want to add is carried in
> descriptors in that program map table (PMT) of transport streams. But I
> think m2ts do not have any PMTs. So to add this information, you would have
> to build a complete PMT (which describes all the elementary streams in the
> transport) and add the necessary descriptors. Not an easy task and not
> something easily tought via a few emals. You would have to read the mpeg
> transport stream spec to get a complet enough understanding. But once
> build, you could just tack it on to the start of the stream and you should
> be good to go.
>
> Random seek behavior of libbluray is completely another matter. libbluray
> is using the metadata of the disc structure for that. Transport stream have
> no index. Even worse, transport stream timestamps can have discontinuities
> (i.e. go backwards, jump forwards). There are markers designating when a
> discontinuity is happening and a player adjusts accordingly during linear
> playback, but you can't seek to some random location in a stream and know
> how far in seconds you have seeked.
>
> _______________________________________________
> libbluray-devel mailing list
> libbluray-devel at videolan.org
> https://mailman.videolan.org/listinfo/libbluray-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/libbluray-devel/attachments/20200621/590749d8/attachment.html>


More information about the libbluray-devel mailing list