我正在使用 mp4parser 将 h264 文件和 aac 文件复用到 mp4 文件中。代码如下。
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 分钟:
DataSource videoFile = new FileDataSourceImpl(h264Path);
我的示例 h264 视频文件持续时间约为 20 秒,大小为 3MB(比特率约为 178KB)。它由 MediaCodec 生成。这在生产环境中确实不可接受。我的代码有什么错误吗?还是 mp4parser 的真正效率?非常感谢。