如何去code中的字节数组(.h264格式)的视频在android系统? [英] how to decode the byte array(.h264 format) in to video in android?

查看:479
本文介绍了如何去code中的字节数组(.h264格式)的视频在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我在视频脱code的ByteArray(即在.h264格式),并从现场steaming.The code未来的ByteArray低于

 静态最终诠释VIDEO_BUF_SIZE = 100000;
 静态最终诠释FRAME_INFO_SIZE = 16;
 字节[] = frameInfo新的字节[FRAME_INFO_SIZE]
 字节[] = videoBuffer新的字节[VIDEO_BUF_SIZE]文件SDFile = android.os.Environment.getExternalStorageDirectory();文件DESTDIR =新的文件(SDFile.getAbsolutePath()+/test.h264);
// avRecvFrameData返回保留的帧,并将其存储的长度。
INT RET = av.avRecvFrameData(avIndex,videoBuffer,
                        VIDEO_BUF_SIZE,frameInfo,FRAME_INFO_SIZE,
                        frameNumber的);FOS =新的FileOutputStream(DESTDIR,真);
                fos.write(videoBuffer,0,RET);
                fos.close();那么,我可以现在就做。谢谢大家。


解决方案

我已经使用 javacv执行H.264实时流的解码库。其相当不错的图书馆。
这里是我的<一个href=\"http://stackoverflow.com/questions/22497540/javacv-decoding-h-264-live-stream-coming-from-red5-server-on-android-device\">question和它的答案,它可以帮助你。如果执行同样的步骤,因为我已经完成,它会去code的视频,你将能够发挥它的设备。

In My App,I have to decode the bytearray(that is in .h264 format) in to video and the bytearray 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.

解决方案

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.

这篇关于如何去code中的字节数组(.h264格式)的视频在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆