简体   繁体   English

如何在Android视频中解码字节数组(.h264格式)?

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

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. 在“我的应用程序”中,我必须将字节数组(.h264格式)解码为视频,然后将字节数组从实时流传输中解码出来。 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. 谢谢大家。

I have used javacv library for performing decoding of H.264 live stream. 我已经使用javacv库执行H.264实时流的解码。 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. 如果您执行与我执行的步骤类似的操作,它将解码视频,并且可以在设备上播放。

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

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