Exoplayer: Extend to support raw H264 video stream in ExoPlayer

Created on 27 Nov 2017  路  2Comments  路  Source: google/ExoPlayer

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.

question

Most helpful comment

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.

All 2 comments

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.

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

Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KenendZ picture KenendZ  路  3Comments

orcunkobal picture orcunkobal  路  3Comments

Ufosek picture Ufosek  路  3Comments

mkaflowski picture mkaflowski  路  3Comments

R00We picture R00We  路  3Comments