简体   繁体   English

媒体编解码器解码器和播放

[英]Media codec decoder and playback

I'm trying to show live preview from one android device to another. 我正在尝试显示从一个Android设备到另一个的实时预览。 Here is what I did, 这就是我所做的

Sender : 1.Camera frame(YUV) -> 2.Mediacodec (encode h264 byte[])-> 3.MediaMuxer-> 4.mp4 发件人:1.摄像机帧(YUV)-> 2.Mediacodec(编码h264字节[])-> 3.MediaMuxer-> 4.mp4

I'm sending output of media encoder via socket connection. 我正在通过套接字连接发送媒体编码器的输出。

Receiver : 5.byte[] via socket ->6. 接收器:5.byte []通过套接字-> 6。 Mediacodec (decoder) -> 7.Play. Mediacodec(解码器)-> 7.Play。

Till step 5 everything works fine. 直到步骤5一切正常。

However I'm not able to decode the byte[]. 但是,我无法解码byte []。 What is missing here? 这里缺少什么? I guess, I'm not able to send(don't know how to send) sps and pps properly! 我猜想,我无法正确发送(不知道如何发送)sps和pps! also how to test that what I'm sending is correct data? 还有如何测试我发送的是正确的数据?

Thanks. 谢谢。

You are muxing to mp4 (container format) the encoded h264 video. 您正在将编码的h264视频混合到mp4(容器格式)。 However, on the decoding side, you are not using demuxer (or parser/splitter). 但是,在解码方面,您没有使用解复用器(或解析器/分离器)。 Media codec decoder can take elementary video not any container format. 媒体编解码器可以采用基本视频,而不能采用任何容器格式。 Use mediaextractor to demux in android. 使用mediaextractor在Android中解复用。 ( https://developer.android.com/reference/android/media/MediaExtractor.html ) https://developer.android.com/reference/android/media/MediaExtractor.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM