【问题标题】:how to decode the byte array (.h264 format) in to video in android?如何在android中将字节数组(.h264格式)解码为视频?
【发布时间】:2019-02-05 01:14:39
【问题描述】:

在我的应用程序中,我必须将字节数组(即 .h264 格式)解码为视频和来自直播的字节数组。代码如下:

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();

那我现在能做什么?

谢谢大家。

【问题讨论】:

  • 你解决了吗?

标签: android video-streaming decode


【解决方案1】:

我使用javacv 库来执行 H.264 直播流的解码。它相当不错的图书馆。 这是我的question 及其答案,它可能会对您有所帮助。如果您执行与我执行的类似步骤,它将解码视频,您将能够在设备上播放它。

【讨论】:

  • 如何在 android 中为 windows 7 构建 ffmpeg 库?
  • 声音也来了吗?
  • 在直播中,音视频帧是不同的,所以需要分别截取帧,并且要知道音频的媒体格式是什么。因此,您可以使用正确的解码器对语音进行解码
  • 直到我们没有得到任何关于音频的数据。ffmpeg库是解码数据的唯一解决方案吗。
  • 我不能保证唯一的解决方案,但 ffmepeg 是处理视频和音频转换的最广泛使用的选择
猜你喜欢
  • 1970-01-01
  • 2017-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-07
  • 2014-01-03
  • 1970-01-01
  • 2015-09-29
相关资源
最近更新 更多