Q:

how mpegts works

Can anyone please explain as to how mpeg-ts works. I have gone through the specification doc but didnt understood as to why multiple streams are combined to form one stream.
Also I opened a .ts file using media info tool and for Audio it was showing 2 Audio streams. So which audio stream will be used while playing the content. 

A:

The why is simple to explain: to carry several media over one bit stream. Consider DVB (digital TV): each transponder (= frequency) provides one bit stream. But you already need at least two streams for a TV channel: audio and video. And then a lot more that you'll never see carrying meta-information. So instead of transporting each of these streams on a separate frequency, they are multiplexed into one bit stream. That is the MPEG-TS (Transport Stream). A demuxer then takes this stream and separates it into substreams which carry the real information.
Through this, a typical DVB-T transponder in Europe can carry four TV channels (called a bouquet). The number can vary, it's a decision of the stream provider (trade-off between more quality = less channels = more expensive or less quality = more channels = cheaper, I guess).
As to which audio stream is played: a TV channel can have several audio streams (for example, normal audio, audio with descriptions for visual impaired, another language, etc.). By default, a player will probably play the first audio stream but can switch audio streams at any time.

A:

Mpeg2 TS is a container. Containers hold one or more audio/video streams and also contain the metadata describing how this data (the mutltimedia streams) are stored in the file. Containers greatly simplify the display application by way of interleaving, synchronisation, inter alia.
Specifically, mpeg2-ts is meant for streaming content (e.g. Video On Demand). In applications like these, the server needs to transmit multiple video streams (e.g. different camera angles during a football match) and multiple audio streams (e.g. different languages) at the same time. These are multiplexed into a single mpeg2-ts file (uniquely identified by something called a program ID). At the client site, the player application has to choose the PID of the video and audio stream to render. Alternatively, the player can ask the user (e.g. by selecting language).

