ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Extend to support raw H264 video stream in ExoPlayer

Open shen330 opened this issue 9 years ago • 2 comments

Hello,

I'm working on an application that receives raw H264 stream from a socket, decode it and display on a SurfaceView. Since the H264 stream has no need to extract, no transport protocol like RTP, it just transports from my hardware with a socket to my application.

I'd try to extend a MediaSource, a MediaPeriod, Timeline, SampleStream, Loadable, and it still not works now, cause ExoPlayer has so many class I should extend, I'm a little lost. Am I in the right way? Waiting for your reply.

Thanks.

shen330 avatar Nov 27 '17 03:11 shen330

One way to do this is to implement a DataSource that reads from the socket and an Extractor that parses the stream. Then you can use those with the provided ExtractorMediaSource by constructing it with a custom DataSourceFactory and ExtractorsFactory that return instances of your components.

Your Extractor implementation will need to split up the incoming stream into samples. If it's an Annex B bytestream you can probably just copy Ac3Extractor, make sniff return true and use an H264Reader instead of an Ac3Reader. There will be a few more details to work out, like how to set timing information on output samples (via H264Reader.packetStarted), but hopefully this is useful as a starting point.

andrewlewis avatar Nov 27 '17 08:11 andrewlewis

I have made it as you said, it works well.

Thank you so much!

shen330 avatar Dec 21 '17 03:12 shen330