使用 Mediacodec 和 Motorola mobile 编码音频的问题
Issues encoding audio with Mediacodec and Motorola mobile
我已经能够实现 video/audio 解码器和编码器。在我的三星 S3 上,一切正常。然后我部署到三星,我有一些旋转问题我已经修复,但最终编码的视频没有音频。
当我停止 mediamuxer 时,我得到以下日志:
01-29 12:35:26.372 I/MPEG4Writer(23222): Received total/0-length (27/0) buffers and encoded 27 frames. - video
01-29 12:35:26.374 D/MPEG4Writer(23222): Stopping Audio track
01-29 12:35:26.376 I/MPEG4Writer(23222): Received total/0-length (4/82) buffers and encoded 4 frames. - audio
01-29 12:35:26.376 I/MPEG4Writer(23222): Audio track drift time: 0 us
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Audio track source
01-29 12:35:26.377 D/MPEG4Writer(23222): Audio track stopped
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Video track
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Video track source
01-29 12:35:26.377 D/MPEG4Writer(23222): Video track stopped
01-29 12:35:26.378 D/MPEG4Writer(23222): Stopping Audio track
01-29 12:35:26.378 D/MPEG4Writer(23222): Duration from tracks range is [80000, 1772500] us
01-29 12:35:26.378 D/MPEG4Writer(23222): Stopping writer thread
01-29 12:35:26.379 D/MPEG4Writer(23222): 1 chunks are written in the last batch
01-29 12:35:26.380 D/MPEG4Writer(23222): Writer thread stopped
01-29 12:35:30.212 D/MPEG4Writer(23222): Stopping Video track
01-29 12:35:30.212 D/MPEG4Writer(23222): Stopping Audio track
我猜是与 4/82 缓冲区有关并且只编码了 4 帧。我已经将我从解码器获得的所有缓冲区写入复用器,我认为有 82 个缓冲区。 presentationTime 和标志与我从解码器获得的相同。
正如我所说,这段代码适用于我的三星 S3。你有什么想法是我的问题吗?可能是比特率?
谢谢。
我发现byteBuffers在某些情况下得到了Position=Limit,所以,我不得不设置Position(info.Offset), Limit(info.Offset+info.Size),就像在许多示例中一样(例如 grafika)。因此,我一直在编码 0 长度的缓冲区,但只有 4 个数据。没有它,这在我的三星手机上运行良好,但在摩托罗拉手机上却不行。
谢谢
我已经能够实现 video/audio 解码器和编码器。在我的三星 S3 上,一切正常。然后我部署到三星,我有一些旋转问题我已经修复,但最终编码的视频没有音频。 当我停止 mediamuxer 时,我得到以下日志:
01-29 12:35:26.372 I/MPEG4Writer(23222): Received total/0-length (27/0) buffers and encoded 27 frames. - video
01-29 12:35:26.374 D/MPEG4Writer(23222): Stopping Audio track
01-29 12:35:26.376 I/MPEG4Writer(23222): Received total/0-length (4/82) buffers and encoded 4 frames. - audio
01-29 12:35:26.376 I/MPEG4Writer(23222): Audio track drift time: 0 us
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Audio track source
01-29 12:35:26.377 D/MPEG4Writer(23222): Audio track stopped
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Video track
01-29 12:35:26.377 D/MPEG4Writer(23222): Stopping Video track source
01-29 12:35:26.377 D/MPEG4Writer(23222): Video track stopped
01-29 12:35:26.378 D/MPEG4Writer(23222): Stopping Audio track
01-29 12:35:26.378 D/MPEG4Writer(23222): Duration from tracks range is [80000, 1772500] us
01-29 12:35:26.378 D/MPEG4Writer(23222): Stopping writer thread
01-29 12:35:26.379 D/MPEG4Writer(23222): 1 chunks are written in the last batch
01-29 12:35:26.380 D/MPEG4Writer(23222): Writer thread stopped
01-29 12:35:30.212 D/MPEG4Writer(23222): Stopping Video track
01-29 12:35:30.212 D/MPEG4Writer(23222): Stopping Audio track
我猜是与 4/82 缓冲区有关并且只编码了 4 帧。我已经将我从解码器获得的所有缓冲区写入复用器,我认为有 82 个缓冲区。 presentationTime 和标志与我从解码器获得的相同。 正如我所说,这段代码适用于我的三星 S3。你有什么想法是我的问题吗?可能是比特率? 谢谢。
我发现byteBuffers在某些情况下得到了Position=Limit,所以,我不得不设置Position(info.Offset), Limit(info.Offset+info.Size),就像在许多示例中一样(例如 grafika)。因此,我一直在编码 0 长度的缓冲区,但只有 4 个数据。没有它,这在我的三星手机上运行良好,但在摩托罗拉手机上却不行。 谢谢