H.264 到传输流转码器问题

标签 h.264 mpeg transport

我的第一篇文章在这里 [所以请原谅最终的格式/公式/等问题]。我正在将原始 H.264 写入 mpeg 2 传输流转码器(仅更改容器,本身不涉及视频转码)。我认为我了解 mpeg 2 传输流规范 (H.222.0),但我无法让 QuickTime 播放生成的 .ts 文件(VLC 和 FFMPEG 播放正常)。我在做什么:

  1. 使用程序映射 pid 53 创建 PAT
  2. 为 PCR PID 70 创建 pid 为 53 的 PMT
  3. 将原始 NALU 拆分为 PID 为 70 的 PES 数据包 - 添加一个带有填充字节的自适应字段,以防 PES 长度小于 184 字节

我有两个(几乎相同的)文件 - 其中一个是 VLC 转储的两帧 .ts 文件,另一个是 VLC 转储的两帧 .ts 文件转码为原始 H.264,然后转码再次使用我的工具.ts。差异很小,但对于我的生活来说,QuickTime 只播放原始的 VLC .ts,而不是我转码后的。我正在使用来自 http://tstools.berlios.de 的 tsreport报告各种 .ts 文件结构,它们看起来几乎相同。下面是 tsreport 导出的日志。有任何想法吗 ?


原始 VLC .ts 文件的 tsreport 日志

       0: TS Packet  1 PID 0000 [pusi] PAT
  Adaptation field len 166 [flags 00]
  section length:       00d (13)
  transport stream id: 7fc2
  version number 08, current next 1, section number 0, last section number 0
    Program 001 (  1) -> PID 0042 ( 66)
     188: TS Packet  2 PID 0042 [pusi] PMT
  Adaptation field len 155 [flags 00]
  section length:  018 (24)
  program number: 0001
  version number 10, current next 1, section number 0, last section number 0
  PCR PID: 0044
  program info length: 0
  Program streams:
    PID 0044 -> Stream 1b H.264/14496-10 video (MPEG-4/AVC)
        Languages: ^@^@^@
     376: TS Packet  3 PID 0044 [pusi] stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len   7 [flags 10]: PCR
 .. PCR            0
  PES header
    Start code:        00 00 01
    Stream ID:         e0   (224) SYSTEM START: Video stream 0
    PES packet length: 0000 (0)
    Flags:             80 c0 : PTS DTS
    PES header len 10
    PTS 0
    DTS 0
  Data (176 bytes): 00 00 01 e0 00 00 80 c0 0a 31 00 01 00 01 11 00 01 00 01 00...
     564: TS Packet  4 PID 0044 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
     752: TS Packet  5 PID 0044 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
     940: TS Packet  6 PID 0044 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
    1128: TS Packet  7 PID 0044 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
    1316: TS Packet  8 PID 0044 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len 164 [flags 10]: PCR
 .. PCR 562829905200
    1504: TS Packet  9 PID 0044 [pusi] stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len 134 [flags 00]
  PES header
    Start code:        00 00 01
    Stream ID:         e0   (224) SYSTEM START: Video stream 0
    PES packet length: 0000 (0)
    Flags:             80 c0 : PTS DTS
    PES header len 10
    PTS 1876128985
    DTS 1876128985
  Data (49 bytes): 00 00 01 e0 00 00 80 c0 0a 33 bf 4d e9 b3 13 bf 4d e9 b3 00...
Read 9 TS packets

我拿了上面的 VLC .ts 文件,从中提取了原始比特流——然后我用我的工具再次将它转换为 .ts;我的 .ts 的 tsreport 日志如下:

       0: TS Packet  1 PID 0000 [pusi] PAT
  Adaptation field len 166 [flags 00]
  section length:       00d (13)
  transport stream id: 79d4
  version number 08, current next 1, section number 0, last section number 0
    Program 001 (  1) -> PID 0035 ( 53)
     188: TS Packet  2 PID 0035 [pusi] PMT
  Adaptation field len 161 [flags 00]
  section length:  012 (18)
  program number: 0001
  version number 10, current next 1, section number 0, last section number 0
  PCR PID: 0046
  program info length: 0
  Program streams:
    PID 0046 -> Stream 1b H.264/14496-10 video (MPEG-4/AVC)
     376: TS Packet  3 PID 0046 [pusi] stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len   7 [flags 10]: PCR
 .. PCR      5370000
  PES header
    Start code:        00 00 01
    Stream ID:         e0   (224) SYSTEM START: Video stream 0
    PES packet length: 0000 (0)
    Flags:             80 c0 : PTS DTS
    PES header len 10
    PTS 18000
    DTS 18000
  Data (176 bytes): 00 00 01 e0 00 00 80 c0 0a 31 00 01 8c a1 11 00 01 8c a1 00...
     564: TS Packet  4 PID 0046 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
     752: TS Packet  5 PID 0046 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
     940: TS Packet  6 PID 0046 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
    1128: TS Packet  7 PID 0046 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
    1316: TS Packet  8 PID 0046 stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len 122 [flags 00]
    1504: TS Packet  9 PID 0046 [pusi] stream type 1b (H.264/14496-10 video (MPEG-4/AVC))
  Adaptation field len 122 [flags 10]: PCR
 .. PCR      7170000
  PES header
    Start code:        00 00 01
    Stream ID:         e0   (224) SYSTEM START: Video stream 0
    PES packet length: 0000 (0)
    Flags:             80 c0 : PTS DTS
    PES header len 10
    PTS 24000
    DTS 24000
  Data (61 bytes): 00 00 01 e0 00 00 80 c0 0a 31 00 01 bb 81 11 00 01 bb 81 00...
Read 9 TS packets

更新

事实证明,我在每个 NALU 之前都有 9 类型的 NALU - 即,我的流类似于 9 7 9 8 9 6 9 5 ... 而不是 9 7 8 6 5 9 1 9 1 ...

最佳答案

问题是我在每个 NALU 之前都有 9 类型的 NALU - 即,我的流类似于 9 7 9 8 9 6 9 5 ... 而不是 9 7 8 6 5 9 1 9 1 ... 我改变了我的容器转码器只输出一个访问单元定界符——即 NALU 类型 9——每帧(不是每个 NALU),现在一切都很好。

关于H.264 到传输流转码器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22754231/

相关文章:

algorithm - 一种循环冗余校验算法,它对具有特定非零值的尾随字节数不变

java - MATSim 中的可视化工具

ios - 将来自 VTCompressionSession 的压缩帧与音频数据混合到 MPEG2-TS 容器中以进行网络流式传输

ffmpeg - 媒体源扩展中的有趣行为

ffmpeg - MPEG DASH - 我是否需要将音频和视频轨道作为单独的源文件来使用 mp4box 创建 DASH 包

video - 在 mp4 (h.264/avc) 视频中帧速率不一致是否合法

abap - 不使用TMS将TR文件推送到SAP ERP系统

voip - H.264 over RTP 流在播放时损坏

iphone - FFmpeg 不解码 h264 流

file-format - 如何解析这个苹果特有的 MPEG 文件头?