我用mediacodec解码视频后给surface显示 我怎样能拿到这个显示的图像 保存到本地
因为这种方式不是给surface开线程去画图像了 直接保存图像的话会是一张黑图 只能从解码器传的图像入手 求高手知道
ByteBuffer buffer = outputBuffers[outIndex];
buffer.position(info.offset);
buffer.limit(info.offset + info.size);
byte[] ba = new byte[buffer.remaining()]; //converting bytebuffer to byte array
buffer.get(ba);
Log.e(TAG, "ba = " + ba.length + "");
YuvImage yuvimage = new YuvImage(ba, ImageFormat.NV21, 1280, 720, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, 1280, 720), 100, baos);
byte[] jdata = baos.toByteArray();
final Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length);
没搞过这方面的。采纳我下把。。