Mpeg 2 Software

In this article, we are going to show how to add and retrieve closed-caption data to the AVC and MPEG2 streams through Intel® Media Server Studio and Intel® INDE. In the first part, we will illustrate using code examples how to add CC messages to the AVC and MPEG2 streams. In the second part, we will show how to retrieve these messages using the decoder.

  1. Mpeg 2 Software
  2. Mpeg 2 Capture Software
  3. Mpeg 2 Encoder Software
  4. Mpeg-2 Reference Software
  5. Mpeg-2 Encoder Software

Free MPEG Player is a program that enables you to play MPG and MPEG files. Once the program is initiated, the files can be added onto the tool and played immediately. It provides functions such as play, stop, pause, fast forward and rewind. Motion monitors the video signal from one or more cameras (video4linux interface) and is able to detect if a significant part of the picture has changed. Features: interval snapshots, live streaming webcam, mpeg generation, database interface, OSD etc. For the latest releases and deb packages go to the Motion home page.

To test the closed-captioning in AVC/MPEG2 using the following code snippets, we recommend using the tutorials instead of the samples. (You can download the tutorials from the TUTORIALS tab here). The tutorials are much easier to understand and have more comments to help you. For encoding, simple_6_encode_vmem_lowlatency tutorial, and for decoding, simple_2_decode tutorial. In the code snippets below, we point you to the location where this code should be added for encode and decode.

Mpeg 2 Software

Let's get started!

Adding Closed-caption Messages to the AVC and MPEG2 Encode Stream

In this section, we will see how to add closed-caption data to AVC and MPEG2 streams during the encoding stage. Below are the high-level how-to steps, and we will follow that up with a code snippet.

Step 1: Create the SEI/user_data payload with the appropriate header and message fields. For details on the AVC and MPEG2 payload structures, refer to this document. You can also refer to the following - for AVC stream (Section 6.4.2 in the document), and for MPEG2 stream (Section 6.2.3 in the document).
Step 2a:Populate the mfxPayload structure with this payload and header information.
Step 2b: Pass the mfxPayload structure to mfxEncodeCtrl structure
Step 3:Pass this structure to the EncodeFrameAsync function (first parameter), and you're done!

Code example to add CC messages to AVC, in the main encoding loop:

Code example to add CC messages to MPEG2, in the main encoding loop:
Adding payloads to MPEG2 is similar to the AVC example above. The difference comes from the format used for the MPEG2 user_start_code as compared to SEI message. Below, we illustrate how to populate an MPEG2 payload. This is in accordance to the ATSC standard for MPEG2 Video.

In this section, we have seen how to add payloads to the AVC and MPEG2 encode stream. You can verify the payloads are added by opening the output bitstream in an editor and viewing in HEX mode (for instance, GVim). You should see each frame carrying a payload that has the 'Frame: <framenum>' along with the payload meta information. Below is an encoded out.h264 file that uses the above-mentioned code snippet in simple_6_encode_vmem_lowlatency tutorial to add CC captions. You can see the SEI message 'Frame: 6' highlighted.

Mpeg 2 Capture Software

Mpeg 2 Software

Mpeg 2 Encoder Software

Retrieving Messages from the Decoded Stream

We just saw how to add CC messages to the encode stream. In this section, we will see how to retrieve the encoded SEI/userData messages from the AVC or MPEG2 streams respectively. The SDK provides an API GetPayload() for this purpose, and we will illustrate how to use this for AVC and MPEG cases. The GetPayload() function follows the DecodeFrameAsync() function call, and returns the mfxPayload structure populated with the message, number of bytes and timestamp. Please note that you are required to initialize the BufSize and Data members of the structure before you call the GetPayload() function.

Mpeg-2 Reference Software

Below is the output of the fwrite for decode of out.h264 file we encoded above. On the console is printed the output of the GetPayload() call for each frame.

Mpeg-2 Encoder Software


This concludes our howto add and retrieve CC messages in AVC and MPEG2 stream. You can also refer to our documentation section 4.14 for the pseudo-code, and for information on the APIs, you can refer to the mediasdk-man.pdf in the doc folder of the Media SDK install folder.