

	Mpg2Cut2 - http://www.geocities.com/rocketjet4/




MPG2CUT2 - FAULT TOLERANT, GOP LEVEL, BINARY CUTTER 
         - FOR MPEG-2 PROGRAMS STREAMS 
         - ESPECIALLY DIGITAL TELEVISION (DTV) CAPTURES



         *** BETA VERSION ***


                *** USE AT YOUR OWN RISK ***


               Remember to do a virus check






**** CURRENT KNOWN PROBLEMS :-

  - Private Stream 2 Audio not previewable
    Can also cause the program to crash.

  - Audio sync after joins on some players.

  - Multiple selection ranges - VERY PRIMITIVE
    It basically works, at least for my environment.
    It MAY NOT be acceptable to YOUR system.
    If you have problems with the output,
    passit through PVAStrumento.

  - Multiple input files - not fully tested.
    It is quite usable if you are not too fussy.

  - Preview function is very primitive,
    with no audio syncing. 

  - Forward single frame does not show B frames.
    Sometimes gives bad pictures.
    Not ready yet.

  - "BACK" command sometimes stops.
    In this situation, use Scrollbar to scroll back .

  - "BACK" command sometimes skips an extra GOP.
    Performance trade-off, still working on this.

-----------------------------------------------------------------

APPLICATION DESCRIPTION
=======================

Mpg2Cut2 - Enhancement of Mpeg2Cut v 1.6 - based on DVD2AVI

Copies selected portions of an MPEG2 file.

Does *NOT* support MPEG1 format.
It will just sit there looking darkly at you.

Selection is made at "Group Of Pictures" (GOP) level,
which is usually around a dozen frames,
so accuracy is limited to about half a second of time.

There is NO decryption capability,
it will only work on non-encrypted files.
So if you are trying to use it on a commercial DVD,
and just get rubbish out, don't be surprised.

The program does NOT check for "Open GOPs",
so you can get spoilage of the first and last GOP in a selection.

A GOP is usually around half a second.

The program does NOT check for delay between audio and video streams,
which is quite common, so I suggest you leave some extra fat 
at the start and end of your edit selection, 
to avoid losing some audio.

The Audio delay is shown in milliseconds (ms). 
At least 200ms is normal, but over 1 second is common.
So add AT LEAST one GOP at the end of the edit.
For safety, add 3 GOPs.

Also remember that change of shot is unlikely to coincide with a GOP 
boundary, so you should also add a padding GOP at the start of the clip.


--------------------------------------------------------------------

USAGE
=====

Navigate along the time line using either the slider
or the buttons or keyboard commands. 
The keyboard is the most flexible way to navigate.


KEYBOARD COMMANDS :-

To allow for people with different habits,
there are 2 different configurations for keyboard commands:

   1) Classic Mpeg2Cut

   2) VirtualDub compatible (well... sorta)

         Not quite, because VDub has frame level navigation,
         while Mpg2cut2 is GOP oriented.



    Arrow keys navigate along time line

	ACTION               CLASSIC       VIRTUALDUB

	Forward one GOP       UP            RIGHT
	Back    one GOP       DOWN          LEFT 
	Back a lot            LEFT          UP
	Forward a lot         RIGHT         DOWN
	Next File Start       Ctrl RIGHT
	Previous File Start   Ctrl LEFT	

	SHIFT - Magnifies each of the above keys

	Forward 1 Frame        /     (NB. NO MARKING in the middle of a GOP)

	GO TO Clip#        0..9

	Mark "IN"             [             Shift [
	Mark "OUT"            ]             Shift ]
	Go to "IN"        Shift [           [
	Go to "OUT"       Shift ]           ]
	ADD clip         +


	Open file         F3 Ctrl-O
	Append file       alt-O       
	Append Like       alt-L       
	Save clips        F4 Ctrl-S
	Save This clip    Ctrl_T
	Play              F5 P
	Pause Play        Space
	Stop Play         ESC

	Snapshot          B or Shift-B   (result dependant on option setting)

	L = Luminance Boost 

-----

MULTIPLE INPUT FILES.

   Reinstated the ability to concatenate multiple input files.
	   Menu - File - Append. 
   Multiple files can be selected during File Open or Append,
   but be patient as it takes time to open a number of files.

   NOTE
   ====
   This is a primitive binary join,
   with NO analysis of the Mpeg attributes.
   It is up to you to ENSURE that the files are COMPATIBLE.
   Otherwise, expect strange results.
   EG Does NOT detect:-
       - Broken GOP at join boundary (maybe fix in a future release)
       - Different bitrates
       - Different Height or Width
       - Different chroma sub-sampling


   You can choose to sort the file either by File Name,
   or by internal Mpeg Time Stamp (System Clock Reference).
   Each approach has it benefits and limitations.

   Do this *BEFORE* you select clips, 
   because I the Edit Decision List is NOT updated.
                (May fix this in a later release.)

---

MULTI-CLIP selection (NEW).


You can select multiple clips to be written to a single output file.

Select one clip at a time to be included in the output.

IE - MARK the "FROM" point, 
     MARK the "TO"   point,
     ADD the selection to the list using the  + symbol.

As mentioned above, leave some extra fat 
at the start and end of your edit selection,
to protect against open Gops and audio offsets.

If you just change you mind about the "FROM" or "TO" position,
of the most recently added clip,
then just MARK the new point and do another ADD.
It will recognize that the other is the same,
and optionally ask you if you want to replace the previous selection.

To REMOVE the last clip added,
use MENU - EDIT - REMOVE CLIP.

The ADD action can be automated,
so that as soon as you mark the "OUT" point,
it will add the clip to the list.

An intermediate level of automation is "REMIND",
where it will remind you if you forget to manually add a clip.

At the end - REMEMBER TO SAVE THE CLIPS:
 
    MENU - FILE - SAVE ALL   (or press F4).
     
Mpeg "Sequence End" codes will be added at the end of each clip,
if this menu option has been enabled.

Some players may pause at joins - try hitting PLAY.
If this becomes a headache, then you can
try using "PVAStrumento" by Offeryn to reset time stamps.

---

OUTPUT CONTROLS


Primarily to standardise start and end of file.

PREAMBLE option.

   Can copy control info from the start of the input file.
   This is very crude, but may help some people, sometimes.
   Previous version did not copy control info from start of file.

   PREAMBLE = MAXIMUM

      This is a conservative setting that allows for files
      with complex control information at the start.
      Recommended if editing VOB files.

   PREAMBLE = SMALL

      Good for NEBULA DigiTV files to remove crud from start of file,
      thus improving compatibility with other utilites such as TMPGENC.   


   Message: "Input file starts part way through a GOP....
             SKIP TO FIRST KEY-FRAME ?"
   Common with DTV files. 

   If you have a separely editing a sequence of files that originated as
   a single stream, then ONLY click "OK" on the FIRST one.  
   A better approach is to use the "File-Append" command
   to concatenate fragments in a single edit session,
   to avoid losing frames from GOPs that have been split across files.  

   For ease of finding files when you have a lot in the same folder,
   use "File-Append-Like", which restricts the File display
   to those with a similar prefix. (Not supported on DBCS)

   PREAMBLE = NONE
   This is the old approach used in version 1 of MPEG2CUT.
   Retained for those who may still want it,
   but has been moved into the "obsolete" prefernces sub-menu.

Insert Seq End codes.

   At the end of each clip, it will insert an Mpeg code (B7) to indicate the end
   of a video sequence.  This will aid some decoders, at very little cost.

VOB Pad 2k - EXPERIMENTAL.

   This feature is still experimental, as it needs a LOT more work.

   Some utilities require VOB file length to be exact multiple of 2k. 

   At this stage of development, this option will just pad the file length
   to fool other utilities into thinking the packet size is fixed 2k.

   *WARNING*
          This option should ONLY be turned on for a FINAL compilation VOB.
          NOT for intermediate edits.

   For proper DVD conformance, use "PVAStrumento" by Offeryn
   to reblock ALL the Mpeg packets to 2k.



Default Output Folder 

  Allows you to set the current output folder as the future default
  to be displayed when an output file is to be created. 

  For Windows 98 users, the facility is more sophisticated still :-
  The INPUT folder name is still provided in the filename,
  to allow easy override of the default folder.

  Windows 2000 does not seem to be quite as flexible, 
  so use the menu to toggle the function on or off BEFORE the save.
  


---

If the image is too dark on your monitor,
you can boost the display using the 
Menu - View - Luminance option.
This does NOT effect the output MPEG file,
but can optionally effect BMP snapshots.
The choice is yours.

GAMMA - This is the main difference between TV and PC systems.
        Adjust this first.  130 is a common starting point.
        Increases brightness and contrast in dark areas.

CONTRAST - Same as contrast control on an analogue TV.

BRIGHTNESS - ditto.

LOCK - Automatically adjust contrast and brightness together.

BMP - The changes will also be applied to BMP snapshots.

NOTE:- PLAY SPPED PERFORMANCE HIT
       The new version with GAMMA control has a performance impact,
       noticable when using "Preview" or "Play".
       If you have CPU that is less than 1GHz, it will be play slow. 

---

BMP snapshot of current frame has 2 formats:
	1) Grab Frame asis
	2) Grab Fields separately (NEW)
	    Use this where interlacing artefacts are a problem.

By default, if the overlay display is de-interlaced,
then BMP snapshots will be too.

Override this with the SHIFT key when you press B,
or change the view to turn it off for that session.

Ovarlay de-interlacing can be turned off in MENU - VIEW
and this will change the Snapshot default at the same time.

Grabs have NO Aspect Ratio Correction,
so afterwards you will have to use an an imaging program
like irFanView or Paint Shop Pro to do BiCubic resampling
to correct the aspect ratio.

This is because a good imaging program will give better results
than my quick and dirty Aspect ratio correction.

PAL EXAMPLE:
    720x576 16:9 Full Frame Grab - Resample Height from 720 to 1024
    720x576 16:9 Field Separated - Resample Height from 288 to  405.        (405 Alive !)


---

VIEW - ASPECT RATIO Correction 

The aspect ratio specified in the MPEG file
will be honoured (approximately).
If the picture is wider than the screen,
it will display the middle of the picture.

The aspect ratio conversion is quick and dirty,
so interlaced material can look quite rough.

De-interlace option is useful on non-cine material,
or traditional NTSC telecine (29.97fps),
and for poor PAL telecine.
It is should not be needed for standard PAL telecine.

If the picture is bigger than the screen,
scroll by pointing and clicking with the mouse
on the area of interest to centre it. 

You can ZOOM OUT to see the whole picture.

Note that NONE of this effects the output MPEG file, nor BMP snapshots. 

---



INSTALLATION
============

1)   Download TWO (2) Zip files from http://www.geocities.com/rocketjet4/

     You will need BOTH the main MPG2CUT2 zip file
     AND the AUDIO DLL zip file.


2)   Unzip the downloaded files and do a VIRUS SCAN !

3)  Copy the Mpg2Cut2.EXE file and this TXT file to an appropriate folder.

    AND copy the AUDIO sub-routines into the Windows System folder,
    or into a Dos PATH folder :-

            libmmd.dll
            mpalib.dll mpa_mmx.dll mpa_sse1.dll mpa_sse2.dll

4)  Create shortcuts to both the EXE and this TXT file
    and put the shortcuts either on the desktop or in your Start Menu.

3)  Under Windows 2000 or later, set security to allow dumb users
    to update the file "Mpg2Cut2.INI".



WINDOWS EXPLORER CONTEXT MENU
=============================

This can be either done manually using Windows Explorer Options
or semi-manually using a REG file.

If you don't know anything about REG files,
use the following manual method in Windows 98 :-

	- Check what Windows Explorer calls mpeg files
	- Menu - View - Folder Options
	- File Types
	- Scroll down to the entry name relating to mpeg files
	- Click on the "Edit" button
	- Click into the retangle labelled "Actions"
	- Click on the "New" button
	- Create a new action called "EDIT"
	- "Browse" button to navigate to the folder
        where you have put the Mpg2Cut program
      - Highlight the file named "Mpg2Cut2.exe"
	- Click "OK"
	- Click "OK"
	- You may want to repeat the whole process for "VOB" files
	- Click "OK"


ALTERNATIVELY
=============

If you are quite familiar with REG files,
AND you have a current BACKUP of ypur System Registry,
try the following:- 

Edit the supplied file MPG2CUT2.REG

Change the path to match where you have installed Mpg2Cut2.EXE
Note that back slashes must be DOUBLED within the quoted string.

Save the changes and open in Regedit.

NOTE:  To avoid accidentally laumching the supplied sample REG file,
       it has been shipped with a dummy extension of .TXT


------------------------------------------------------------------
MINIMUM REQUIREMENTS

Windows 98 SE

	This is what I am running on. Also seems to run OK on Win2K.
	I expect it would work on other modern versions of Windows...


Celeron or better CPU

	Editing:
		The basic editing function does not use much CPU,
		so you could get away with using a very basic machine.

		I use a P-III 800 Mhz and this is plenty fast enough
            for editing Standard Definition files. 

            For High Definition, 800 Mhz is OK for editing, 
            but a little slow.


	Previewing:
		The preview function chews up a lot more CPU than editing does,
            so if you are using a slower machine,
            I suggest turning off the adjustment of Luminance and Audio.

            600Mhz P3 would probably be minimum for previewing a 
            Standard Definition (SD) file.

            For High Definition preview, probably need at least 
            2 Ghz even for a moderate bit rate HD file. 
            But for the seriously high bit rates that some countries have, 
            probably need more than 3Ghz.

      There is provision for other CPUs (eg 3dNow) that I cannot test.

------------------------------------------------------------------

HOME PAGE: 

     http://www.geocities.com/rocketjet4/


------------------------------------------------------------------


CHANGES since Version 1.5 of Mpeg2Cut
=======

1) Multiple clips into a single file. 
   After making a selection, click the "+" button
   to add the clip into the Edit selection List.

   When you have selected all your clips,
        Menu - File - Save ALL   to save all the clips.

   If you just want to save ONLY the current selection,
        Menu - File - Save This   to save just the current selection.

   Players may pause at joins - try hitting PLAY.
   This is because I am not rebuilding the internal Time Stamps.

   Preview function NOT yet enhanced for multi-clip.

2) Multiple Input files.

   Reinstated the ability to concatenate multiple input files.
   Added a menu command to DELETE all the input files.
   This is a REAL delete - *NOT* a recycle.

3) Compatibility improvements.

   Overcomes most of the problems reported by users regarding
   Mpeg2Cut incompatibility with other software:

   Output Format controls to standardise start and end of file.
   Preamble options to copy headers from original file.
   Padding option to padd out end of file.

   Clip scoping changed from I-Frame start block number
   to instead use SEQ/GOP header start address.

4) More Fault Tolerance.
   Much less vulnerable to transmission errors.
   This is especially important when working with cruddy DTV captures.

5) Interface with Windows Explorer 
   Now accepts file name via parm area.
   Output file names are now based on input file name.

6) Toolbar changed.
   Moved to top to allow for picture height > display height
   Extra buttons for ergonomic reasons.
   Button size scaled according to screen resolution. 
   Extra buttons and info on progress window.

7) BMP snapshot no longer requires RGB24 display.
   Option to separate interlaced fields.
   Name now based on input file name and frame time stamp.

8) Display Enhancements.

      - Aspect Ratio Correction 
      - De-Interlace
	- Align view window based on primary mouse click within image area. 
      - Zoom-Out through toolbar button or secondary mouse click;
	// not yet:- Zoom-In at double-click position (Max=1:1)
		     - Release overlay when minimized 
      - Reacquire overlay after DisplayChange or Mpeg canvas size increase.

   Most MPEG files have anamorphic (squeezed) pixels.
   Program now allows for this,
   so even Cinemascope looks almost sensible.

   HDTV (1080) viewed on low-res screen (640) will ZOOM OUT by default.
   Amount of Zoom can be controlled through "Z" button on toolbar.

   To allow for previewing HDTV on a small processor,
   option to skip frames when behind,
   during play/preview processing.

   RGB mode support for view enhancements is very basic. YUY2 is better.

   Gamma control added to Luminance dialog.

   This allows you to adjust for the difference in luminal linearity
   that exists between TV standards and PC video cards.
   Also, the gain control now acts more like classic TV contrast control.

   This slows down "PLAY" mode, as it is less efficient than the basic
   controls that existed in the previous version, which used MMX.

9) Navigation Keys.
   SHIFT key speeds up the arrow keys. Other new keys defined.
   Because I am impatient.

10) Intelligent reset of OUT point
    on subsequent IN selection.
   Now resets OUT to END.

11) Shows how many MegaBytes are selected out of total MB.
   Also checks amount of free space on output FAT drive.
   Estimated time left when outputing large file.

12) Default Output folder and Extension

13) Visual EOF Indicator.
    Display now shows a visual indicator of EOF reached,
    to clearly distinguish it from the last image shown. (YUY2 mode).

13) Drops delta frames if PLAY mode is too slow.
    Conservatively set, so that Key frames always show, even if behind.

14) Sped up Mpeg decoder a bit.
    Still scope for trimming fat from the processing of component buffers.

15) Reduced tendency to swamp the system when copying large selections.

16) Shows Time Co-ordinates.
    Current position is shown as time relative to start of file.
    Assumes timestamp sequence is unbroken.
    
    Alternatively co-ordinates can be shown as the actually internal value
    of the Mpeg time stamps, or just a block number within the file.
    Swap formats by clicking on the time display.

17) MPAlib version chopsen by program.
    The user no longer needs to understand the difference in hardware
    between models of CPU models.
    Also cleaned up code on Private Stream processing,
    but there is more to do on this.
    More info about mpeg audio layer.

18) More info in Title bar.
    Progessive/Interlaced indicator (p/i) after vertical line count
    Field encode structure (Top first/Bottom first/p=progressive encode)
    EG  576ip means interlaced original, encoded progressively).
 
+ Miscellaneous little changes.




OTHER KNOWN BUGS & LIMITATIONS
===============-==============

1) Timestamps are not corrected at joins.
   
2) Bitrate limits are not checked.

3) Bad MPEG data MAY still cause crashes,
   BUT it's a LOT less frequent in this version.

   Since the macro-block decoder is a mystery to me,
   there are still problems that I haven't allowed for.

4) Always puts an MPEG header at the front,
   even if  you don't really want it to.
   However, you can set "preamble" to SMALL
   to reduce the amount of crud.

   Setting preamble to NONE corresponds to ver 1.15 of Mpeg2Cut.

5) After applying SP5 service pack, EXE grew by 20% overnight,
   and I started getting more crashes. Don't like this.

6) In DirectX9, not automatically falling back to RGB
   when overlay unavailable.

7) Luminance control might benefit from being rewritten in MMX.



MPEG DECODE ERROR CODES
=======================

Fault_Flag = 1;   // Invalid DCT table code
Fault_Flag = 2;   // Invalid Macro Block type for this Picture type
Fault_Flag = 3;   // Invalid Coded Block Pattern
Fault_Flag = 4;   // Invalid macroblock_address_increment
Fault_Flag = 5;   // Invalid motion_type
Fault_Flag = 10;  // Invalid motion_code
Fault_Flag = 11;  // Invalid start code within Picture data
Fault_Flag = 42;  // Unknown Pic type - not I,P,B


