Intro
Mark Wilczynski's MPEG2Repair
tool is an excellent way to fix up corrupted MPEG2 transmission streams
to make them more palatable to editors and media players -- not to
mention making them a little smaller by the amount of garbage that's
removed.
I just came across the tool yesterday (2/15/2007), and I love it.
Unfortunately, for reasons I don't entirely understand, Mark does
not seem inclined to add command-line parameter parsing to the program.
(Who am I to question it? The guy's a video genius, and I'm
not; should I expect him to be everything?)
A solution to the problem
Enter
mpeg2repairHelper. This is a brutal hack that allows you to
control MPEG2Repair from scripts. Written in Delphi, you just toss a
single file into the same directory as Mark's program.
To use it, type something like:
mpeg2repairhelper "c:\input file.ts" "c:\output file.ts"
For more detailed usage information, type mpeg2repairhelper without any parameters.
How it works
The
program launches mpeg2repair, types in the input filename, scans the
PIDs, waits 5 seconds to [hopefully] give it time to find 'em, fills
out the rest of the form, hits the start button, hangs around and waits
for it to finish, then exits.
In addition to the output file, two logs are created:
"c:\output file.ts.txt"
This is placed in the same directory as your output file.
mpeg2repairHelper.LOG
This is placed in the same directory as the program.
It is appended to each time it runs.
(side note: This program started off as a console application, but I found
that I couldn't get my AppActivate routine to work in that mode, so I
made it a Windows app with a form.)
Caveats
Trying
to locate other Windows programs and sending keystrokes to them is
not the most robust method of control. My biggest concern is that
the 5 second delay may not be enough for fat files on slow systems.
If that proves to be the case, maybe I'll add an optional
parameter to vary the amount of time it waits.
The
tab order of mpeg2repair's is not visually intuitive in the case of
multiple audio streams; the stream selection dropdown (bottom of form)
comes between the source & destination file selection at the top of
the form. When there is only one audio stream, this control is skipped
entirely, and will throw everything out of whack unless you add
"/SAT" (for "single audio track") as a parameter.
In
the
case of multiple audio tracks, the first is chosen by default,
unless you specify an alternate track with the "/AT" parameter.
Thanks to Haudy for suggesting the "Alt-Tab" for making the audio
track selection possible. It's an ugly hack of a hack, but it works
most of the time. (If Mark ever wants to tweak his form to make
it
a bit easier, or -- far better yet -- collaborate to add native
command-line parsing, it would help the reliability a bit!)
Downloads
mpeg2repairHelper.7z (138k)
Source Code (20k)
Don't know what to do with a .7z file? Visit http://7-zip.org.
Change Log
1.4 - 02/02/2008 - Option to select a specific audio track
1.3 - 07/04/2007 - Option to suppress video output (log only)
1.2 - 07/02/2007 - Handles streams with only a single audio program
1.1 - 02/20/2007 - Handles special chars in filenames; added abort button,clock
1.0 - 02/16/2007 - Created
Feedback
Questions, Comments, Suggestions?
Write me at mpeg2repairhelper@boling.us.