Click here to Skip to main content
11,705,453 members (50,275 online)
Click here to Skip to main content

An analyzer for MPEG 2 Program Stream files

, 12 Apr 2004 151.3K 3.4K 87
Rate this:
Please Sign up or sign in to vote.
Simple program that interprets a MPEG 2 file.

Intro:

This program is about demultiplexing a MPEG 2 movie file to its elementary packets. The program is a standalone release that I developed after the TS_Constructor program and represents the next step in multiplexing elementary streams for the HDTV standard.

The concept:

You know, of course, that a movie file of any type must contain specific info (audio, video, data and other stuff). What this program does is to identify and list detailed info on a MPEG 2 standard file. Each movie file is encoded in specific packets. Each packet serves a purpose: you have video packets, audio packets, stream specific packets (as PACK Header, System Header or PSM-Program Stream Map packet). Video and Audio packets usually form the ES (Elementary Streams) of a movie file and are encoded in PES (Packetized Elementary Streams) packets. One or more PES are regarded as PACKS, delimited by PACK Headers, as shown in the figure below that explains how a MPEG 2 stream is composed:

Sample screenshot

The program:

PS_Analyzer counts every type of packet in an input MPEG 2 file. The counts are displayed on screen while detailed info (type, number, size, SCR, PTS, DTS) for each packet as well as an overall statistic, is listed to an output text file specified by the user. As a note, SCR stands for System Clock Reference and is found in every PACK Header, PTS stands for Presentation Time Stamp and indicates the decoder when a specific picture or sound is to be displayed, DTS stands for Decoding Time Stamp and indicates the decoder when a certain picture or sound is to be decoded, because the order of images in a MPEG 2 file isn't the order of viewing when displayed as a movie. All this values are given in milliseconds. This concept isn't something new at all, you'll find the same idea in BBTOOLS sources from the BBMPEG project. The difference might be that this isn't a console application and is specifically developed for MPEG 2 files (also known as Program Streams). The program isn't too fancy but surely is functional and easy to use. It features only two forms, a main form, and a BROWSER form to help retrieve MPEG 2 files that are in different locations as the program.

Main window (at start):

Sample screenshot

This is how the program looks when you start it.

Main window (after processing a file) :

Sample screenshot

This is how the main window looks after a successful process.

Browse window:

Sample screenshot

This is the browse window used to change the current directory.

Output text file:

That's what you'll see in the output text file after processing a MPEG 2 stream:

Sample screenshot

at the beginning of file.

Sample screenshot

at the end of file.

Author notes:

This program might prove very useful. Apart from extracting info on a MPEG 2 files, with slight modifications it can be used to read any type of movie or to demultiplex a movie into Elementary Streams (Audio & Video components). The down side might be that comments are mostly in Romanian, but giving the MPEG 2 organization picture provided and the ease of C# classes, I hope it is not too hard to decipher the source code.

For impressions regarding this program or discussions related to this subject, 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

Share

About the Author

ro_angel_bv
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

You may also be interested in...

Comments and Discussions

 
QuestionMpeg Containers Pin
jfriedman13-Dec-14 2:45
professionaljfriedman13-Dec-14 2:45 
QuestionHow to analyze mpeg2 video ES? Pin
lyon19889-Mar-09 3:24
memberlyon19889-Mar-09 3:24 
GeneralWant to know about iFrames Pin
ayaz_tata21-Dec-08 20:18
memberayaz_tata21-Dec-08 20:18 
GeneralMPGE4 Support Pin
harmonicbox24-Jun-08 23:51
memberharmonicbox24-Jun-08 23:51 
GeneralReally good job Pin
Saifbuet21-Oct-07 5:24
memberSaifbuet21-Oct-07 5:24 
GeneralNeed sample H264 Program streams Pin
prashanth_d_4-Oct-07 1:10
memberprashanth_d_4-Oct-07 1:10 
Generali need your TS_constructor source Pin
yousef z20-Aug-07 1:45
memberyousef z20-Aug-07 1:45 
QuestionWonderful job. Do you have C++ version of that source? Pin
Alexey.Andriyashev@usethelink.com28-Mar-07 5:49
memberAlexey.Andriyashev@usethelink.com28-Mar-07 5:49 
AnswerRe: Wonderful job. Do you have C++ version of that source? Pin
Balusamy16-Oct-07 19:45
memberBalusamy16-Oct-07 19:45 
AnswerRe: Wonderful job. Do you have C++ version of that source? Pin
Balusamy16-Oct-07 19:45
memberBalusamy16-Oct-07 19:45 
AnswerRe: Wonderful job. Do you have C++ version of that source? Pin
hyunoh17-Aug-08 15:59
memberhyunoh17-Aug-08 15:59 
QuestionHelp Required ... Pin
khawaja kamran13-Dec-05 21:35
memberkhawaja kamran13-Dec-05 21:35 
GeneralGr8 JOB !!! Pin
Anonymous8-Jun-05 6:02
sussAnonymous8-Jun-05 6:02 
QuestionHow to configure? Pin
kuchta5-Apr-05 22:45
memberkuchta5-Apr-05 22:45 
GeneralNice! Small question Pin
comrade11-Aug-04 17:34
membercomrade11-Aug-04 17:34 
GeneralRe: Nice! Small question Pin
Anonymous7-Sep-04 3:03
sussAnonymous7-Sep-04 3:03 
GeneralNice Job Pin
ivisaf6-May-04 18:35
memberivisaf6-May-04 18:35 
GeneralOne more thing... Pin
ro_angel_bv28-Apr-04 5:14
memberro_angel_bv28-Apr-04 5:14 
GeneralRe: One more thing... Pin
Anonymous22-Apr-05 17:19
sussAnonymous22-Apr-05 17:19 
GeneralReally nice job Pin
danich_roxa14-Apr-04 0:57
memberdanich_roxa14-Apr-04 0:57 
GeneralRe: Really nice job Pin
ro_angel_bv14-Apr-04 2:25
memberro_angel_bv14-Apr-04 2:25 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 13 Apr 2004
Article Copyright 2004 by ro_angel_bv
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid