ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Investigate adding HLS support.

Open ojw28 opened this issue 12 years ago • 84 comments

ojw28 avatar Jun 23 '14 04:06 ojw28

Heyy I was trying to implement HLS(AAC) support on top of the ExoPlayer implementation and then I realized you are also investigating this. So here is my implementation so far. I have a HLSRendererBuilder and I am creating a HLSAacChunkSource that will have the audio and video representations for different bandwidths. In my case I am interested only in Audio. So this will have only one representation. And the major part I feel is the extractor. (AacChunkExtractor). So it would be great if you can let me know if I am going in the right direction.

sdhr48 avatar Jun 27 '14 16:06 sdhr48

Registering my extreme interest in adding HLS support. @sdhr48 could you put your work online? I'd love to help!

OnlyInAmerica avatar Jun 27 '14 23:06 OnlyInAmerica

That sounds about right, except the extractor should be called something like Mpeg2Extractor, since I think it would be extracting from the MPEG-2 transport stream?

ojw28 avatar Jul 01 '14 03:07 ojw28

And yes, we are looking at this too. We'll provide an update when we have something to share!

ojw28 avatar Jul 01 '14 03:07 ojw28

Nice

crossle avatar Jul 01 '14 07:07 crossle

Hi ! I'm also very interested in HLS. We need that badly for our app so I started looking into it. Right now my plan is:

  • focus on video-only first as HLS has audio/video interleaved inside chunks and it looks like it is not supported with the existing codebase.
  • add HLSRendererBuilder, HLSChunkSource, TSMediaChunk, TSExtractor all in java and all for video-only.
  • shoehorn audio support.
  • test performance, possibly implement the TSExtractor in native code.
  • add more features (live, multi-track audio, subtitles, etc...)

What do you think ? My fork is at https://github.com/martinbonnin/ExoPlayer/commits/hls. It is 100% work in progress and it does not even compile but I don't want to duplicate effort so I figure out it is better to share progress. Please tell me if you believe what I'm doing is useful. If not, just tell me what could be more useful and I'll be happy to work on whatever can make this project move faster !

martinbonnin avatar Jul 02 '14 01:07 martinbonnin

HLS support would be awesome

4ntoine avatar Jul 04 '14 02:07 4ntoine

Without HLS support ExoPlayer feels incomplete. Let's hope someday we will get it working!

akavrt avatar Jul 07 '14 15:07 akavrt

@martinbonnin, any luck on your implementation? I need this so bad for a project I am working on.

nachtien avatar Jul 09 '14 19:07 nachtien

@nachtien I'll post an update when I get stuff working.

@crossle I was a bit worried to add a big dependency such as ffmpeg requiring jni and stuff but I guess if it works it'll be more efficient than java.

martinbonnin avatar Jul 10 '14 07:07 martinbonnin

ok so now I can have some video rendered except that the stream pauses/rebuffers all the time. It looks like it's coming from chunk.startTimeUs and endTimeUs that I hardcoded to 0 for now. Problem is HLS is not like smoothstreaming and I cannot know the timestamps before parsing the TS file. @ojw28 : any idea how to circumvent this ?

martinbonnin avatar Jul 11 '14 13:07 martinbonnin

Aren't there timestamps in the manifest? If there weren't, then it would be impossible to implement seeking?

ojw28 avatar Jul 11 '14 13:07 ojw28

HLS has no real 'manifest'. It has 'playlists' with the duration of each chunk in the EXTINF tag so I could use that to guess the timestamps but I am not 100% convinced because:

  • the timestamps inside the TS might not start at offset 0.
  • the chunk durations might be imprecise. I am not sure if this is a problem or not.

I'm going to try...

martinbonnin avatar Jul 11 '14 14:07 martinbonnin

Yeah. Playlists fundamentally must contain timestamps (or durations from which timestamps can be derived) for seeking to be possible. The timestamps must also not drift as you get further down the list, otherwise seeking would become inaccurate the further down the playlist you get.

If there needs to be some timestamp adjustment to the sample timestamps themselves, something similar to sampleOffsetUs in Mp4MediaChunk might do the trick, depending on what exactly is required. I'm hoping to get more up to speed with HLS in the next few weeks, and will be able to provide a slightly more informed opinion as opposed to random thoughts :).

ojw28 avatar Jul 11 '14 14:07 ojw28

Ok so at first sight this seems to work but actually the incessant rebuffering problem was somewhere else. It was due to the fact that my TSMediaChunk.read() could return false (if reading an audio sample while a video one is expected for an example). In that case, the renderer stops feeding its input buffers and exoplayer believes it needs to rebuffer. To workaround that, I now discard audio completely but this is not a long-term solution...

martinbonnin avatar Jul 11 '14 16:07 martinbonnin

+1 for HLS support.

johnluther avatar Jul 14 '14 19:07 johnluther

@martinbonnin, awesome work so far!! Do you have an ETA for when think you'll have this done?
I tried using one of our audio only HLS files and it got stuck on preparing. It might be because it is an encrypted stream, or it might be because of something else.

nachtien avatar Jul 14 '14 20:07 nachtien

@nachtien do you have a test url ?

martinbonnin avatar Jul 14 '14 20:07 martinbonnin

@martinbonnin -- It actually gets through the preparing phase, but then jumps to idle. It looks like it is throwing an index out of bounds exception on the getTrackInfo method. I tracked the issue down to the MainPlaylist file lines 55-69 (parse method). The m3u8 file we have has EXTINF:5.0 or 4.0 above every url, so its not loading anything in the playlist.

Here is the URL we are using: https://api.beatgasm.com/v1/play/4301.m3u8?type=user&type_id=2190&bitrate=64000&X-Auth-Token=d4328aa4-46e2-452f-90f5-8228dd22a54c

Thank you!

nachtien avatar Jul 14 '14 20:07 nachtien

@martinbonnin, I saw the changes you committed today. So awesome. Please let know if you want help with this... If you really think this is possible to get the audio from the URL I attached above to start streaming in under 3 seconds, I could probably dedicate some time to help or allocate some other resources to help.

nachtien avatar Jul 16 '14 20:07 nachtien