如何解决camera2 api -> mediaCodec -> mediaMuxer -> mp4 文件
我正在尝试获取 mp4 文件。我使用 camera2 api 拍摄视频,并可以使用 MediaCodec 将其保存为 avc 文件。但我不明白如何重做这段代码,以便使用 MediaMuxer 编码成 mp4 文件。对不起我的英语,这是通过翻译翻译的
NotificationListener<ScrollEndNotification>(
child: ListView(
controller: _scrollController,children: ...
),onNotification: (notification) {
print(_scrollController.position.pixels);
},),
在初始化 MediaCodec 后,我录制了视频:
private class EncoderCallback : MediaCodec.Callback() {
override fun onInputBufferAvailable(codec: MediaCodec,index: Int) {
}
override fun onOutputBufferAvailable(
codec: MediaCodec,index2: Int,info: MediaCodec.BufferInfo
) {
outPutByteBuffer = mCodec!!.getOutputBuffer(index2)
val outDate = ByteArray(info.size)
outPutByteBuffer!![outDate]
try {
Log.i("EncoderCallBack"," outDate.length : " + outDate.size)
outputStream!!.write(outDate,outDate.size)
} catch (e: IOException) {
e.printStackTrace()
}
mCodec!!.releaseOutputBuffer(index2,false)
}
override fun onError(codec: MediaCodec,e: MediaCodec.CodecException) {
Log.i("EncoderCallBack","Error: $e")
}
override fun onOutputFormatChanged(codec: MediaCodec,format: MediaFormat) {
Log.i("EncoderCallBack","encoder output format changed: $format")
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。