Note: if the included program does not run, download and install the Visual Basic 6.0 SP6 runtime files.
To:
Allow frame rates to be mixed in an MPEG-2 file, without resorting to interlacing
Use the TMPGEnc manual IVTC feature to make this easy to apply to mixed-frame rate music videos - and to avoid having to manually define inverse telecine AND framerate for the same file
Maintain SVCD and DVD standards compliance
Both the NTSC-format SVCD and DVD specifications require a display frame rate of 29.970 pictures/second. If encoded correctly, a 23.976fps MPEG-2 file has its display frame rate defined as 29.970 interlaced. To pad the 23.976 progressive frames to the 29.970 interlaced frames, the picture headers include "REPEAT_FIRST_FIELD" and "TOP_FIELD_FIRST" flags that instruct the player to play a picture for either 2 or 3 fields. If a "REPEAT_FIRST_FIELD" sequence of 10… (accompanied with a "TOP_FIELD_FIRST" pattern of 1001…) is used, then a 3:2 pulldown will be applied by the DVD or SVCD player to convert the video to 29.970 interlaced frames per second. Computer MPEG-2 decoders, and progressive-scan DVD and SVCD players, will use these to convert to 59.94 frames per second.
Fortunately for us, these flags are not restricted to merely performing a 3:2 pulldown. By using different patterns on these flags at different times, we can use practically any picture frame rate we wish, and code different frame rates in different parts of the MPEG-2 file.
This implementation uses TMPGEnc for the manual IVTC and encoding process. It also uses a separate program, "custom_pulldown.exe", that can import a TMPGEnc TPR file (with a manual IVTC); then generate a TMPGEnc forced picture type bitrate file (to lower the bitrate on portions of the video that will be later sped up), and apply the "REPEAT_FIRST_FIELD" and "TOP_FIELD_FIRST" flags (with updated timestamps and NTSC drop frame flags) to the encoded MPEG-2 video elementary stream file.
First load your video & audio source in the designated area and
be sure to choose “ES (Video+Audio)” for the
Stream type.

Next click the “Setting” button and it will take you to a
screen that should look like this…

The setting above is the “Super VideoCD (NTSCFilm)” MPEG
setting template and is mandatory. DC and motion precision are
exceptions.
Now that you are done with the “Video” tab settings,
click the “Advanced” tab like you see below.

Now it is time to “IVTC” your video by double clicking
“Inverse telecine.” You should also take care of your
“Source range,” “Clip frame,” and color
correction if needed. Lastly, you must also check the “Do not
frame rate conversion” box as shown above.
The IVTC process is very similar to the 24fps IVTC you are used to. Just a few things to keep in mind:
The frames you select not only choose which frames are outputted, but how long the output frames are displayed. Therefore, try to keep a repeating pattern when you can. Don't use 1001010100100 when 10100 will do, unless you like jerky video.
The "Check" button doesn't matter due to the timings of each frame is corrected in the MPEG-2 pulldown flags. Therefore, ignore audio synching.
Output frames must have either 1 or 2 non-output frames between them and the next output frame. MPEG-2's flags allow a frame to be set to last for 2 or 3 fields.

Here
you see an example of a typical IVTC’able pattern (10010). This
is valid due to having each a one and two frame gap.

Here
is another example which shows a progressive pattern (10). This is
also valid due to skipping every other frame.

This would be an invalid pattern due to limitations in the
MPEG-2 frame repeat system. An output frame must last for 2 or 3
fields, no more, no less.

This again would be invalid. It would require the last output frame
(the one on the left) to be shown for 4 fields, which can not be
done.
Fortunately, this is easy to fix.
Just right click on the frame you want to chose and select “Copy
frame.”

Adding a copy frame makes the space between the frames valid, and
makes it play back identically (abiet with a duplicate coded frame).
Before you do anything else make sure “Always save encode log
file Automatically” is checked below.


Finally, open up the “custom_pulldown.exe” program, load
the TMPGEnc project file (filename.tpr) you just saved and click
“Go.”

Now you will have two text files in the folder of your TMPGEnc
project file. “filename.tpr-TMPGEnc_Force_Bitrate_file.txt”
and “filename.tpr-TPR_parsing_errors_log.log”

If you accidentally had output frames that were not 2 or 3 output
frames apart, you will see this error. Opening the file it indicates,
then scrolling down to the end, will give you a list of invalid
output frames, that looks like this:
--- INVALID PULLDOWN ---
Error
list:
Input #100.5, Output #80 is too late, previous frame lasts
for 5 fields (max 3)
Input #194.5, Output #155 is too late,
previous frame lasts for 4 fields (max 3)
Input #382.5, Output
#305 is too late, previous frame lasts for 4 fields (max 3)
Input
#428, Output #342 is too early, previous frame lasts for 1 field(s)
(min 2)
Input #607, Output #485 is too late, previous frame lasts
for 4 fields (max 3)
To fix the errors, open the IVTC screen again.

Right
click any frame, select “Move to specified frame”, and
then select “Original”.

Type
in the “Input #” number specified in the log file. If the
input number ends with .5, backspace that out (as shown here with the
input number 194.5).
Doing this scrolls you to the area near the error. Scroll back and forward a few frames, and make sure that no frames are right next to each other, or more than 2 frames apart (like the “GOOD”/“BAD” screens earlier in these instructions).
After you fix the errors, go back to the step where you save your TPR project file, and rerun your file through custom_pulldown.exe.
Now that you're done with that, go back to TMPGEnc, and click “Setting” to open the MPEG Setting window again.
Open
the “GOP structure” tab which is shown below.

Check the “Force picture type setting” and after that,
the “Detect Scene change” will be un-checked. Re-check it
and click on “setting.”
Below you will see what looks to be like another IVTC window. Just
click the “Load” button and open up your
“filename.tpr-TMPGEnc_Force_Bitrate_file.txt” file and
click “OK.”

You will see right above many lines with different integers. Click
OK, then click OK again in the MPEG Settings window.
Now you are ready to encode. Click the big “Start” button (hopefully you knew that already).

Once
you're done encoding, open up custom_pulldown.exe again (if you
closed it), and fill in your original TPR file (in the box at the
top), and the m2v file that TMPGEnc just made. The program should
automatically detect and fill in the TMPGEnc encode log file if it
can find it – if not, click “Browse” and open it
(it should be the name of your .m2v, but ending in .log instead of
.m2v). This encode log file is not required, but it significantly
decreases the time needed to process the m2v file. Click the second
“go” button (circled in the picture above) to begin
processing.
During processing, the titlebar will show the frame it is currently indexing in the m2v file. Sometimes this stops changing, even if it is on a number less than the number of frames in the m2v file, but the program is still running and indexing frames.
We're almost there...

Click
“MPEG Tools” in the “File” menu.

Select
“MPEG-2 Super VideoCD (VBR)” as the Type. Fill in your
m2v and mp2 files, choose an output file, then click run.
After a few seconds of multiplexing, you will have the final, mixed-frame-rate SVCD MPEG-2 video file. Congratulations :).
A CBR forced bitrate file must be used in TMPGEnc if the target bitrate is more than 80% of the maximum bitrate of the DVD or SVCD format.
Frames must be either 2 or 3 fields long. To meet this requirement, sometimes copy frames will need to be added, or, less often, frames will need to be removed.
The "custom_pulldown.exe" program is very slow and limited. If anyone reading this knows C++ or some other decent language well enough to pull this off, please do so so we don't have to use my VB6 hackjob ;).
Some software MPEG-2 decoders will deinterlace a picture if a 3:2 pulldown sequence is not maintained (for example, the Media Player Classic internal decoder). This means that 30fps sequences, and brief periods during scene changes that shift the pulldown flags, may be deinterlaced in a few players. Disabling deinterlacing (and/or setting to "Weave" mode) should solve this problem.
Progressive scan DVD players that do not use flags in their calculations (and display or external scan converters/line-doublers/scalers) will probably have to deinterlace and/or have interlaced artifacts, especially scene changes.
Not usable (or useful) on PAL.
Software by dbloom
Documentation by vidiotz
kthxbye