这需要太长的时间使用mp4parser到混流H264成MP4文件 [英] It takes too long time to mux h264 into mp4 file using mp4parser

查看:3024
本文介绍了这需要太长的时间使用mp4parser到混流H264成MP4文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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.

推荐答案

试用谷歌的 ExoPlayer库虽然我相信MP4提取仅在Dev分支可用,请参见<一个href=\"https://github.com/google/ExoPlayer/tree/dev/demo/src/main/java/com/google/android/exoplayer/demo\"相对=nofollow>演示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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆