Click here to Skip to main content
15,861,168 members
Articles / Programming Languages / C#
Article

Sample speed test for Transport Stream construction

Rate me:
Please Sign up or sign in to vote.
3.47/5 (45 votes)
13 Apr 20044 min read 123.9K   1.9K   48   15
A program that emulates the TS construction from ES files for the HDTV standard.

What's new:

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:

The concept:

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.

This program:

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):

Sample screenshot

That's how the program looks when started.

Main window (after multiplexing):

Sample screenshot

That's how the program looks after a completed multiplexing process.

TS settings window:

Sample screenshot

Here you can specify PES HEADER & PES PACKET LENGTH to see how the multiplexer does with different values.

About window:

Sample screenshot

This is a window containing some about info, specifications and a calendar.

Diagram window:

Sample screenshot

That's the scalable diagram you can view after completing a multiplexing process.

Legend window:

Sample screenshot

This window is useful if you wish to understand how the output TS stream is formed.

Author notes:

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 (ro_angel_bv@hotmail.com or ro_angel_bv@fastmail.fm).

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Malaysia Malaysia
Dumitru Bogdan - alias Angel

Born 1980 , Brasov , Romania

Final year student at Transilvania University of Brasov , Faculty of Electrical Engineering & Computer Science , Department of Electronics & Computers

Programming : Visual C++ , Visual Fox Pro , Assembler & later , C#

Motto : "Nothing Last Forever" , and software is no exception

Comments and Discussions

 
QuestionMpeg Containers Pin
jfriedman13-Dec-14 2:41
jfriedman13-Dec-14 2:41 
GeneralMy vote of 5 Pin
Trollslayer8-Jan-11 2:49
mentorTrollslayer8-Jan-11 2:49 
QuestionHow to get picture type Pin
Sudhanshu Gupta23-Dec-08 19:30
Sudhanshu Gupta23-Dec-08 19:30 
Generalpls help me ! Pin
tuan1798323-Dec-04 3:57
tuan1798323-Dec-04 3:57 
GeneralISO 13818-1 Pin
Colin Urquhart14-Apr-04 21:21
Colin Urquhart14-Apr-04 21:21 
GeneralRe: ISO 13818-1 Pin
ro_angel_bv15-Apr-04 0:07
ro_angel_bv15-Apr-04 0:07 
GeneralRe: ISO 13818-1 Pin
hjschmidt17-May-04 2:58
hjschmidt17-May-04 2:58 
GeneralInteresting... Pin
don_cavaro14-Apr-04 1:06
don_cavaro14-Apr-04 1:06 
GeneralRe: Interesting... Pin
ro_angel_bv14-Apr-04 2:31
ro_angel_bv14-Apr-04 2:31 
GeneralArticle Quality Pin
Carlos H. Perez29-Mar-04 13:19
Carlos H. Perez29-Mar-04 13:19 
GeneralRe: Article Quality Pin
ro_angel_bv29-Mar-04 19:50
ro_angel_bv29-Mar-04 19:50 
GeneralRe: Article Quality Pin
Jonathan C Dickinson21-Jul-08 1:26
Jonathan C Dickinson21-Jul-08 1:26 
GeneralUpload the code, or don't upload at all! Pin
Mark Belles29-Mar-04 11:15
Mark Belles29-Mar-04 11:15 
GeneralSource Code Pin
ASerfes29-Mar-04 4:52
ASerfes29-Mar-04 4:52 
GeneralRe: Source Code Pin
ro_angel_bv29-Mar-04 19:59
ro_angel_bv29-Mar-04 19:59 
I understand you're interested in the topic ?

Angel

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.