Tech Tip - Updating Time Code in MPEG streams

Encoders Optimized for HIgh Resolution Formats


PixelTools MPEGRepairHD can reset the time code throughout an existing MPEG stream. The process is fast and simple: you specify the starting time code and the tool updates the time codes in all of the GOP headers.  This process works on MPEG2 and MPEG1 transport, program, system, and elementary streams.


Updating Time Code with MPEGRepairHD

To update the GOP time code of any MPEG stream, launch MPEGRepairHD and browse to your MPEG stream with the File to Decode or Analyze button.  Next, depress the Decode | Configure button and select the Fix Stream tab. Check the “Reset MPEG Time Code” box on the lower right of this dialog.  This enables the Hour, Minute, Second, and Frame edit boxes.  Enter the time code that you wish to be set in the first GOP header of your stream.  Check the “Drop Frame” check box if you want the calculations to include drop frames.  Next, enter or browse the full path name of the file you wish to store the updated MPEG file in the upper left “Save Fixed File” edit box.  If your source file is multiplexed as a TransPort, Program, or System stream, you can cause the output to be an exact duplicate of the source stream multiplexing structure by checking the “Save Multiplexed Format” check box. Selecting OK to close the dialog box and depressing the Control Decode | Run button will cause MPEGRepairHD to process the MPEG file. The first GOP header will contain the time code you specified.   Subsequent GOP headers will be stamped with the time code appropriate for the frame number, frame rate, and drop frame options you have selected.

Note that you can speed up this process by depressing the small button with the red line running through the monitor to disable display of each frame.

Updating Time Code with Expert WorkShop SDK

The SDK can be set up to replace time code in a source file and save the result as a new file.   Set up the Decode section as illustrated in the sample source code.  Before calling the ExpDecodeConfigure function, set the following parameters in the ExpDecFix_str structure:

EnSetTimeCode to true to cause time code update during decode

DecodeFixName to contain the name of the file you wish to save the updates to.

int TimeCodeHour; to the appropriate starting time code
int TimeCodeMinute;
int TimeCodeSecond;
int TimeCodeFrame;
bool DropFrame;

SaveAsMuxedFile true if your source is multiplexed and you want the original multiplexing format implemented in the updated file.  Set this value to false if your source is an elementary stream or you want your multiplexed source file saved as an elementary stream with the updated time code.

To run the time code update operation, call ExpDecodeNextFrame for the length of the source video.



MPEGRepair can update the time code throughout the entire stream.

The time code is stored in each GOP header in the video elementary stream.

The starting time code can be specified in terms of Hour, Minute, Second, and Frame. 

Subsequent GOP time codes will be updated with the values based on the starting time code and appropriate to the source’s frame rate, frame number, and DropFrame settings.

The operation occurs in the elementary video stream. 

MPEGRepair can retain the multiplexed structure in Transport, Program, VOB, and System stream if the Save As Muxed File option is selected.   If the Save As Muxed File option is not selected, the resultant updated stream will be an elementary video stream


MPEGRepairHD and ExpertWorkshop SDK are trademarks of PixelTools Corporation. All other brand names are trademarks or registered trademarks of their respected holders

Let us know if we can help or request a free demo of our products. View our products features at a glance.

Visit our products page and check out at our PixelTools Store to purchase any of our products

Thank you for your interest in PixelTools


| Contact Us

© 2020 PixelTools| Privacy Policy |