I have .m2ts video file (VBR, duration = 1 hour).
I need to know from which byte I should read this file if I want to start playing this file from 20 minute.
M2TS is standard TS with a 4-byte timestamp ahead of the sync byte (0x47), but I don't understand how use it. Please see following timestamps ahead of sync byte in my video file:
0D 9E E2 02
35 8B 62 28
1D 77 E2 4F
05 64 62 76
2D 50 E2 9C
15 3D 62 C3
3D 29 E2 E9
25 16 63 10
Can someone explain how to use timestamps for seeking in .m2ts files ?
M2TS
doesn't have a 4-byte timestamp.
What it does have is a 4-byte TP_extra_header
consisting of a 2-bit
copy permission indicator plus a 30-bit
arrival timestamp (ATS) with a resolution of 27 MHz
.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| C | ATS |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| TS [188 bytes] |
| |
| . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
Since the BDAV
format is intended for storage, it uses variable rate (VBR) Transport Streams instead of the typical constant rate (CBR) streams found in broadcast to save space. The arrival time is recorded in order to be able to convert the variable stream into a constant rate and T-STD compliant one for playback.
This timestamp will roll-over every (2^30 - 1) / 27000000 ~= 39.768
seconds.
For eg: 1D77E24F ∧ 3FFFFFFF
is in decimal 494395983 / 27000000 ~= 18.32
seconds.
I'm not really familiar with BD but I think more info about the m2ts
files is kept in the clpi
and mpls
accompanying files. If you only have the m2ts
file you'll have to seek by PCR.