Ogg Objections: Problems with the Container Format

This one was accidentally deleted from the submission queue when it was first submitted some time ago, so I decided to keep it around for a slow news day (such as this one – dear lord, it’s quiet). FFmpeg developer Mans penned down a number of crucial problems with the Ogg container format.

The problems with the format centre around a few basic principles: generality, overhead, latency, random access, and timestamps.

The problem with generality is, well, that there isn’t any. Ogg is supposed to be a general-purpose container format, meaning that “encoded data of any type can be encapsulated with a minimum of effort”. According to Mans, Ogg doesn’t fit this description.

“For every format one wishes to use with Ogg, a complex mapping must first be defined,” Mans explains, “This mapping defines how to identify a codec, how to extract setup data, and even how timestamps are to be interpreted. All this is done differently for every codec. To correctly parse an Ogg stream, every such mapping ever defined must be known.”

Sadly, there is no single place to go and get these codec mappings from, leading to problems. “It is simply impossible to obtain a exhaustive list of defined mappings, which makes the task of creating a complete implementation somewhat daunting,” Mans explains. He also presents Matroska as a much better example of a general purpose container format.

Ogg also has overhead problems, Mans argues. After providing a detailed explanation of the concept, he concludes: “We thus see that in an Ogg file, the packet size fields alone contribute an overhead of 1/255 or approximately 0.4%. This is a hard lower bound on the overhead, not attainable even in theory. In reality the overhead tends to be closer to 1%. Contrast this with the ISO MP4 file format, which can easily achieve an overhead of less than 0.05% with a 1 Mbps elementary stream.”

Latency-wise, it all gets very technical again:

Latency in an Ogg-based system is introduced at both the sender and the receiver. Since the page header depends on the entire contents of the page (packet sizes and checksum), a full page of packets must be buffered by the sender before a single bit can be transmitted. This sets a lower bound for the sending latency at the duration of a page.

On the receiving side, playback cannot commence until packets from all elementary streams are available. Hence, with two streams (audio and video) interleaved at the page level, playback is delayed by at least one page duration (two if checksums are verified).

This problem could technically be solved, but in doing so, you’d hit the overhead problem again. “Minimum latency is clearly achieved by minimising the page duration, which in turn implies sending only one packet per page,” Mans explains, “This is where the size of the page header becomes important. The header for a single-packet page is 27 + packet_size/255 bytes in size. For a 1 Mbps video stream at 25 fps this gives an overhead of approximately 1%. With a typical audio packet size of 400 bytes, the overhead becomes a staggering 7%. The average overhead for a multiplex of these two streams is 1.4%.”

Other formats, like ISO MPEG-PS and Microsoft’s ASF, have far less overhead, and Mans suggests bringing Ogg in line with those.

Random access is also a problem with Ogg. Random access allows direct seeking at any position in the file; quite important for a general purpose container format. The method with which Ogg provides random access is crude, according to Mans, a problem which gets worse on slower media like optical disks or over the network.

Another important aspect of video files is that the audio and video streams must run in sync, or else it starts to get annoying really fast. “By the time Ogg was invented, solutions to this problem were long since explored and well-understood,” Mans writes, “The key to proper synchronisation lies in tagging elementary stream packets with timestamps, packets carrying the same timestamp intended for simultaneous presentation. The concept is as simple as it seems, so it is astonishing to see the amount of complexity with which the Ogg designers managed to imbue it.”

Mans concludes that Ogg is simply a bad format – patent free or no. “[Being patent-free] still does not alter the fact that Ogg is a bad format,” Mans claims, “Being free from patents does not magically make Ogg a good choice as file format. If all the standard formats are indeed covered by patents, the only proper solution is to design a new, good format which is not, this time hopefully avoiding the old mistakes.”

39 Comments

  1. 2010-03-18 12:36 am
    • 2010-03-18 1:01 am
      • 2010-03-18 1:39 am
        • 2010-03-18 1:49 am
          • 2010-03-18 2:23 am
          • 2010-03-18 9:56 am
          • 2010-03-18 11:24 am
          • 2010-03-18 12:55 pm
          • 2010-03-18 1:19 pm
          • 2010-03-18 2:07 pm
          • 2010-03-19 6:49 am
    • 2010-03-18 2:11 am
  2. 2010-03-18 12:43 am
    • 2010-03-18 1:31 am
  3. 2010-03-18 5:16 am
  4. 2010-03-18 5:24 am
    • 2010-03-18 6:30 am
  5. 2010-03-18 9:44 am
    • 2010-03-18 10:04 am
      • 2010-03-18 10:39 am
      • 2010-03-18 5:08 pm
        • 2010-03-18 5:13 pm
          • 2010-03-18 5:19 pm
    • 2010-03-18 11:06 am
      • 2010-03-18 11:17 am
        • 2010-03-18 11:39 am
          • 2010-03-18 12:19 pm
          • 2010-03-18 5:04 pm
      • 2010-03-18 4:09 pm
        • 2010-03-19 12:47 am
          • 2010-03-19 11:37 am
          • 2010-03-20 12:05 pm
        • 2010-03-19 6:15 am
          • 2010-03-19 11:48 pm
        • 2010-03-19 11:43 pm
      • 2010-03-18 4:54 pm
        • 2010-03-19 7:01 am
          • 2010-03-19 9:05 am
      • 2010-03-18 5:10 pm