my first post here [so please excuse the eventual formatting/formulation/etc issues]. I am writing a raw H.264 to a mpeg 2 transport stream transcoder (changing the container only, no video transcoding per se involved). I think I understand the mpeg 2 transport stream spec (H.222.0) but I cannot get QuickTime to playback the resulting .ts files (VLC and FFMPEG play back fine). What I'm doing :
- create PAT with program map pid 53
- create PMT with pid 53 for PCR PID 70
- split the raw NALUs into PES packets with PID 70 - add an adaptation field with stuffing bytes in case the PES is less then 184 bytes long
I have two (almost identical) files - one of them is two frames .ts file dumped out by VLC, the other one is the two frames .ts file dumped by VLC transcoded to raw H.264 that in turn is transcoded to .ts again with my tool. The differences are minimal, but for the life in me, QuickTime plays back only the original VLC .ts, not my transcoded one. I am using tsreport from http://tstools.berlios.de to report the various .ts file structures and they look almost identical. Below are the logs dumped out by tsreport. Any ideas ?
tsreport log for the original VLC .ts file
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
I took the VLC .ts file above, extracted the raw bitstream from it - then I used my tool to convert it to .ts again; the tsreport log for my .ts is below :
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
Update
Turns out, I had NALUs type 9 before each NALU - i.e., my stream was something like 9 7 9 8 9 6 9 5 ... instead of 9 7 8 6 5 9 1 9 1 ...