Native window queueBuffer function not rendering output from Stagefright decoder

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:47:54
mathieujofis

I ended up solving this issue by using the Java low level APIs instead. I set up a native read_frame function that parses video frames using FFmpeg. I call this function in a separate Java decoder thread, which returns a new frame of data to be decoded by MediaCodec. It was very straight forward to render this way-- just pass MediaCodec the surface.

Alternatively, I could have used MediaExtractor, but FFmpeg had some other functionality that I needed.

Just in case the problem has not been solved! I have had the same problem, and found the problem pure accidentally!

@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { NativeLib.init(holder.getSurface(), width, height); }

you have to allocate the frame buffer to a dimension dividable by 16, which is the macro block size. Otherwise, the graphic buffer is not large enough for decoding output. H264 encoder has internal little large frame size for encoding process if the provided video sequence has the width or height not aligned to macro block. Just apply following: width = 16 * (width + 15)/16; height = 16 * (height + 15)/16;

You need call native_window_set_scaling_mode(mNativeWindow->get(), NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!