It takes too long time to mux h264 into mp4 file using mp4parser

怎甘沉沦 提交于 2019-12-23 04:50:38

问题


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();

But when I debug it,it takes about 4 mins on this step:

    DataSource videoFile = new FileDataSourceImpl(h264Path);

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.


回答1:


Try Google's ExoPlayer library though I believe MP4 extraction is only available on the dev branch, see demo code here.




回答2:


Give the right path of H264 file, then it will debug.



来源:https://stackoverflow.com/questions/26394428/it-takes-too-long-time-to-mux-h264-into-mp4-file-using-mp4parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!