OK, looking at some of the articles on this site and because of the overall favorable feedback I've received on this program, I've decided to update this article. The program is the same, only the article is improved. So, here it goes, the improved version:
This program is about multiplexing more Elementary Streams (usually MPEG 2 files) into a Transport Stream. That's the idea behind HDTV (High Definition TV or Digital TV) standard. That's how your digital TV signal is formed (of course, if you have one). The standard stream chosen for HDTV is MPEG 2, because it has many advantages regarding video & audio streams and formats. A MPEG 2 file (also called Program Stream) contains VIDEO, AUDIO and ancillary data organized in PES (Packetized Elementary Stream) packets.
Here's a link to a program I've developed to deal with MPEG 2 standard: An analyzer for MPEG 2 Program Stream files.
If you want to know more about PES packets, I suggest reading the ISO 138181 documentation (sadly, ANSI has it on sale for 560$ !!!)
The problem resides in multiplexing PES packets into a Transport Stream (TS) and sending this stream over the network at a preferably fixed bit rate. A TS packet is of fixed length - 188 bytes, no matter the type of carried data (audio or video), and one TS packet can carry data from only one PES packet.
So, let's review: you multiplex multiple movie files into a stream that you send over the network. The clients in that network receive your stream and decode it (each client wants only one movie from the stream). Then, the client application plays the stream, and if your Transport Stream isn't adequate, the client might receive a too small amount of data - then you'll see glitches in the player, or, on the opposite, the amount of data received might be excessive and at the client player, frames are discarded.
Don't think for a moment that this program resolves the issue of HDTV communication. It's just a speedometer, very useful to understand the concept and still functioning as a benchmark. As a note, there are some companies in the Internet offering such a multiplexing software, more or less performing, but if you'll take a look at their software license price, you'll easily understand why nobody will share their sources of such a program on a free basis.
This sample program has the following features:
- Lets you choose how many ES (Elementary Stream) files you want to generate
- Lets you chose the size of an ES file
- Generates ES files filled with a single char
- Lets you specify the size of the multiplexing buffer
- Lets you specify the size for PES packet's Header & PES packet's Length
- Lets you chose how the TS stream will be created (to a file or to "Emulated Network")
- Generates the multiplexing stream you can read to identify individual TS packets and their content
- Constructs a diagram for buffer efficiency after each multiplexing process
Main window (at start point):
That's how the program looks when started.
Main window (after multiplexing):
That's how the program looks after a completed multiplexing process.
TS settings window:
Here you can specify PES HEADER & PES PACKET LENGTH to see how the multiplexer does with different values.
This is a window containing some about info, specifications and a calendar.
That's the scalable diagram you can view after completing a multiplexing process.
This window is useful if you wish to understand how the output TS stream is formed.
This sample program demonstrates that C# is adequate to write that sort of HDTV multiplexing application. I've heard some voices saying that only C++ and Assembler are suited to reach the desired multiplexing speed (usually around 27 MBit/s) and I wrote this program to demonstrate they are wrong. Anyway, my view is that this program is interesting because of the subject it approaches.
If you want to talk on this subject or you have suggestions regarding this program, please feel free to contact me by e-mail (email@example.com or firstname.lastname@example.org).