ljfxmu
ljfxmu

Reputation: 113

How to use MediaCodec class to decode H.264 streams

I have been asked to display a video stream (the stream is not from HTTP)in android, the stream is raw H.264 which is Recorded and encoded in a PC ,and I get it through WIFI.

When I get the stream, can use the MediaCodec decoder to decode the stream and display it?

Upvotes: 5

Views: 6569

Answers (2)

fadden
fadden

Reputation: 52353

Yes. Configure the MediaCodec as a "video/avc" decoder, and pass an output Surface to the configure() call.

The MediaCodec API is pretty low-level, and there's not a lot of sample code available. It might be easier to use MediaPlayer instead.

Update: There's now a bunch of sample code here. Most of it makes use of Android 4.3 (API 18) features, but if you don't need MediaMuxer or Surface input to MediaCodec it'll work on API 16.

Upvotes: 2

Arun C
Arun C

Reputation: 9035

See the Video Encoding Recommendations here

Upvotes: 0

Related Questions