问题描述
我使用mp4parser到混流H264文件和AAC文件转换成MP4 file.And的code作为初级讲座。
I'm using mp4parser to mux h264 file and aac file into mp4 file.And the code is as belows.
String h264Path = "path to my h264 file, generated by Android MediaCodec";
DataSource videoFile = new FileDataSourceImpl(h264Path);
H264TrackImpl h264Track = new H264TrackImpl(videoFile, "eng", 5, 1); // 5fps. you can play with timescale and timetick to get non integer fps, 23.967 is 24000/1001
Movie movie = new Movie();
movie.addTrack(h264Track);
Container out = new DefaultMp4Builder().build(movie);
FileOutputStream fos = new FileOutputStream(new File("path to my generated file.mp4"));
out.writeContainer(fos.getChannel());
fos.close();
但是,当我调试它,它需要在这一步大约4分钟:
But when I debug it,it takes about 4 mins on this step:
DataSource videoFile = new FileDataSourceImpl(h264Path);
和我的样本H264视频文件在持续时间和3MB约20秒的大小(约178KB的比特率)。它的通过媒体codec.That产生的真正的生产环境中不能接受的。有没有在我的code一些错误呢?抑或是mp4parser真正的效率?非常感谢。
And my sample h264 video file is about 20 seconds in duration and 3MB in size(about 178KB in bitrate).It's generated by MediaCodec.That's really not acceptable in production environment. Is there some mistake in my code?Or is it the real efficiency of mp4parser?Very Thanks.
推荐答案
试用谷歌的虽然我相信MP4提取仅在Dev分支可用,请参见演示code这里。
Try Google's ExoPlayer library though I believe MP4 extraction is only available on the dev branch, see demo code here.
这篇关于这需要太长的时间使用mp4parser到混流H264成MP4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!