We have in the spec for PES_packet():
Code: Select all
if (PTS_DTS_flags = = '10') {
'0010' 4 bits
PTS [32..30] 3 bits
marker_bit 1 bit
PTS [29..15] 15 bits
marker_bit 1 bit
PTS [14..0] 15 bits
marker_bit 1 bit
}
Code: Select all
if (PTS_DTS_flags = = '10') {
'0010' 4 bits
PTS [32..30] 3 bits
marker_bit 1 bit
PTS [29..15] 15 bits
marker_bit 1 bit
PTS [14..0] 15 bits
marker_bit 1 bit
}
Code: Select all
VIDEO_PES_PTS := (UInt64(b[0] and $e) shl 29) or
(UInt64(b[1]) shl 22) or
(UInt64(b[2] and $fe) shl 14) or
(UInt64(b[3]) shl 7) or
(UInt64(b[4]) shr 1);
Code: Select all
1011[0]: 1048560 [11650,666666667 ms]
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
missing PES packet header
1011[11]: 1086097 [12067,744444444 ms]
Great. Thank you.
OK. For later processes it is necessary to start with a zero timestamp. But I guess it is easy to subtract the first PTS value from all PTS's.
Very nice, thanks.Sherman wrote: ↑Thu Jul 18, 2024 7:13 amOK, I updated main2.cpp and main3.cpp with the fix. There was a little bug in the case of afc = 3. For main3.cpp I also added some dots at the beginning to show progress. For video each dot is 1000 frames.
https://rationalqm.us/misc/main3.cpp
Yes, I need later the PTS in ms with nano second accuracy.
A mega big thanks to you Sherman.
OK. Now that I know where the extra 4 bytes come from (and a packet is therefore always 192 bytes long), everything should fit with the Spec.PDF and I can use it.
Hi Rocky.
Oh yes, what a waste of Bytes.
Code: Select all
0.000000
0.000000
10.666667
10.666667
21.333333
21.333333
32.000000
32.000000
42.666667
42.666667
53.333333
53.333333
64.000000
64.000000
Code: Select all
0.000000
0.000000
32.000000
32.000000
64.000000
64.000000
96.000000
96.000000
Many thanks. I'll take a closer look at it in the next few days, but my first look tells me it shouldn't be difficult.
I suspect that I should parse other audio formats. But for example, with an AC-3 track, the duration is always fixed at 32ms. In that case, everything is known, but if I want to parse in m2ts, it would be enough if I recognized that it was AC-3 for the PID, right?
It's funny that this was my first thought too, but I thought it wasn't clean and real professionals wouldn't program it like that. But it's good to know that it can be done like that.
Right.hubblec4 wrote: ↑Mon Sep 02, 2024 2:07 pmI suspect that I should parse other audio formats. But for example, with an AC-3 track, the duration is always fixed at 32ms. In that case, everything is known, but if I want to parse in m2ts, it would be enough if I recognized that it was AC-3 for the PID, right?
Rocky (who used to work on set-top box backend HW/SW) told me there is a wrinkle involved. Since presentation times are evenly spaced, it is not essential to include a time stamp in every presentation unit. Instead, time stamps can be interpolated by the decoder, but they must not be more than 700 ms apart. Now, is timestamp interpolation something for you to worry about? He says he's never seen interpolation on bluray/UHD disks, nor on audio streams, although he has seen it on broadcast video streams (e.g., DVB, presumably for bandwidth saving). It's likely that in practice for bluray/UHD disks both ways are fine. But maybe you prefer to be safe and not sorry.So the question is whether I even need to parse the durations if the duration can also be determined using the PTSs. Do you think that still makes sense?