简体   繁体   English

Android Mediacodec在不同平台(Android,iOS,Web)上对h264进行编码和解码

[英]Android Mediacodec encode h264 and decode in different platforms (Android,iOS, Web)

I am developing an Android app (min sdk=21) which required to stream real-time video(capture from an Android device camera) to different platform(Android/IOS/web). 我正在开发一个Android应用程序(min sdk=21) ,该应用程序需要将实时视频(从Android设备的摄像头捕获(min sdk=21)流式传输到不同的平台(Android / IOS / web)。
I decided to use Media codec to encode the video to h.264 and send the raw data by TCP socket to other devices. 我决定使用Media编解码器将视频编码为h.264,然后通过TCP socket将原始数据发送到其他设备。

I created an input surface from Media codec and I set the color format to MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface . 我从Media编解码器创建了一个输入表面,并将颜色格式设置为MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface

Android devices should be able to decode this raw data, but is it possible to decode this raw data in iOS or Web if I choose this color format? Android设备应该能够解码该原始数据,但是如果我选择这种颜色格式,是否可以在iOS或Web中解码该原始数据

Yes, the input color type shouldn't matter. 是的,输入颜色类型无关紧要。 Even if you use COLOR_FormatSurface , it still is encoded as a normal YUV 4:2:0 video as if you'd use the other, non-surface color formats. 即使您使用COLOR_FormatSurface ,它仍然被编码为普通的YUV 4:2:0视频,就像您将使用其他非表面颜色格式一样。

If you'd manually choose a more uncommon color format like YUV 4:4:4 (when not using surface input), the encoder could either choose to actually downsample this into YUV 4:2:0 (and all decoders would support it) or keep it as is and encode into the more uncommon variants of H264, which not all decoders might be able to decode. 如果您手动选择一种更不常见的颜色格式,例如YUV 4:4:4(当不使用表面输入时),编码器可以选择将其实际降采样为YUV 4:2:0(并且所有解码器都支持)或保持原样并将其编码为H264更为罕见的变体,并非所有解码器都能够解码。

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

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