这是我的第一篇文章,所以请耐心等待。
我正在尝试将原始 h264 视频播放到 Android 应用程序中的 Surface 对象上。我在 HTC 上使用 android 5.0.1。在阅读了 android 文档后,我发现我需要使用 MediaCodec 对象来解码原始字节,然后将它们释放到 Surface。我已经倾注了大量其他问题和文档,但还没有找到我看似非常简单的问题的答案。这是我的代码片段:
@Override
public void surfaceCreated(SurfaceHolder surfHolder) {
try {
String codecType = "video/avc";
MediaFormat mf = MediaFormat.createVideoFormat(codecType, 45 ,45);
mc = MediaCodec.createByCodecName(codecType);
mc.configure(mf, surfHolder.getSurface(), null, 0);
mc.setCallback(vcb);
mc.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当它尝试按名称创建编解码器时遇到了问题,并且出现此错误:
08-26 18:09:02.054 9132-9132/com.james.firstclient I/InputMethodManager? [startInputInner] EditorInfo { packageName=com.james.firstclient, inputType=0x20001, imeOptions=0x48000005, privateImeOptions=null }, windowGainingFocus=android.view.ViewRootImpl$W@37cf53de, mServedView=android.widget.EditText{2a8889bf VFED..CL .F....I. 48,177-1032,290 #7f080001 app:id/hostText}, mServedInputConnectionWrapper=android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@3ed5088c
08-26 18:09:03.964 9132-9292/com.james.firstclient D/libc? [NET] android_getaddrinfofornet+,hn 12(0x3139322e313638),sn(),hints(known),family …Run Code Online (Sandbox Code Playgroud)