5

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?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
ljfxmu
  • 113
  • 2
  • 7

2 Answers2

2

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.

fadden
  • 51,356
  • 5
  • 116
  • 166
  • But,I cannot find a way to deal with H.264 stream with MediaPlayer .any ideals? – ljfxmu Apr 21 '13 at 07:38
  • 1
    Let me back up a step. What exactly is the format -- elementary stream, PES, ...? MediaCodec accepts elementary stream data, but it doesn't accept it was a *stream*; it takes a series of "access units", so if it's an elementary stream you need to preserve or recover the "packet" boundaries. You also need to ensure that the first buffer passed in has the codec info it wants, which isn't currently documented. Your best bet may be to convert the stream on the PC side to something MediaPlayer can handle. – fadden Apr 22 '13 at 17:53
0

See the Video Encoding Recommendations here

Arun C
  • 9,035
  • 2
  • 28
  • 42