4

众所周知,在 Smooth Stream 客户端清单文件中,video 标签中包含一个“CodecPrivateData”属性。现在经过我的初步调查,我发现这个字符串是通过使用本质上是 NAL 单元的 SPS 和 PPS 形成的。

我正在寻找一种从视频 GOP 中提取该信息的方法,以便我可以使用它来创建清单文件并手动替换编解码器私有数据

基本上,我期待创建自定义应用程序以使用 ffmpeg 创建平滑表示

4

1 回答 1

15

请注意,SPS/PPS 与 mp4 文件中的视频轨道分开存储在全局标头之一(全局标头的 avcC 部分)中。

这是格式:每个 ISO/IEC 14496-10 8+ 字节

                 = long unsigned offset + long ASCII text string 'avcC'
                -> 1 byte version = 8-bit hex version  (current = 1)
                -> 1 byte H.264 profile = 8-bit unsigned stream profile
                -> 1 byte H.264 compatible profiles = 8-bit hex flags
                -> 1 byte H.264 level = 8-bit unsigned stream level
                -> 1 1/2 nibble reserved = 6-bit unsigned value set to 63
                -> 1/2 nibble NAL length = 2-bit length byte size type
                  - 1 byte = 0 ; 2 bytes = 1 ; 4 bytes = 3
                -> 1 byte number of SPS = 8-bit unsigned total
                -> 2+ bytes SPS length = short unsigned length
                -> + SPS NAL unit = hexdump
                -> 1 byte number of PPS = 8-bit unsigned total
                -> 2+ bytes PPS length = short unsigned length
                -> + PPS NAL unit = hexdump

如果您只想从单个 .mp4 中提取 SPS/PPS,您可以使用十六进制编辑器并根据上述 MP4 格式规范通过检查获得 SPS/PPS(通过从文件末尾搜索查找“avcC”字符串); 然后将 SPS/PPS 字节添加到 c 样式数组中供您使用。

否则,您可以将 ffmpeg 与h264bitstream实用程序一起使用来提取 SPS/PPS。首先在命令行运行ffmpeg提取h264流:

ffmpeg -i my_funny_video.mp4 -vcodec copy -vbsf h264_mp4toannexb -an my_funny_video.h264

然后从 h264bitstream 实用程序运行 h264_analyze:

h264_analyze my_funny_video.h264

这将对您的 SPS/PPS 和其他 NAL 进行详细分析。

于 2013-07-10T13:49:08.637 回答