Eyevinn / mp4ff

Library and tools for parsing and writing MP4 files including video, audio and subtitles. The focus is on fragmented files. Includes mp4ff-info, mp4ff-encrypt, mp4ff-decrypt and other tools.
MIT License
462 stars 84 forks source link

SPS/PPS serialization #344

Closed Kerblif closed 6 months ago

Kerblif commented 6 months ago

Hi,

I want to serialize SPS/PPS, but I haven't found the right methods. Do they exist?

tobbee commented 6 months ago

No, there is no code to serialise SPS/PSS, just parse and interpret them. What is your use case for generating or changing SPS/PPS?

Kerblif commented 6 months ago

I am engaged in reverse engineering of a Chinese registrar for public transport. The registrar uses its own protocol for video transmission, in which it sends SPS and PPS in some kind of chaotic order. Therefore, I was going to write code to read these SPS and PPS so that when initializing a new live broadcast, I could immediately send data to start it. In theory, it is possible to store data in byte array format, but I don't really like this implementation.

tobbee commented 6 months ago

Deserialising the SPS and PPS should be fine with the code here, but there may be some details which are not fully correct since it is very hard to test this without integration with a decoder/encoder. The main use case of this library is to extract relevant parts/parameters, but also get the size of the slice header so that one can start encryption at the right byte.

In general, the newer MPEG standards are NAL-unit-based with SPS, PSS, and video slices all being NALUs. It is therefore quite natural to pass them around as byte-slices. If one also needs the interpretation of parameter sets, it is fairly easy to have that as side data.

tobbee commented 6 months ago

@Kerblif I think I have answered your question, and don't think I can help you more. If no other aspect comes up, do you think it is OK to close this ticket next week?

Kerblif commented 6 months ago

Yes, of course, thank you so much for your help!