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.
我被要求在android中显示视频流(流不是来自HTTP),流是原始H.264,它是在PC中记录和编码的,我通过WIFI得到它。
When I get the stream, can use the MediaCodec decoder to decode the stream and display it?
当我得到流时,可以使用MediaCodec解码器解码流并显示它吗?
2 个解决方案
#1
1
Yes. Configure the MediaCodec as a "video/avc" decoder, and pass an output Surface to the configure() call.
是。将MediaCodec配置为“video / avc”解码器,并将输出Surface传递给configure()调用。
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.
MediaCodec API非常低级,并且没有大量示例代码可用。可能更容易使用MediaPlayer。
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.
更新:现在有一堆示例代码。其中大部分都使用了Android 4.3(API 18)功能,但如果您不需要MediaMuxer或Surface输入到MediaCodec,它将在API 16上运行。
#1
1
Yes. Configure the MediaCodec as a "video/avc" decoder, and pass an output Surface to the configure() call.
是。将MediaCodec配置为“video / avc”解码器,并将输出Surface传递给configure()调用。
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.
MediaCodec API非常低级,并且没有大量示例代码可用。可能更容易使用MediaPlayer。
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.
更新:现在有一堆示例代码。其中大部分都使用了Android 4.3(API 18)功能,但如果您不需要MediaMuxer或Surface输入到MediaCodec,它将在API 16上运行。