|
|
|
 |
| Tech
Tips
- Closed Captioning Insertion |
|
Overview
PixelTools
products can insert and extract closed
captioning into and from an MPEG stream. The closed captioning source
can be the actual closed captioning text strings along with their associated
time code, formatted captioning codes (as in a .scc file) or formatted
user data.
PixelTools MPEGRepairHD can:
- Insert CC Data into elementary video streams during encoding or
to existing encoded elementary streams
- Extract and display digital and analog CC data from elementary
and multiplexed streams
- Encode CC data per CEA-708, CEA-608, ATSC, or DVD specifications
- Transcode between CC formats
- Automate processing via batch mode
Expert WorkShop SDK can:
- Embed all of the above CC processing in your
application
Demo of Closed Captioning functionality
Download the closedcaptiontrial.zip file
to obtain a demo version of MPEGRepair that is configured to illustrate
some of the closed captioning insertion and display capability.
Unzip the
file into a directory and run the CCDemo.bat file to launch the demo. The demo will automatically encode a file adding the
closed captioning the text strings stored in the Expert.edl file. The
demo will then decode the newly encoded MPEG file so you can see the
closed captioning displayed over the video.
Adding closed captioning via
MPEGRepairHD GUI
During Encoding
Closed captioning insertion is
controlled via the Encoding Decision List (edl) text file. The EDL
file is read during the encode operation. The
EDL file contains the closed captioning text string and the first frame
number or time code where the text string will appear. The
EDL file must be named Expert.edl and must be located in the directory
where your encoded MPEG file is being stored. The CLOSEDCAPTION command
specifies the closed captioning text string. An example of the
format of the closed captioning is presented in the top of the sample
Expert.edl provided with the product. The formatted closed
captioning data is added to the appropriate frame user_data fields
as requested in the Expert.edl file.
Using Raw
Text as Input
The following is an example of the Edl closed captioning file commands:
FRAME 1038
CLOSEDCAPTION
The little brown cow jumped over
FRAME 1146
CLOSEDCAPTION
the moon!
Using
Closed Captioning .SCC file as Input
The closed captioning EDL file can also be of popular closed caption
file format (.scc) which consists of the time code followed on the
same line by a sequence of sets of 4 HEX codes representing the actual
closed captioning data that will be added to the video user_data.
The following is an example of the Edl with formatted closed captioning
command:
00:00:00:14 9426
9426 94ad 94ad 9470 9470 9137 9137
00:00:13:06 942c
942c
Using
Line 21 Hex data as Input
Also, any pre-formatted closed captioning data (using any closed
captioning standard) can be added via the HEXUSERDATA edl command. Just
add the frame number or time code of the frame user data and the actual
user data, up to 72 characters long, after the HEXUSERDATA command.
. An example of the format of the hex user data is presented
in the top of the sample Expert.edl provided with the product.
The following is an example of the Edl raw user data file commands:
FRAME 1038
HEXUSERDATA 04 ff 29 d0 55 9f 28 44
FRAME 1039
HEXUSERDATA 05 ff 39 d4 22 9f 28 44
FRAME 1102
HEXUSERDATA 05 ff 39 d4 22 9f 28 44
Closed Captioning Format
The Closed Captioning Format selection controls
the actual formatting of the text or SCC EDL and DDL commands into
the MPEG user data and controls the specific user data locations.
The Format selection control is located in the Encode section of
MPEGRepairHD in the Optimize Encode | Configure | Line 21 property
page. Note
that the insertion of closed captioning data into an existing stream
using the Decode Fix process utilizes the Closed Captioning Format
set in the Encode configuration.
The following Closed Captioning format options are available:
CEA 708 DTV
This option causes up to eighteen closed captioning characters to be inserted into picture header user data fields in display order. When converting text to CEA-708 data, DTV Window 0 will be initialized and enabled. Your closed captioning text will be written to this window at the specified frame or time code.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show Picture user data that will start with the Hex values: 47 41 39 34
CEA 708 NTSC
This option causes up to two closed captioning characters to be inserted into picture header user data fields in display order. These bytes are added to the NTSC channel in the field per your Closed Captioning Style selection. This channel was designated by the CEA to facilitate legacy closed caption processing in CEA-708 systems.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show Picture user data that will start with the Hex values: 47 41 39 34
CEA 708 DTV & NTSC
This option causes up to eighteen closed captioning characters to be inserted into picture header user data fields in display order and up to two closed captioning characters to be added to the NTSC channel in your selected field. When converting text to CEA-708 data, DTV Window 0 will be initialized and enabled. Your closed captioning text will be written to this window at the specified time. This option causes the same closed captioning text to be written to both the CEA-708 window and the NTSC channels.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show Picture user data that will start with the Hex values: 47 41 39 34
CEA 608 (default)
This option causes up to two closed captioning characters to be inserted into picture header user data fields in transmission order. The characters will be entered into the Field 1 or Field 2 closed captioning field per your Closed Captioning Style selection.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show Picture user data that will start with the Hex values: 02 09
ATSC / CEA 608
This option causes up to two closed captioning characters to be inserted into picture header user data fields in display order. The data formatted per CEA-608 and is wrapped in a SCTE-21 and ATSC header. The characters will be entered into the Field 1 or Field 2 closed captioning fields per your Closed Captioning Style selection.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show Picture user data that will start with the Hex values: 47 41 39 34
DVD
This option causes up to 30 closed captioning characters to be inserted into GOP header user data fields. The first set of user data will be inserted at the first GOP at or after the Frame number or time code set in the EDL or DDL file. The remaining user data (over the 30 character per GOP limit) will be inserted in subsequent GOP headers. The characters will be entered into the Field 1 or Field 2 closed captioning field per your Closed Captioning Style selection.
Analyzing the actual user data using the MPEGRepairHD Decode Statistics window will show user data at EVERY GOP header that will start with the Hex values: 43 43 01 f8 9e. The GOP headers will contain the closed captioning data or will contain NULL data.
To an existing MPEG
stream
Closed captioning can be added
to an existing elementary stream. This is accomplished using the PixelTools
decode functionality in conjunction with a Decision List (ddl) text
file. The DDL file contains the
closed captioning text string and the first frame number or time code
where the text string will appear. The DDL file must be
named Expert.ddl and must be located in the directory where your output “fixed” MPEG
file is being stored. To enable processing of the Expert.ddl file,
check the Decode Function Enable | Configure | Fix Stream | Use Commands
in DDL file option and enter the name of the file the will include
the closed captions in the Save Fixed File edit box. The CLOSEDCAPTION
command in the Expert.ddl file specifies the closed captioning text
string. An
example of the format of the closed captioning is presented in the
top of the sample Expert.ddl provided with the product. The
formatted closed captioning data is added to the appropriate frame
user_data fields as requested in the Expert.ddl file after depressing
the Control Decode | Run button with your source file in the Decode
MPEG File to Decode or Analyze edit box . You can speed up the process
by depressing the Speed button with the slashed monitor to disable
decode display.
The ddl file format is similar to that of the
edl file format presented above. In addition to the text strings
supported with the CLOSEDCAPTION command, any formatted user data can
be inserted via the HEXUSERDATA command. Also, the .scc closed
caption format is supported. (Be sure to rename the .scc file as Expert.ddl).
Displaying closed captioning
via MPEGRepairHD GUI
The MPEGRepair Decoder can extract and display closed captioning information
in several formats.
Hex User Data
 |
Opening the Decode Statistics window (by
depressing the St speed button) and selecting the View | Video
Statistics | User Data will display the hex values of all user
data as it is encountered in the stream. Note that the data will
be encountered in transmission order not display order.
Click on image to see actual size. |
Closed Captioning Data
Opening the Decode Statistics window (by depressing the St speed button) and selecting the View | Video Statistics | Closed Captioning | Your Option will display your selected captioning type as it is encountered in the stream. The data will be the ASCII closed captioning text and the closed captioning control codes. Note that the data will be displayed as it is encountered in transmission order not display order.
CEA Field1
CEA Field2
This format includes two CC bytes per frame in display or transmission order. The data consists of the basic CEA-608 format which starts with 02 09 80 80. The Field1 and/or Field2 options result in the selected field(s) being extracted and translated into the statistics window. This selection also decodes the two NTSC CC bytes of CEA-708 data or the ATSC/CEA-608 CC bytes in transmission order. The CEA-708 and CEA-608/ATSCdata starts with 47 41 39 34.
DVD Field1
DVD Field2
This format includes 20 CC bytes per GOP in display order. The data consists of a sequence of CEA-608 data byte pairs which starts with 43 43 01 f8. The Field1 and/or Field2 options result in the selected field(s) being extracted and translated into the statistics window.
CEA-708 All
This format includes 18 CC bytes per picture in display order. The data displayed via this option is the 708 control codes and ASCII text for all 8 possible 708 windows. This option does not display the two 708 NTSC byte pairs per frame. (These are displayed using the CEA Field1 and CEA Field2 options.)
CEA-708 Window1 ->Window8
These options display only the control codes and ASCII text for the selected CEA-708 window.
|

Click on image to
see actual size.
|
Click on image to
see actual size. |
Closed Captioning Overlay
Opening the Decode Display window using the De speed button will bring up a window that will display all of the frames in display order. Selecting the Text Overlays | Closed Captioning | Your Option will cause all of your selected closed captioning text detected in the stream to be over laid on the decoded video.
The Field1 option displays all Field1 captions that have been added via the CEA-608, ATSC, DVD, or CEA-708 NTSC standards. The text appears with a greenish color above the Field2 text.
The Field2 option displays all Field2 captions that have been added via the CEA-608, ATSC, DVD, or CEA-708 NTSC standards. The text appears with a reddish color below the Field1 text.
The CEA-708 option displays all of the CEA-708 captions that are written to windows 1 through 8. The text appears with a bluish color below the Field2 text.
|
Extracting Digital Closed Captioning Data
Select your file containing the digital closed
captioning in the File to Decode or Analyze Edit box. In the
Decode Configure | Extract Streams dialog, check the Save Digital Data
option and enter or browse the name of the file to hold your extracted
data. Runing the decoder will cause all user_data to be saved in your
selected output file.
Extracting Analog Closed Captioning Data
Select yuor file containing the analog closed
captioning in the File to Decode or Analyze Edit box. In the
Decode Configure | Extract Streams dialog, check the Save Analog Data
option and enter or browse the name of the file to hold your extracted
data.
Runing the decoder will cause the two CC bytes
to be extracted from the analog modulated white line at the top of
each frame. The parity
bit will be stripped off of the data before it is saved. The data
in your selected analog CC file will be ASCII text which will include
the CC words displayed on the screen. The data will also include
the CC control characters which will be intermixed with the readable
text.
Extraction in the Statistics Log
All data displayed in the Decode Statistics Log
will also be stored in the Decode.log file. You can select between
the raw user_data and the translated ASCII text and control codes using
the Decode | Statistics | Video Statistics menu options.
Adding closed captioning via ExpertWorkshop SDK
During Encoding
To enable the addition of closed
captioning data while encoding a file, create an encoding edl text file
as described above using the CLOSEDCAPTION, or HEXDATA commands or use
one of the supported closed captioning file format. Use the EdlFullFileName
configuration parameter to point to the edl file. During the ExpEncodeNextFrame
API command, the selected edl file will be read to determine if any
closed captioning data needs to be added to the user_data in the encoded
frame.
The two closed captioning bytes also be added to
each frame by adding them to the ClosedCaptionBuffer parameter
of the calls to ExpEncodeNextFrame. These
two bytes will be stuffed into video user_data using the format and wrapper
as defined in the Closed Captioning Format.
During Decoding
To enable the addition of closed
captioning data while decoding a file, create a decoding ddl text file
as described above using the CLOSEDCAPTION, or HEXDATA commands or use
one of the supported closed captioning file format. Store the name of the resultant MPEG file that will contain
the closed captioning data in the DecodeFixName member of the ExpDecFix_str. The
ExpDecFix_str is a member of the VidDecodeParams_struc which is sent
to the decoder as a member of the ExpDecConfigure API call. During
calls to ExpDecodeNextFrame, the source stream is written to the resultant
MPEG stream along with the appropriate user_data containing the closed
captioning text per the ddl file.
Closed Captioning Insertion Format
The Closed Captioning Format is set using the ExpEncodeConfigure call
where the
ExpEncParameters_str | Line21Params_struc CCType contains the
actual format.
CCType of
CEA608 = 0, ATSC_CEA608 = 1, or DVD_CC = 2.
Specification
The CGMS and APS flags are added to the MPEG video
user data as Extended Data in the line 21 emulation of digital data as
specified in the Advanced Television Systems Committee Inc (ATSC) Digital
Television Standard A/53, the ISO/IEC 13818-2 MPEG video standard, the
Society of Cable and Telecommunications Engineers (SCTE) ANSI/SCTE 20
2004 Methods for Carriage of Closed Captions and Non real-time Sampled
Video and ANSI/SCTE 21 2001 Standard for Carriage of NTSC VBI Data in Cable Digital Transport Streams specification, and the Consumer Electronics Association CEA-708-B Digital Television (DTV) Closed Captioning specification, and the Consumer Electronics Association CEA-608-C Line 21 Data Service specification.
Supplemental Information
Line 21 data can have many uses and is governed by multiple overlapping
specifications in support of government and industry regulations. A
little history may aid in the understanding of the features.
Analog
In the 1970’s, extra bandwidth was exploited in the television
broadcast signal that occurred in a normally dead period while the electron
gun was being repositioned to start the painting of each new field. A
US federal mandate required that most broadcasts include closed captioning.
It was determined that two ASCII characters could reliably be included
in the vertical retrace interval (line 21) right before the first visible
horizontal line. Simple decode circuitry was mandated to
be included in all TVs that would provide the extraction and storage
of the line 21 data and allow the TV user to add the closed caption characters
as an overlay to the video in the next fields. Other industry users
fought for access to the line 21 data. The Copy Generation Management
System (CGMS) provided a three state flag that would cause new industry
and federally mandated TV decoders to prevent copying of selected video
content. The flags are “Copy Freely”, “Copy Once”,
and “Copy Never”. The old Macrovision technology of
interfering with the TV broadcast synchronization signals to prevent
video copying was also embedded in line 21 data with Analog Protection
System (APS) flags that instruct the video decoder to interfere with
selected synchronization signals. Also video content rating, program
type information, and program schedule data is broadcast via the line
21
Digital
The advent of MPEG compressed video brought with it more possibilities
for higher bandwidth closed captioning channel and other supplementary
data channels. One of the digital constraints though was to make
the new system backwards compatible with older TV technologies IE allow
for just two bytes of data per field. This evolution has resulted in
a large array of specifications that support the new and old capabilities.
Line 21 data can be added to user_data of each frame of elementary
MPEG video. Line 21 data can also be added as a special stream
within a MPEG transport stream.
Specifications
The Consumer Electronics Association publishes CEA-608-C Line 21 Data
Service that details data formats for closed captioning services and
extended data (including CGMS and APS). The CEA publishes CEA-708-B
Digital Television Closed Captioning that details usage of a 9600 bps
closed channel (ten times the bandwidth of the original channel). The
Advanced Television Systems Committee Inc (ATSC) publishes the Digital
Television Standard A/53 specification that details a format for adding
line 21 data to user_data of an MPEG-2 stream. The International
Organization for Standardization (ISO) publishes the ISO/IEC 13818-2
MPEG video standard that details the inclusion of user_data in compressed
video streams. The Society of Cable and Telecommunications Engineers
(SCTE) publishes the ANSI/SCTE 20 2004 Methods for Carriage of Closed
Captions and Non real-time Sampled Video and ANSI/SCTE 21 2001
Standard for Carriage of NTSC VBI Data in Cable Digital Transport Streams
specification that defines additional VBI services.
PixelTools line 21 support
At the lowest level, MPEGRepairHD is capable of adding frame accurate
user_data during MPEG encoding or to an already existing video elementary
stream. This will support all of the above data services provided
that the data is packaged in the correct format. MPEGRepairHD can add
up to 128 eight bit data bytes to designated frames during encoding
using an Encoding Decision List (EDL) file or to an existing MPEG stream
using a Decoding Decision List (DDL) file. These text files specify
the frame number and corresponding data bytes which will be inserted
in the user_data at the selected picture header. The data bytes
must be formatted appropriately per the desired usage. The encoding
EDL and the decoding DDL files utilize the identical format.
At a higher level, MPEGRepairHD can add CEA-708 or CEA-608 closed captions during encoding or to an existing stream as listed
in a simple text file. The EDL command file reads closed caption text
strings, formats your closed caption text and inserts it into user_data
fields starting at your requested frame number. The MPEGRepairHD
Decode | Configure | Fix Stream dialog also allows selection of a similar
DDL closed caption text file that will be formatted and added to an
existing MPEG stream. The Encode and Decode closed caption text commands
are of identical format.
regarding current status of
adding Line 21 data as a separate transport layer within a transport stream.
MPEGRepairHD
and ExpertWorkshop SDK are trademarks of PixelTools Corporation.
All other brand names are trademarks or registered trademarks of
their respected holders
©1998-2007
PixelTools Corporation |