mpgtx a command
line MPEG audio/video/system file toolbox, that slices and joins
audio and video files, including MPEG1, MPEG2 and MP3. mpgtx was designed with the
good old Unix philosophy in mind : do few but do it well and
provide end user an austary yet powerfull command line
interface. You can find more info on mpgtx project here |
Quick
Links |
News |
I began to work on Debian packages in summer, to give something back to the community.
I looked for orphaned ones, that I used and that needed help. I found mpgtx, that I had already used to handle MPEG files and for MP3 tagging.
Because an active upstream developer is very useful for a package maintainer to do work on source code for requested features or found bugs, I asked Laurent, if he still work on it.
I got an very friendly answer. I saw a chance to use my knowledge in C++ and get experiences in working with other developers over Internet.
Let's see, that will happen. ;-)
Erik
What's inside |
>> mpgtx can currently
split and join MPEG 1 video files and most MPEG audio files.
>>
mpgtx can fetch detailed informations from MPEG 1 and MPEG 2.
>> mpgtx can demultiplex MPEG 1 and MPEG 2 files
(System layer, Program layer and Transport Layer).
>>
mpgtx can add, remove and edit ID3 tags from mp3 files and rename mp3
files according to their ID3 tags.
<<
DivX ;) is not yet supported, neither is MPEG 4
<<
splitting and joining of MPEG 2 video files is experimental.
(read "will work only in your wildest dreams")
<<
mpgtx can not multiplex audio and video into
a system stream.
Show me |
Download |
Linux Static Binary |
|
Source Code |
|
Windows Exe |
You can find any older release of mpgtx here
For l33+ c0d4z and those who want the freshest meat mpgtx
cvs is (wide) open to you. Simply do a :cvs
-d:pserver:anonymous@cvs.mpgtx.sourceforge.net:/cvsroot/mpgtx
login
cvs
-d:pserver:anonymous@cvs.mpgtx.sourceforge.net:/cvsroot/mpgtx co
mpgtx
Okay this is not that simple.
Syntax |
mpgtx [mode] [options] file [file | range] ...
Modes |
mpgtx has five fundamental modes :
split mode (-s switch)
join mode (-j switch)
info mode (-i switch)
demultiplex mode (-d switch)
ID3 tag mode (-T switch)
Options |
When in split or demux mode, you may
want to specify a basename to the output files, this is done with the
-b BASENAME
option.
When in join mode, you
may want to specify the output file name, then use -o FILENAME
.
Note that the special filename -
can be used to
specify standard output.
mpgtx uses ranges to
find out which part of the file you want to split or join.
ranges
is of the form [a-b] where a and b can be time values or file offset
values.
Time Values are of the form HH:MM:SS.SSSS where
the HH: part can be omited.
Offset Values are a number of bytes
optionaly followed by the letter 'M' in which case offset is in
Megabytes or 'k' offset is in kilobytes.
The first range
must follow an MPEG file name.
Additionaly, half opened
ranges can be specified to ensure that two chunks do not overlap
:[a-b] [b-c]
produces two overlapping ranges (the b
value is guaranteed to be part of each range) and[a-b]
]b-c]
do not overlap since b is contained in the first range
only.
Examples:myfile.mpg [35:14-1:22:00]
corresponds to the range 35 mins 14 secs to 1 h 22 mins of file
myfile.mpgmyfile.mpg [42000-520M]
corresponds to the
range 42000 bytes to 520 Megabytes of file myfile.mpg
Additionaly
an empty value corresponds to the file boundary, thusmyfile.mpg
[-520M]
corresponds to the first 520 Megabytes of file
myfile.mpgmyfile.mpg [3:20-]
from 3 mins 20 second
to the end of myfile.mpg
Another kind of range
[part_number/total_parts] can be usedmyfile.mpg [1/4]
corresponds to the first quarter of myfile.mpg
You may
also want to cut a file at a given boundary, mpgtx
provide an additional syntax for it :myfile.mpg {520M}
defines two ranges : one from beginning of file to 520
Megabytes, the other from 520 Megabytes to the end of file.
Several
dash separated values in ascending order can be specified, thus
:myfile.mpg {a-b-c}
defines the four following
ranges : [0-a] ]a-b] ]b-c] ]c-]
ID3 tag mode |
An ID3 tag is a chunk of extra informations such as artist name,
album and genre. ID3 tags are displayed by most mp3 players.
ID3
tag mode supports this modes to help you sort your audio files :
tagmp3 show file
tagmp3 set FORMAT file
tagmp3 move FORMAT file
tagmp3 del file
tagmp3 list
Format String |
The format string is a character string composed of zero or more directives: ordinary characters (not %), which are not interpreted and conversion specifications, each of which results in the corresponding ID3 tag field substitution. Each conversion specification is introduced by the character %. The following lines describes each conversion specification along with its associated ID3 field. Special sequence %% is substituted with a single %.
Format string : set mode |
For set mode the format string is a list of ID3 fields followed by a ':' (next chars are the field value) or a '?' (ask user for field value)
tagmp3 set "%A:Pink
Floyd %a:The Wall %t? %T?" *.mp3
Format string : move mode |
The format string is the destination path where each field identifier is substituted with the tag value.
tagmp3 move
"/home/foo/mp3/%A/%a/%T-%t.mp3" *.mp3
/home/foo/mp3/Pink
Floyd/The Wall/{track}-{title}.mp3
" tagmp3 move "%A-%t.mp3" *.mp3
Additional names |
mpgtx comes with four symbolic links which are mpgsplit,
mpgcat, mpginfo and mpgjoin.
When called under these
names, mpgtx will change its behaviour according to the
following :
mpgtx -s
mpgtx -j
mpgtx -j -o -
mpgtx -i
mpgtx -d
mpgtx -T
Examples |
Enough with the theory, here comes action.
Suppose you want to split matrix-trailer.mpg into 166 playable chunks with the basename mychunk |
mpgtx -166 matrix-trailer.mpg -b mychunk Now processing Chunk 1/166 ... 100.00% Now processing Chunk 2/166 ... 92.79% [...]
Now suppose you want to join file1 and file2 and to append the first 30 Megs of file3 followed by 30 mins of the same file starting at 1hour 10 mins, you want all these chunks into one file materoffactly called thejoinedfile.mpg (yeah suppose you're crazy enough to want to do so) |
mpgtx -j file1 file2 file3 [-30M] [1:10:00-1:40:00] -o thejoinedfile.mpg Now processing Chunk 1/4 ... 100.00% Now processing Chunk 2/4 ... 100.00% Now processing Chunk 3/4 ... 100.00% Now processing Chunk 4/4 ... 100.00%
Hey why not deleting this annoying 5 minutes intro from movie.mpg? |
mpgtx -s movie.mpg [5:00-] -b without_intro Now processing Chunk 1/1 ... 100.00%
I want to split this file at 699 Megs so that it can fit on my Video CD! |
mpgtx -s file {699M} Now processing Chunk 1/2 ... 100.00% Now processing Chunk 2/2 ... 45.31%
I wonder about the display size and the duration of this mpegfile |
mpgtx -i mpegfile mpegfile: Mpeg 2 System File [Video/Audio] Estimated Duration: 01:38:29.51s Aspect ratio 4/3 (TV) Not interlaced, chroma format: 4:2:0 Video Format: PAL Size [352 x 288] 25.00 fps 1.15 Mbps User Data: ------------ encoded by TMPGEnc b12a ------------ Audio : Mpeg 1 layer 2 192 kbps 44100 Hz Stereo, No emphasis
What's inside this weird MPEG file? |
mpginfo weird.tx weird.tx: Mpeg 2 Transport Stream [2 programs] Program N° 2 contains 2 Elementary Streams: Stream 1: MPEG 2 audio [pid: 59] audio version 2 Stream 2: MPEG 2 video [pid: 58] video version 1 Program N° 1 contains 2 Elementary Streams: Stream 1: MPEG 2 audio [pid: 57] audio version 2 Stream 2: MPEG 2 video [pid: 56] video version 1
Let's demux this transport file. |
mpgdemux ../mmedia/teracom_3/Teracom_3 -b weird Demultiplexing : [Programs 02 audio 02 video 02] [100.00%]
what about this wagner.mp3 ? |
mpgtx -i wagner.mp3 wagner.mp3 Audio : Mpeg 2 layer 3 Estimated Duration: 03:00.70s 32 kbps 24000 Hz Frame size: 96 bytes Mono, No emphasis, original ID3 v1.1 tag ---------------- title : Der fliegende Hollander genre : Other ---------------- ID3 v2.3.0 tag (more info on http://www.id3.org/) ---------------- TRCK : 01 COMM : (lang: eng) : (empty) PCNT : (skipped) TLEN : 180000 TCON : Richard Wagner TIT2 : Richard Wagner - Der fliegende Hollander ----------------
TODO list |
Features |
Multiplexing of audio and video into a system file.
Internals |
Improved support to MPEG 2 video files.
Get rid of the GOP limitation. Split on frame basis.
Correct timelines. Sets wrong time stamps into right order.
Support MPEG 4 and Divx ;).
Improve info mode.
Known Bugs |
|
|
|
Known mpgtx Bugs and limitations |
Bugs |
Problems were reported about Windows Media Player.
Full Bug list can be found here
If you found a bug please help me to correct it : just submit it.
Limitations |
mpgtx is a GOP based MPEG editor. A GOP is a Group Of Picture, typically 15 pictures for a duration of 0.5 second. So is mpgtx's accuracy.
MPEG files joined with mpgtx can show artifacts at the splice point. This is not a bug from the editor but rather from the player. Technically mpgtx sets the Broken Link flag in the GOP header which tells the player to discard leading interpolated (B) frames. Some players will ignore this flag, thus displaying artifacts. mtv and mtvp are known to handle these files correctly. You can find these tools at www.mpegtv.com.
Time ranges are currently computed on the duration estimation and the file size to produce offset ranges internally.
Author |
Laurent Alacoque <laureck @ users .
sourceforge . net> © 2001 |