使用MP4V2分析MP4文件

2024-06-07 22:48
文章标签 分析 使用 mp4 mp4v2

本文主要是介绍使用MP4V2分析MP4文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、下载链接

http://download.csdn.net/download/u011425939/10149476

二、解压源码

得到 libmp4目录

三、进入test目录使用帮助

root@ubuntu16:/work/my/code/mp4/mp4v2/libmp4/test# ./mp4_tool -h
usage: mp4_tool <options> mp4_file
Options: 
-h, -?, --help            List the more commonly used options
-a, --add <string>        Add a track to the mp4 file,(Todo) 
-e, --extract <integer>   Extract a track from the mp4 file 
-i, --info <integer>      List tracks info from the mp4 file 
-r, --show_rap <integer>  Show one track random access point 
-v, --verbosity <integer>  Control amount of the log 
root@ubuntu16:/work/my/code/mp4/mp4v2/libmp4/test# 

四、输出一个MP4文件的信息

root@ubuntu16:/work/my/code/mp4/mp4v2/libmp4/test# ./mp4_tool -i Showreel.mp4Movie info Timescale: 600, duration: 71680000, creation_time: 3377085776, modification_time: 3377172176 Number of tracks: 2 Track # 0 Info: - Track_id: 1, is_track_enable: 1, duration: 42960 
Media info: timescale: 25000, media_duration: 71600000, type: vide, sub type: avc1, 1790 samples 
video info: w:1280 h720
max sample size: 74216 
nr of samples: 1790 
media sub type: 1635148593 Track # 1 Info: - Track_id: 2, is_track_enable: 1, duration: 43008 
Media info: timescale: 44100, media_duration: 71680000, type: soun, sub type: mp4a, 3087samples 
audio info: sample_rate: 44100, channels: 2, bits_per_sample: 16

五、lib_mp4.h中的 api 接口 使用它们可以得到相应的信息。


1、uint8_t mp4_probe(const char *file_name );/* open a mp4 file and get the handle */
2、mp4_handle_t* mp4_open( const char* file_name, int mode );/* close the mp4 handle */
3、void mp4_close( mp4_handle_t *handle );4、void mp4_set_verbosity( uint32_t verbosity );5、uint32_t mp4_get_verbosity( void );/*return the timescale of the movie, 0 if error*/
6、uint32_t mp4_get_timescale(mp4_handle_t *handle);/*return the duration of the movie, 0 if error*/
7、uint64_t mp4_get_duration(mp4_handle_t *handle);/*return the creation info of the movie*/
8、int mp4_get_creation_time(mp4_handle_t *handle, uint64_t *creation_time,uint64_t *modification_time);
/*return the number of tracks in the movie*/
9、uint32_t mp4_get_nr_of_tracks( mp4_handle_t *handle );/*** return the track id of track index n, or 0 if error* the valid index range is [0, nr_track-1]
*/
10、uint32_t mp4_get_track_id(mp4_handle_t *handle, uint32_t index);/*return the track number of the track of specified ID, or 0 if error*/
11、uint32_t mp4_get_track_idx_by_id(mp4_handle_t *handle, uint32_t track_id);/*gets the enable flag of a track 0: NO, 1: YES, 2: error*/
12、uint8_t mp4_is_track_enabled(mp4_handle_t *handle, uint32_t track_id);/* determines if the track is encrypted 0: NO, 1: YES, 2: error*/
13、uint8_t mp4_is_track_encrypted(mp4_handle_t *handle, uint32_t track_id);/*get the track duration return 0 if bad param*/
14、uint64_t mp4_get_track_duration(mp4_handle_t *handle, uint32_t track_id);/*return the media type FOUR CHAR code type of the media(soun, vide, hint)*/
15、uint32_t mp4_get_media_type(mp4_handle_t *handle, uint32_t track_id);/*return the media sub type FOUR CHAR code type of the media(mp4a, mp4v, avc1...)*/
16、uint32_t mp4_get_media_sub_type(mp4_handle_t *handle, uint32_t track_id);/* get esds decconfigDescr info, or -1 if esd is NULL */
17、int mp4_get_esds_dec_config_info(mp4_handle_t *handle, uint32_t track_id,uint8_t *object_type_ind, uint8_t *stream_type,uint8_t *up_stream, uint32_t *buf_size_db,uint32_t *max_bitrate, uint32_t *avg_bitrate );/* get esds decConfigDescr decSpecificInfo */
18、int mp4_get_esds_dec_specific_info(mp4_handle_t *handle, uint32_t track_id,uint8_t**config, uint32_t* config_size );/*get the timescale of media*/
19、uint32_t mp4_get_media_timescale(mp4_handle_t *handle, uint32_t track_id);/*get duration of the media(without edit) */
20、uint64_t mp4_get_media_duration(mp4_handle_t *handle, uint32_t track_id);/*get width, height of the given visual sample desc
return -1 if not a visual track */
21、int mp4_get_visual_info(mp4_handle_t *handle, uint32_t track_id,uint32_t *width, uint32_t *height);/*get samplerate, channels and bps, version of the given audio trackreturn -1 if not a audio track*/
22、int mp4_get_audio_info(mp4_handle_t *handle, uint32_t track_id,uint32_t *sample_rate, uint32_t *channels,uint8_t *bits_per_sample, uint8_t *version );/*return the numbers of samples */
23、uint32_t mp4_get_nr_of_samples(mp4_handle_t *handle,uint32_t track_id);/*return the max sample size of the track */
24、uint32_t mp4_get_max_sample_size(mp4_handle_t *handle,uint32_t track_id);/*return the sample size of the track sample, or 0 if error */
25、uint32_t mp4_get_sample_size(mp4_handle_t *handle,uint32_t track_id, uint32_t sample_id);/* return sample id by the time */
26、uint32_t mp4_get_sample_from_time(mp4_handle_t *handle, uint32_t track_id,uint64_t when, uint8_t search_mode );/* get sample time, it's dts */
27、uint64_t mp4_get_sample_dts(mp4_handle_t *handle, uint32_t track_id, uint32_t sample_id );/* get sample duration in media time scale*/
28、uint64_t mp4_get_sample_duration(mp4_handle_t *handle, uint32_t track_id, uint32_t sample_id );/* get avc decoder cfg info, memory is allocate and free by library, return <0 if error  */
29、int mp4_get_track_h264_seq_pic_headers(mp4_handle_t *handle, uint32_t track_id,uint8_t *nr_of_seq_hdr,char ***seq_hdr,uint16_t **seq_hdr_size,uint8_t *nr_of_pic_hdr,char ***pic_hdr,uint16_t **pic_hdr_size);/* get avc decConfig info  */
30、int mp4_get_track_h264_dec_config_info(mp4_handle_t *handle, uint32_t track_id,uint8_t *nalu_size, uint8_t *cfg_ver,uint8_t *profile_ind, uint8_t *profile_comp,uint8_t *level_ind );/* read a sample by sample id, return < 0 if error */
31、int mp4_read_sample( mp4_handle_t *handle, uint32_t track_id, uint32_t sample_id,char *buf, uint32_t* size,uint64_t *DTS, uint64_t *CTS,uint64_t *duration_time, uint8_t *is_sync );/* read a sample by given a desired decoding time IN MEDIA TIME SCALE, return< 0 if error */
32、int mp4_read_sample_from_time( mp4_handle_t *handle, uint32_t track_id, uint64_t when,uint8_t search_mode,char *buf, uint32_t* size,uint64_t *DTS, uint64_t *CTS,uint64_t *duration_time );/* convert FOURCC to string */
33、int mp4_fourcc_to_str(uint32_t type, char *str, int str_len);








这篇关于使用MP4V2分析MP4文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1040518

相关文章

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

Python中注释使用方法举例详解

《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

Go语言数据库编程GORM 的基本使用详解

《Go语言数据库编程GORM的基本使用详解》GORM是Go语言流行的ORM框架,封装database/sql,支持自动迁移、关联、事务等,提供CRUD、条件查询、钩子函数、日志等功能,简化数据库操作... 目录一、安装与初始化1. 安装 GORM 及数据库驱动2. 建立数据库连接二、定义模型结构体三、自动迁

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹

MySQL中的表连接原理分析

《MySQL中的表连接原理分析》:本文主要介绍MySQL中的表连接原理分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、背景2、环境3、表连接原理【1】驱动表和被驱动表【2】内连接【3】外连接【4编程】嵌套循环连接【5】join buffer4、总结1、背景

Spring 框架之Springfox使用详解

《Spring框架之Springfox使用详解》Springfox是Spring框架的API文档工具,集成Swagger规范,自动生成文档并支持多语言/版本,模块化设计便于扩展,但存在版本兼容性、性... 目录核心功能工作原理模块化设计使用示例注意事项优缺点优点缺点总结适用场景建议总结Springfox 是

嵌入式数据库SQLite 3配置使用讲解

《嵌入式数据库SQLite3配置使用讲解》本文强调嵌入式项目中SQLite3数据库的重要性,因其零配置、轻量级、跨平台及事务处理特性,可保障数据溯源与责任明确,详细讲解安装配置、基础语法及SQLit... 目录0、惨痛教训1、SQLite3环境配置(1)、下载安装SQLite库(2)、解压下载的文件(3)、

使用Python绘制3D堆叠条形图全解析

《使用Python绘制3D堆叠条形图全解析》在数据可视化的工具箱里,3D图表总能带来眼前一亮的效果,本文就来和大家聊聊如何使用Python实现绘制3D堆叠条形图,感兴趣的小伙伴可以了解下... 目录为什么选择 3D 堆叠条形图代码实现:从数据到 3D 世界的搭建核心代码逐行解析细节优化应用场景:3D 堆叠图

Springboot如何正确使用AOP问题

《Springboot如何正确使用AOP问题》:本文主要介绍Springboot如何正确使用AOP问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录​一、AOP概念二、切点表达式​execution表达式案例三、AOP通知四、springboot中使用AOP导出

Navicat数据表的数据添加,删除及使用sql完成数据的添加过程

《Navicat数据表的数据添加,删除及使用sql完成数据的添加过程》:本文主要介绍Navicat数据表的数据添加,删除及使用sql完成数据的添加过程,具有很好的参考价值,希望对大家有所帮助,如有... 目录Navicat数据表数据添加,删除及使用sql完成数据添加选中操作的表则出现如下界面,查看左下角从左