后一修订版 前一修订版 public:it:mp4 [2024/04/23 10:03] – 创建 oakfire public:it:mp4 [2024/04/23 10:31] (当前版本) – oakfire
====== MP4 ====== ====== MP4 ======
<markdown>
## 参考
- https://www.cnblogs.com/chyingp/p/mp4-file-format.html
- https://lucius0.github.io/2018/01/16/archivers/media-study-08/
- ffmpeg\libavformat\movenc.c
## 文档 ==== 参考 ====
- 参考:https://www.cnblogs.com/codertian/p/8277965.html
- 文档下载:https://standards.iso.org/ittf/PubliclyAvailableStandards/index.html * https://www.cnblogs.com/chyingp/p/mp4-file-format.html
- 14496-12 14496-14 14496-15 下载要收费了, csdn 解决 * https://lucius0.github.io/2018/01/16/archivers/media-study-08/
- 14496-15 涉及h264 h265 流 的 stsd box 封装 * ffmpeg\libavformat\movenc.c
- 14496-15-2017 5.4.2 讲述 h264 的 avc1-avcC box 结构, ` avcC主要是AVCDecoderConfigurationRecord` , 这个见 5.3.3.1.2
- avc1 是 ` AVCSampleEntry` , 继承 ` VisualSampleEntry` ==== 文档 ====
- ` VisualSampleEntry` 结构见 14496-12_2015 12.1.3.2
```C * 参考:https://www.cnblogs.com/codertian/p/8277965.html
* 文档下载:https://standards.iso.org/ittf/PubliclyAvailableStandards/index.html
* 14496-12 14496-14 14496-15 下载要收费了, csdn 解决
* {{ :public:it:iso_iec_14496 -12_2015.pdf |}}
* {{ :public:it:iso_iec_14496-14-2020.pdf |}}
* {{ :public:it:iso_iec_14496-15_2013_avcff.pdf |}}
* {{ :public:it:标准iso-iec14496-15-2017.docx |}} 这个是在WPS里用图片型PDF经ORC扫描生成的,可能有错漏。查看时可比对2013版
* 14496-15 涉及h264 h265 流 的 stsd box 封装
* 14496-15-2017 5.4.2 讲述 h264 的 avc1-avcC box 结构, '' avcC'' 主要是 '' AVCDecoderConfigurationRecord'' , 这个见 5.3.3.1.2
* avc1 是 '' AVCSampleEntry'' , 继承 '' VisualSampleEntry''
* '' VisualSampleEntry'' 结构见 14496-12_2015 12.1.3.2<code c>
class VisualSampleEntry(codingname) extends SampleEntry (codingname){ class VisualSampleEntry(codingname) extends SampleEntry (codingname){
unsigned int(16) pre_defined = 0; unsigned int(16) pre_defined = 0;
unsigned int(16) data_reference_index; unsigned int(16) data_reference_index;
} }
``` </code>
- H265 的 hev1 - hvcC box 结构 14496-15_2013 就有提及,在 8.4.1 章节, hvcC box 包含 `HEVCDecoderConfigurationRecord` 结构,具体见 8.3.3.1 章节 * H265 的 hev1 - hvcC box 结构 14496-15_2013 就有提及,在 8.4.1 章节, hvcC box 包含 `HEVCDecoderConfigurationRecord` 结构,具体见 8.3.3.1 章节
- ` Compressorname` in the base class VisualSampleEntry indicates the name of the compressor used with the value "\013HEVC Coding" being recommended (\013 is 11, the length of the string in * '' Compressorname'' in the base class VisualSampleEntry indicates the name of the compressor used with the value "\013HEVC Coding" being recommended (\013 is 11, the length of the string in
bytes). bytes).
- ` HEVCDecoderConfigurationRecord` 结构: * '' HEVCDecoderConfigurationRecord'' 结构:<code c>
```C
aligned(8) class HEVCDecoderConfigurationRecord { aligned(8) class HEVCDecoderConfigurationRecord {
unsigned int(8) configurationVersion = 1; unsigned int(8) configurationVersion = 1;
} }
} }
``` </code>
==== 一些分析 ====
* mp4 的主要box:
* {{:public:it:426ff9a882f84a3e8503e94c5fe6d7c9.png?|}}
* fmp4 的moov box:
* {{:public:it:a23fa461c3944c798e5e51355a976832.png|}}
## 一些分析
- mp4 的主要box:

- fmp4 的moov box: * 组装 fmp4的 moov box 必须获取视频流的 width, height, pps, sps

- 组装fmp4的 moov box 必须 获取视频流的 width, height, pps, sps * 获取 pps sps:
* avc1 参考 ffmpeg 的 mov_write_video_tag 函数
- 获取 pps sps : ==== 哥伦布编码 ====
- avc1 参考 ffmpeg 的 mov_write_video_tag 函数 * https ://www.cnblogs.com/wangguchangqing/p/6297792.html
* Golomb编码,及其两个变种:Golomb-Rice和Exp-Golomb
## 哥伦布编码
- https://www.cnblogs.com/wangguchangqing/p/6297792.html
</markdown>