Editing MAVICA-MPEG´s by Hand

You can edit ( cut, copy, paste) MAVICA-MPEG´s using a simple hex editor. Since it is not necessary to mess with the MPEG coding it should be easy to generate a more user friendly software with an conveniant "drag and drop" surface.

What is an hex editor ?
Its a software which works like a simple text editor but shows all the single bytes of your file. Every byte is represented by a two digit number in the hexadecimal system. Hexadecimal numbers usualy have as prefix the dollar sign ($) to mark them clearly as hexadecimal numbers. Instead of a base of 10 like the decimal system they use a base of 16 (which is very useful for computers).
To give you an idea how hexadecimal numbers and decimal numbers convert here is a small conversion table.

HEX $01 $09 $0A $0F $10 $20 $FF $100 $1000
DEC 1 9 10 15 16 32 255 256 4096

You can calculate with hexadecimal numbers like with decimal ones. The calculator coming with windows can be switched from decimal to hexadecimal and vice versa.

How do I get an hex editor ?
I used Hex Workshop which can be dowloaded at : http://www.hexworkshop.com

If you load a MAVICA-MPEG in your hex editor it will look like that :

00000000 0000 01BA 2100 0100 0180 0E3B 0000 01BB ....!......;....
00000010 000C 800E 3B07 E1FF C0C0 20E0 E02E 0000 ....;..... .....
00000020 01C0 05A8 FF40 2021 0001 7D01 FFFD 18CC .....@ !..}.....
00000030 55B1 B400 02AA ACB2 CB2C B2CA 1084 2108 U........,....!.
00000040 4211 10E3 B8F7 6108 4210 8421 110E 3B8F B.....a.B..!..;.

Look at the hex string "0000 01BA 2100". It seems that any MPEG with sound starts with that ! But it even comes better. If you look for that string to pop up again you will find that :

00007FD0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
00007FE0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
00007FF0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
00008000 0000 01BA 2100 01FD 0D80 0E3B 0000 01C0 ....!......;....
00008010 05AA FFFF FF40 2021 0003 7A21 FFFD 18CC .....@ !..z!....
00008020 55B1 B400 02AA A390 4945 975D CE26 D934 U.......IE.].&.4

Voila´ after exactly $8000 bytes (which is 32768 in the decimal system) its there again. And coming back after $10000 bytes and so on every $8000 bytes. So its quite obvious that a MAVICA-MPEG comes in blocks of $8000 bytes each.
(This is of course for a 320 x 240 pixel MPEG, for a 160 x 120 pixel MPEG the block size is $2000 bytes, one quart).

Each block contains 9 frames (single pictures) and the sound information. So you can split up a movie into several blocks like I did it down below. Its easy as you can use a hex editor like any simple text editor to cut, copy and paste blocks.

block 01

block 02

block 03

block 04

block 05

block 06

block 07

block 08

block 09

block 10

block 11

block 12

block 13

block 14

Here you can see the original video

the original video

The singe blocks contain a lot of "FF´s" in their tail which seem not to contain any information and could be deleted without harming the picture information, however they seem to be necessary to "synchronize" the sound.

You can trim an MPEG by loading it into an hex editor and just delete the unwanted blocks and save the result as a new MPEG. You can also glue together different MPEG´s with copy and paste.

There are two things you need to take special care for.

1. The last block of a MPEG does not contain the "tail" and is sligtly different. You have to repair that before you can glue a MPEG to the very end of an other.

The end of the last block of a MPEG looks like that :

0013EAA0 0080 10CE 0000 0100 0097 FFFC 8000 0001 ................
0013EAB0 0142 7010 0200 4008 0100 2004 0080 10CE .Bp...@... .....
0013EAC0 0000 01B7 0000 01B9                     ........

As this structure in a "normal" block looks like that :

000769C0 0000 97FF FC80 0000 0101 4270 1002 0040 ..........Bp...@
000769D0 0801 0020 0400 8010 CE00 0001 BE16 210F ... ..........!.
000769E0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
000769F0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................

Note that this example is "shifted" by one byte. Just replace 01B7 with 01BE and 01B9 with 0FFF and fill up the rest with "FF´s" until the next full multiple of $8000 bytes. In our example the "repaired" last block would then look like that :

0013EAA0 0080 10CE 0000 0100 0097 FFFC 8000 0001 ................
0013EAB0 0142 7010 0200 4008 0100 2004 0080 10CE .Bp...@... .....
0013EAC0 0000 01BE 0000 0FFF FFFF FFFF FFFF FFFF ................
0013EAD0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................

now there come a lot of "FF´s" until. :

0013FFE0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................
0013FFF0 FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF ................

At the position $140000 you can add a new block or a series of blocks.

2. The second catch is, you can not take a block which is taken out of the middle of a MPEG to start a new MPEG. The first block of each MPEG is slightly different and seems to contain a "starter code". I did not figure out yet how to convert a regular block into a "starter" block. So I use a trick to start a MPEG with a block taken out of the middle.
I just produced a MPEG in black with no sound and used its very first block as "dummy" starter block. For your convenience you can download this one block as nothing.mpg.
Using the nothing.mpg as a "dummy" header I made the single blocks in the example above playable.

Anyhow this type of editing is somewhat crude and may not work all times. But here is an example of a MPEG edited with this simple method.

Click on picture to download video (app. 1.8 MB, 20 seconds). Has been "glued" together from parts of 3 MPEG-movies.

As long as you leave the MPEG code itself untouched editing is quick and does not degrade the quality of your MPEG´s or blows up the file size. Of course you can not turn, resize, change brightness or contrast etc. because this would mean manipulation of a single frame (picture) which makes it necassary to uncode and recode the single picture, which will degrade the quality of your MPEG and/or blow up the file size. Its the same catch as if you uncompress and decompress single pictures in the JPEG format.

I don´t know how to create my own computer programs under windows to produce a more user friendly editing software. Also I should know more about the specifications of the MPEG file format. But maybe somebody else has the brain and the guts to do it. It can´t be so hard at all. Sell the patent to Sony and make a fortune.....

GO BACK TO MAIN MPEG PAGE !