1

When I remux the transport stream (.ts file) of a satellite recording to mkv, file size shrinks considerably.

Why is that ?
What is inside the .ts container that gets "lost" during remuxing ?

For testing purposes, I recorded a few seconds of a TV satellite broadcast, resulting in a 4 MB .ts file. I then remuxed this file to .mkv, keeping all streams (1 video stream + 2 audio streams) and got a 3 MB .mkv file.
What accounts for the -25% difference in file size ?

I can attach the files if needed. No reencoding takes place.

2
  • Is the video stream re-encoded during remux ?
    – audionuma
    Apr 10, 2023 at 5:59
  • @ audionuma: no. I updated the question. Thank you.
    – summerrain
    Apr 11, 2023 at 3:19

1 Answer 1

2

The short answer: container overhead.

MKV (and to a lesser extent, MP4/ISOBMFF) are very "flexible" containers, and basically adapt to whatever you're trying to shove into them, provided the muxer knows how to handle it and the demuxer at the other end is expecting it.

MPEG-TS is a rigid dinosaur meant to behave exactly the same way, every single time; on discrete hardware, in software, over the air, in cables under the ground, over cellular networks, etc. It can be more resilient as a result, but that comes at a cost - usually padding bytes and wasted packets.


While it's from an "Internet video infrastructure" company's blog, this article from a Mux engineer gave the nicest explanation I could find for you. Mux - Quantifying packaging overhead

TS has some strange properties. It was built for a pre-ethernet world and includes features such as lost and out of order packet detection and remote time synchronization. These features are required for digital over-the-air broadcasts...TS also uses a fixed packet size of 188 bytes with each packet starting with a sync byte to identify the start of a packet...The downside of not using these features is that they still take up space in the file.

Each 188 byte TS packet has a 4 byte header. This header contains the sync byte, some flag bits, a packet id (or PID, which identifies a unique audio or video stream), and a continuity counter (used to identify missing or out of order packets). Every frame then has a prepended Packetised Elementary Stream (PES) header. The PES header is a minimum of 14 bytes, (or 19 bytes if the frame decode time does not match the presentation time, i.e. B frames) and encodes the frame timestamps among other things. Therefore, the first packet has at most 170 bytes available while subsequent packets have 184 bytes available. If a frame is less than 170 bytes, it must be padded to consume the full packet. If a frame is 171 bytes, a second packet is required and thus 376 bytes (188x2) is needed to transmit the 171 bytes of payload, more than doubling the required bandwidth. In reality, frames under 170 bytes are not very common. However at bitrates under 1Mbps, a 10% or more overhead is not uncommon.

Mux


You'd likely see a similar size reduction remuxing to .mp4. Since this is a satellite TS, there could be more than one video, audio, or subtitle track, but I'll assume you preserved them all when remuxing. There might also be other satellite specific "program data" that is discarded when you remux to MKV. e.g. MPEG-TS packet IDs 16–31/0x0010-0x001F are used for DVB metadata. MKV muxers toss that out if they don't know what to do with it, but it's likely of little use to you, especially if it is repeated with every single packet.

Some transmission schemes, such as those in ATSC and DVB, impose strict constant bitrate requirements on the transport stream. In order to ensure that the stream maintains a constant bitrate, a multiplexer may need to insert some additional packets. The PID 0x1FFF is reserved for this purpose. The payload of null packets is all zeroes, and the receiver is expected to ignore its contents. 15

They could also be null/padding packets - like I mentioned above for ATSC/DVB, or you might sometimes see with a .ts/series of .ts files used for MPEG-DASH or HLS internet streaming at a strict constant bitrate. TS overhead for internet use usually comes down to how many "extra" nearly empty frames are required depending on your bitrate, not strict CBR padding.

https://en.wikipedia.org/wiki/MPEG_transport_stream#Null_packets

Use MediaInfo to look at your source .ts and you might be able to get a better idea if there's any extra program data or not.

2
  • "a 10% or more overhead is not uncommon." In my tests a typical DVB-S recording of, say, 4GB remuxes to a 3GB .mkv file with mkvmerge (keeping all streams). I understand why there is overhead. I could even imagine 10%. But 25% ?? That doesn't seem explainable to me by overhead alone. What I would be interested in is a source explaining this big overhead. I'm not sure your answer (which I otherwise like) really provides that ?
    – summerrain
    Mar 29 at 18:45
  • 2
    for legacy DVB-S, CBR (constant bitrate) is a requirement. If the actual bitrate drops below that value, the muxer at their end literally adds zeros to fill space up lol. How many individual streams are contained within the TS container? That might have something to do with it. Mar 31 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.