1

我正在使用 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 的真正效率?非常感谢。

4

2 回答 2

0

尝试 Google 的ExoPlayer 库,尽管我相信 MP4 提取仅在 dev 分支上可用,请参阅此处的演示代码

于 2015-04-25T07:03:46.033 回答
0

给出正确的H264文件路径,然后它将调试。

于 2015-04-21T12:06:16.403 回答