Skip to content
multi-component tool to cut and postprocess m2v/mp2 media (possibly with subpictures)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


m2vmp2cut 0.87-wip

m2vmp2cut is command-line driven frame accurate (currently PAL) mpeg2
video (m2v file) with accompanied mp2 audio (mp2 file) cutter.
A GUI tool is used for selecting the cutpoints.

Frame accuracy is achieved by re-encoding video around cutpoints -- or
sacrifice a bit of selection choices to get output video without any
re-encoding required.

Audio is cut from separate mp2 files at positions that keep a/v sync as
good as possible (maximum sync difference is around 10-15 milliseconds).

This program is licensed under the GPL v2. See file COPYING for details.


Note that 'm2vmp2cut' used to have pretty good help built-in. Executing
'm2vmp2cut' or 'm2vmp2cut . help' will get to it...

First run

$ m2vmp2cut <mpeg2 file> demux <more mpeg2 files or other ProjectX opts>

to demultiplex the source mpeg2.

Now, if you suspect there may be broken subtitle image files (the output
of demux will hint you for this), run

$ m2vmp2cut <mpeg2 file/demux outputdir> pp fixbmps

to verify (and fix) the files.

Next execute GUI for cutpoint hunt:

$ m2vmp2cut <mpeg2 file/demux outputdir> select

<demux outputdir> is derived from the original mpeg2 file by removing latest
suffix after dot (.) and replacing that with '.d' (now it also works without
the trailing 'd' (for user convenience, common prefix for tab completion)).

Select will first show gui window where you can choose what audio and subtitle
files to mux after select. Note that currently these apply to icut & imkvcut
only (the old 'cut' uses only the first audio file chosen by this tool).
When this is done, the graphical content selection tool will start.

When selecting cutpoints it is always good habit to test how the end of
previous part and start of next part will "glue" together. Just press 't'
when at either of these cutpoints to get a test play around these cutpoints
to happen. Also remember 'h' command to see keybindings (and forget mouse
for the time being).

After selection of the cutpoints are done, there are a few options to
continue: The old m2vmp2cut 'cut' command will create new mpeg2 file from
the selected contents, re-encoding some video frames to achieve frame
accuracy. Audio frames don't require any re-encoding.

But latest development has gone to 'pp icut' and 'pp imkvcut' commands.
These 2 require that in each part the start frame is 'I' frame and end
frame is either 'I' frame or 'P' frame. From these selections new video
track can be constructed without re-encoding anything. The imkvcut command
uses all of the audio and subtitle options in the pre-select gui. icut
can only use audio and language info is not used there.

Last, there are other tools in 'pp' which can create content (and in the
future this may even improve) and also m2vmp2cut 'getyuv' and 'getmp2'
may be used in other tools...


gtk2            -- gui library used by m2vcut
libmpeg2        -- for decoding mpeg2 pictures
Mjpegtools      -- for mpeg2enc and mplex tools
Mkvtoolnix      -- for mkvmerge
feh             -- for viewing subtitle pictures
mplayer         -- for viewing test cuts and playing audio options
ProjecX ( -- to demux source mpeg files
Java runtime    -- to run ProjectX (many non-sun vm:s work also)

Perl            -- (run frontend) is written in perl
Python          -- some m2vmp2cut utilities are written in python
"Modern" Shell  -- /bin/sh which has modern shell capabilities
                   (not just Bourne) (this is usually the case)

'C' compiler    -- there are some C utilities that needs to be compiled
Java compiler   -- if you need to compile ProjectX

(C quoted to avoid file(1) recognize this file as 'FORTRAN program,' ;)


Transcode       -- for requantize option (e.g. to fit large image on dvd)

(Other than ProjecX) Demux Tools (: (not used here (anymore))
mplayer (dumpaudio/dumpvideo?)


Run 'm2vmp2cut . help' to get more usage information.


Göran Uddeborg
Daniel Pielmeier


Cutting demuxed files instead of mpeg2 file that has both audio and video
is done since:

1) Handling demuxed video file is easier; no messing with PTS, DTS and SCR
   and so on (I saved development time).

2) I can't compete with such a good tool as ProjectX to get stuff out
   of mpeg2 files.

3) Cutting separate audio and video files yields much better results cutting
   audio and video on right places (near-perfect A/V sync if original has
   so), for example using 48KHz 224 kbit mp2 files one 672 byte audio frame
   contains 24ms of audio -- so A/V sync is at max 12ms off. If doing
   'hard-cuts' in (multiplexed) mpeg2 files 1) audio packets contains like
   2.6 audio frames and 2) audio packets might be far off in the file
   the video packets with time close to each other...

Tools that helped to find out required information (Thanks to the authors!):

gopchop mpegcat tool
dvb-mpegtools analyze
google searches: `mpeghdrs.html' (video) and `mpeghdr.htm' (audio)
google search: `python_mpeg'
You can’t perform that action at this time.