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

时间:2014-03-31 05:31:08

标签: h.264 mpeg transport

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

  1. 使用程序映射pid 53
  2. 创建PAT
  3. 使用pid 53为PCR PID 70创建PMT
  4. 将原始NALU分成带有PID 70的PES包 - 在PES小于184字节长的情况下添加带填充字节的适配字段
  5. 我有两个(几乎相同的)文件 - 其中一个是由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之前我有NALU类型9 - 也就是说,我的流是9 7 9 8 9 6 9 5 ...而不是9 7 8 6 5 9 1 9 1 ...

1 个答案:

答案 0 :(得分:1)

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