-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding cleaned up SEI frame-type 6 logic for 608/708 captions #334
Conversation
@jlacivita Which stream are you using for testing? I have one with CEA-608 captions baked in, but it doesn't appear to pass through your forest of I'm testing with the following: http://cdn3.videos.bloomberg.com/btv/us/master.m3u8 |
@jlacivita regarding your potential NALu type 6 parsing issue. basically the parsing processing is a follow: if you suspect a NAL parsing issue, the idea would be to binary dump the complete PES packet holding SEI NAL unit, so that we could check whether the missing bytes are present in the PES packet or not ... so basically you add the following code here:
if the missing bytes are in the PES packet, then it is a NAL parsing issue. |
@mangui I'll take a look |
Okay, i made some important discoveries. I've been assuming ccType needed to have a value of 0 or 1, which is the value HDS streams in OSMF always used when dispatching onCaptionInfo. After searching through the NAL units, i've found that the subtitles in HLS seem to have ccType set to 2. If i change my "if" clause to use 2 not 0 i get the CC's output the the console. This means I can't wire them directly up to OSMFCCLib, though, without some manipulation. Stay tuned for more. |
yay! there's no problem with the flashls TS, PES or NAL parsing. Thanks to mangui's notes above I was able to confirm the packets are in the file, and parsed by flashls in the correct order using a hex editor and some logging. Once I had that confidence, i discovered a bug in my forrest of logging statements where I wasn't decoding the cc_data bytes properly. From there, I cleaned up my FLVTag sorting code, and I've got OSMFCC working with about 90% accuracy. The remaining problem seems to be in the order the onCaptionInfo events are dispatched. I'm not sure if it's in my caption sorting code or in my new FLVTag() creation, or if it's something subtle in flashls's code for dispatching METADATA tags. What I do know is that if i reload my page, i see onCaptionInfo events in the wrong order once in a while on the OSMF side, even though they're in the correct order on the flashls parsing side in TSDemuxer. This happens without changing any of my code, just re-running the page. I think there might be a race condition somewhere in the flashls code that reads FLVTags with the METADATA type and inserts them into the HLSNetStream. I've committed my latest, so you should be able to see both my forrest of log messages (we can delete this soon, i think!) as well as OSMFCCLib doing it's job (for the most part) @mangui: i'm ready for your next clue... how do I confirm FLVTag.METADATA messages are going out in the correct order? |
Okay, i've got debug output inside of HLSNetStream (it's not committed, since it's a bit too much logging) that shows appendTags is being called with the FLVTags in the wrong order sometimes (even though they're inserted via parsing in the correct order). Furthermore, it's not always the same tag that is out-of-order, so that rules out any problems with the OSMFCCLib getting mixed up. Something between TSDemuxer and HLSNetStream is mixing up the FLVTag order for METADATA tags (and maybe others). |
@jlacivita interesting. do you have a debug log exhibiting the issue to share ? |
@mangui. while preparing the log, i noticed that I've been comparing just the first bitrate's parsing, with the actual playback of a different bitrate. It turns out that the error does, indeed happen at the parsing level, not the appending level. It's caused by the fact that these messages aren't always in the correct order, and it's up to the HLS client to sort them. I'm sorting them inside the parseAVCPES function, but that grabs a batch of them each time (via _parseTimer) so they're only locally sorted within the batches. I think they need to be sorted at the Fragment level, so i'll try that now. Log attached, where you can see what i'm saying. |
Okay that fixed it. i've seen captions work 3 times in a row now, with no mixed up characters. I'm going to commit to my branch so you can see the changes i've made. I'll leave my debugging code in for now. |
Commited to my branch. 608/708 Captions are working!! |
@jlacivita Bravo! Did you work from any publicly accessible documentation? If so, please share it here. Also, I don't fully understand why live is any different from VOD as far as captions are concerned. Could you elaborate on this? |
I mainly used Wikipedia. MPEG2 H264 streams store 708 captions as described here: Once you get the two bytes out of the 708, you can follow the 608 character logic for interpreting them, but that's on the Decoder side, which I haven't really implemented aside from logging out the ASCII characters for debugging (OSMFCCLib is a full featured decoder option): @mangui was also a valuable source of HLS parsing information. The only reason I backed of from dealing with live is that it always adds extra use cases to any only video development. While I was still trying to understand how it worked, I didn't want live mixed into my head :) I do think it should work the same way for both live and vod, now that it's working. |
I think the difference is that our live streams have plain 608 captions, while the VOD one you worked on has 708. I have yet to see 708 captions in a live stream, but I only have my own streams as specimens. |
@maxaf: who's encoding your live streams? I see they're being cached via akamai hdnetwork, so i'm assuming you're using someone pretty standard for encoding? Most of the HDS live streams that i've seen use 708 captions. I wonder why HLS would use 608? I grabbed a single fragment of your stream and didn't see evidence of 608 or 708 in the binary. If you could get me any details, that would be very helpful |
@jlacivita We're using encoders from Cisco's AnyRes Live range, but data sheets don't confirm specifically which captions are being output by the encoder. |
@maxaf: i've confirmed that some live streams work with my changes and some do not. Still trying to track down what the difference is, but I'm guessing it's your theory. |
@mangui now that i've seen 708 working in live streams, i do feel it's time to pull this change into an official flashls branch... What's your opinion? |
@jlacivita yes it would make sense to merge, but I looked at the diff and it still contains a bunch of debug statement. |
Okay, all of the debug is removed. The changes are only in TSDemuxer, and StreamBuffer. PTS sorting is definitely needed, although I suppose we could address your concern here with two things:
I still think sorting belongs somewhere in the library, since captions are useful if they're not in the correct order. |
And honestly, #2 seems hard to do w/out creating a whole system for scanning ahead for SEI tags, sorting them, and then dispatching them based on timecode... I really think the sorting belongs in StreamBuffer, so every implementation (OSMF, etc) can benefit from it |
thanks, looks better ! |
most streams i've seen have them unsorted. I just sent you some via email. |
tks, I am quite busy ATM, will try to check later this week |
Conflicts: .gitignore bin/debug/flashls.swc bin/debug/flashlsChromeless.swf bin/debug/flashlsFlowPlayer.swf bin/debug/flashlsOSMF.swc bin/debug/flashlsOSMF.swf bin/release/flashls.swc bin/release/flashlsChromeless.swf bin/release/flashlsFlowPlayer.swf bin/release/flashlsOSMF.swc bin/release/flashlsOSMF.swf
tks for taking into account the suggested changes (jlacivita@ee5ed3e) |
Conflicts: .gitignore bin/debug/flashls.swc bin/debug/flashlsChromeless.swf bin/debug/flashlsFlowPlayer.swf bin/debug/flashlsOSMF.swc bin/debug/flashlsOSMF.swf bin/release/flashls.swc bin/release/flashlsChromeless.swf bin/release/flashlsFlowPlayer.swf bin/release/flashlsOSMF.swc bin/release/flashlsOSMF.swf
Should be fixed |
that is weird, i still see plenty of unrelated changes |
Conflicts: bin/debug/flashls.swc bin/debug/flashlsChromeless.swf bin/debug/flashlsFlowPlayer.swf bin/debug/flashlsOSMF.swc bin/debug/flashlsOSMF.swf bin/release/flashls.swc bin/release/flashlsChromeless.swf bin/release/flashlsFlowPlayer.swf bin/release/flashlsOSMF.swc bin/release/flashlsOSMF.swf
okay, i'm learning how to use git here, so thanks for bearing with me. should be down to just those files (TSDemuxer and StreamBuffer) |
adding cleaned up SEI frame-type 6 logic for 608/708 captions
thanks @jlacivita ! |
I'm very interested in this feature. Would it be possible to recap what's now available (either in the dev or master branches)? The discusion above is very interesting but it's difficult to follow to a conclusion. Also the test video from @jlacivita (http://www.cpcweb.com/webcasts/hls/cpcdemo.m3u8) seems to have disappeared in the meantime..
Basically, if I have a live or live2vod stream, and I paste it in one of the demo players, am i supposed to see captions (or at least the captions button) or not. If not, what should I do in order to enable it for live streams? |
This is 708 for live, but it doesn't work end-to-end out of the box yet as On Thu, Nov 5, 2015 at 8:58 AM, zuzzurro [email protected] wrote:
|
I think it would just be great if @jlacivita could add a little bit of documentation about the integration of his code with the higher levels, like an OSMF player using OSMFCCLib, that I think he used during his development. Right now implementing CC support and contributing back is more difficult than it could be. |
I keep following up myself here, but that's probably ok. I was finally able to find out at least the first part of my issue, after having added some debugging logs to the CC code. When I switched to another video generated with a different encoder, bingo! it started working and it went all the way down to the _tags.push(tag); line. Now I have two tasks: 1) figure out what's the difference in the encoder configuration and 2) figure out how to use OSMFCClib.. |
Is there any example to test this funcionality? |
So here's a summary of what i've done:
currently i'm getting almost recognizable english out of both 4 & 5, but characters (and commands) are dropped for some reason.
I'm fairly convinced that there's some problem with the NAL Unit parsing, upstream, because I'm seeing characters dropped/corrupted in both my debug log messages, as well as in the events dispatched to OSMFCCLib.
OSMFCCLib is just a tool to make sure we're parsing the packets properly. Once it works, we can discuss writing our own view or not, and cleaning up the delivery method to be something other than onCaptionInfo (maybe that logic simply belongs in the OSMF wrapper to flashls).