鸿蒙开源组件——mp4读写创建组件

jacksky
发布于 2021-12-27 17:00
浏览
0收藏

mp4parser

本项目是基于开源项目mp4parser进行OHOS化的移植和开发的, 可以通过github地址 追踪到原项目

移植版本:release mp4parser-project-1.9.41

项目介绍

项目名称:mp4parser

所属系列:OHOS的第三方组件适配移植

功能:

  • 1.用于读取、写入和创建MP4容器的JavaAPI。
  • 2.MP4文件的合并
  • 3.音轨的相关处理
  • 4.MP4文件与音轨的部分合成处理等等

项目移植状态:完全移植

调用差异:基本没有使用差异,可以参照demo或原项目api

原项目Doc地址:https://github.com/sannies/mp4parser

编程语言:java

项目截图(涉及视频和音频文件仅供demo测试使用)

安装教程

Movie m = new Movie();
m.addTrack(h264Track);
m.addTrack(aacTrack);

方案一

建议下载开源代码并参照demo引入相关库:

//核心引入
compile project(path: ':isoparser')
compile project(path: ':muxer')
compile project(path: ':streaming')
//部分API直接使用样例
compile project(path: ':examples')


方案二

项目根目录的build.gradle中的repositories添加:
mavenCentral()

module目录的build.gralde中dependencies添加:
implementation 'com.gitee.ts_ohos:isoparser:1.0.0'
implementation 'com.gitee.ts_ohos:muxer:1.0.0'
implementation 'com.gitee.ts_ohos:streaming:1.0.0'

混合音频/视频

API使用流程很简单:

1 将每个原始格式文件包装到适当的Track对象中

H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(new File(filesDir,names[1])));
AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(new File(filesDir, names[0])));

2 将这些Track对象添加到Movie对象中

Movie m = new Movie();
m.addTrack(h264Track);
m.addTrack(aacTrack);

3 用MP4Builder创建容器

Mp4Builder builder = new DefaultMp4Builder();
Container c = builder.build(m);

4 将容器写入适当的接收器中

c.writeContainer(new FileOutputStream(outFilePath).getChannel());

更多实例请参考entry中给定的示例

版本迭代

  • v1.0 项目初次提交

版本和许可信息

Apache License Version 2.0, January 2004 http://www.apache.org/licenses

https://gitee.com/ts_ohos/mp4parser_hos/blob/master/LICENSE

mp4parser_hos-master.zip 282.95M 8次下载
已于2021-12-27 17:00:22修改
收藏
回复
举报
回复
    相关推荐