how to decode the byte array (.h264 format) in to video in android?

我的梦境 提交于 2019-12-02 13:28:38

问题


In My App, I have to decode the bytearray (that is in .h264 format) in to video and the byte array coming from live steaming. The code is below:

static final int VIDEO_BUF_SIZE = 100000;
static final int FRAME_INFO_SIZE = 16;
byte[] frameInfo = new byte[FRAME_INFO_SIZE];
byte[] videoBuffer = new byte[VIDEO_BUF_SIZE];

File SDFile = android.os.Environment.getExternalStorageDirectory();

File destDir = new File(SDFile.getAbsolutePath() + "/test.h264");


//avRecvFrameData returns the length of the frame and stores it in ret.
int ret = av.avRecvFrameData(avIndex, videoBuffer,
                        VIDEO_BUF_SIZE, frameInfo, FRAME_INFO_SIZE,
                        frameNumber);

fos=new FileOutputStream(destDir,true);
                fos.write(videoBuffer, 0, ret);
                fos.close();

So what can I do now?

Thanks to All.


回答1:


I have used javacv library for performing decoding of H.264 live stream. Its quite nice library. here is the my question and its answer, it may help you. If you perform similar steps as i have performed, it will decode the video and you will be able to play it on device.



来源:https://stackoverflow.com/questions/28123759/how-to-decode-the-byte-array-h264-format-in-to-video-in-android

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