My task is to capture the videostream from the server and write it to ts. files. I ran into a problem when trying to write a SDT package to ts. I form the packet manually by bytes and I can’t figure out how to calculate 4 bytes of CRC-32 for the end of SDT. (used golang)
I tried to get the CRC based on the checksum of the data already written to the SDT packet, but it doesn't work. In the byte-by-byte parsed SDT, CRC was different from what I calculated.
If you're talking about MPEG-2, then the CRC definition is:
There is an example in RFC 4326:
where the last four bytes of that is the CRC-32/MPEG-2 (in big-endian order) of all of the bytes that precede it.
Here is example C code to calculate that CRC:
(When called with
memequal toNULL, the initial CRC value is returned.)