|
|
|
 |
| Tech
Tips
- MPEG Clip Extraction |
|
Overview
PixelTools products can extract a frame accurate
segment from any MPEG stream. You can also extract a specific frame
from any MPEG stream.
Demo of Frame Extraction
Download the clipextractiondemo.zip file to obtain a demo of MPEGRepairHD that can be used to extract a frame specific segment from an MPEG of
your choice.
Download the clipextractiondemosdk.zip file to obtain a working sample
code that will program a demo of the Expert Workshop SDK to extract a
segment of MPEG from an MPEG of your choice.
Clip Extraction using MPEGRepairHD

Overview
MPEGRepairHD can extract a frame accurate clip from a larger MPEG via
a simple two step process. First decode the segment and save the
uncompressed frames in a folder. Then re-encode the frames using
the MPEGRepairHD high quality encoder. Click on image for larger
view.
Details
Launch MPEGRepairHD and select your source MPEG file in the “MPEG
File to Decode of Analyze” edit box. Depress the Run button
and view the video in the encoder’s mini-monitor or the full
size display via the “de” speed-bar button. You can
use the decoders “Seek” button to advance to the region
you wish to extract. Note that the first few frames after seek
may be corrupted. You can also use the Step button to obtain
better control than the Run button. When MPEGRepairHD decoder
is at the frame just ahead of the segment you wish to extract, depress
the Pause button (if in the Run mode), check the Decode Configure | Extract
Frames | Store Decoded Frames check box, and enter the full path name
of the first frame that will be saved. The name must have an
embedded 0 and must have an extension of YUV, TGA, or BMP to extract
in the YUV, MicroSoft Bitmap, or Univision Targa file format. Then
depress the Run or repeatedly depress the Step button to decode until
the end of your selected segment.
Next, encode your saved files by entering the
first decoded frame name in the encoder’s Encode Input edit box. Set up the
encoding parameters as needed using the Optimize Encode | Configure
options. (You can use the Decoder’s Analyze button to obtain
the encoding parameters of your source file.) Enter the name of the
file you wish to use as the clip name in the Encode Output and depress
the Encoder’s Run button to create the frame accurate clip.
Clip Tips
If you don’t require frame accurate clip extraction and have
an elementary stream (IE not a multiplexed stream), you can use the
Cut Segment Operation to extract the clip. Just decode (using
Seek if desired) to the area you wish to extract. Depress the
MarkIn button at the start of your segment and the MarkOut button at
the end of your segment and depress the Cut button after about 15 frames
have passes since your MarkOut point. MPEGRepair will have calculated
the nearest GOP edit points. Entering the name or your output
clip in the Resultant Stream edit box and depressing the Cut Now button
will cause your selected clip to be saved.
Clip Extraction Using Expert Workshop SDK
Overview
The Expert WorkShop SDK can be used to extract a frame accurate clip
from a larger MPEG within your current application via a simple two
step process. First open your source file, advance or seek to a point
ahead of your extraction point, enable the frame extraction option,
and then run the DecodeNextFrame function for the duration of your
segment to be saved.
Details
Load the Expert WorkShop Dll and extract the functions. Call the ExpDecodeOpen
function with the name of the source file you wish to extract. The
ExpDecInfo structure will be returned with a plethora of information
about your source MPEG. Use the FirstTC and LastTC members
to obtain the precise length of your source video. Pick a point
about a second ahead of the start of the clip you wish to extract. Convert
this start time to the stream time using the timescale returned in
the ExpDecInfo structure. Next make a call to ExpDecodeNextFrame
to start the decoding and then execute the ExpDecodeSeek function
with your computed offset time. The seek function will return
the actual time (in units of the timescale). Next,
call ExpDecodeNextFrame to advance to a frame just before the first
frame of the clip you wish to extract. Clear the WriteEnable
boolean of the ExpDecConfigure structure and add the name of the
first decoded frame to DecPicPrefix, DecFirstPic (number) and DecPicSuffix. The
DecPicSuffix must be YUV, BMP or TGA to cause the decoder to save
the extracted frames as YUV, MicroSoft Bitmap, or Targa formats.
Execute the ExpDecodeConfigure function to apply the new parameters. Call
the ExpDecodeNextFrame for the number of frames in the clip you wish
to extract.
Finally, encode the extracted frames using
the same parameters found in the source stream. Call ExpEncodeOpen
to launch the encoder and return the default parameters in the ExpEncParameters_str
file. Set
up the appropriate parameters (as returned in the ExpDecInfo structure
and load them using the ExpEncConfigure function call. Call
ExpEncodeNextFrame for the number of frames in the clip and then
call ExpEncodeLastFrame to flush the encoding buffer.
Specification
The PixelTools MPEGRepairHD and Expert
WorkShop can be used to extract a frame accurate segment from a larger
MPEG stream. The MPEG stream
can be an elementary or multiplexed stream. The resultant re-encoded
clip will be an elementary stream.
MPEGRepairHD
and ExpertWorkshop SDK are trademarks of PixelTools Corporation.
All other brand names are trademarks or registered trademarks of
their respected holders
©1998-2008 PixelTools Corporation |