java h264 aac合成_Android MP4Coder H264和AAC合成MP4视频库

转载自:http://blog.csdn.net/jay100500/article/details/52957837

遵循:BY-NC-SA

署名-非商业性使用-相同方式共享 4.0协议

作者:谭东

时间:2016年10月28日

环境:Windows 7

Mp4Coder,H264和AAC合成MP4视频库

Github地址:https://github.com/zuichu/Mp4Coder

主要支持功能:

H264和AAC合成MP4视频文件

MP4文件拼接成MP4视频文件

AAC文件拼接成AAC音频文件

MP4文件裁剪、剪切

AAC文件裁剪、剪切

MP4文件提取分离AAC音频文件

MP4文件提取分离H264 文件

H264和网络流AAC文件合成MP4视频文件

其他更多功能和用法参考examples里的例子用法…

用法:

try {

H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(Environment.getExternalStorageDirectory() + "/imgBufFrame.h264"));

AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(Environment.getExternalStorageDirectory() + "/test.aac"));

Movie movie = new Movie();

movie.addTrack(h264Track);

movie.addTrack(aacTrack);

Container mp4file = new DefaultMp4Builder().build(movie);

FileChannel fc = new FileOutputStream(new File(Environment.getExternalStorageDirectory() + "/encode.mp4")).getChannel();

mp4file.writeContainer(fc);

fc.close();

} catch (IOException e) {

e.printStackTrace();

}

也可以根据实际情况自定义帧率:

H264TrackImpl h264Track1 = new H264TrackImpl(new FileDataSourceImpl(Environment.getExternalStorageDirectory() + "/video.h264"), "eng", 15000, 1001);

//给出源码解释:

/**

* Creates a new Track object from a raw H264 source (DataSource dataSource1).

* Whenever the timescale and frametick are set to negative value (e.g. -1) the H264TrackImpl

* tries to detect the frame rate.

* Typically values for timescale and frametick are:

*

*

23.976 FPS: timescale = 24000; frametick = 1001

*

25 FPS: timescale = 25; frametick = 1

*

29.97 FPS: timescale = 30000; frametick = 1001

*

30 FPS: timescale = 30; frametick = 1

*

*

* @param dataSource the source file of the H264 samples

* @param lang language of the movie (in doubt: use "eng")

* @param timescale number of time units (ticks) in one second

* @param frametick number of time units (ticks) that pass while showing exactly one frame

* @throws IOException in case of problems whiel reading from the DataSource

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值