The Software Download form : http://www.souxin.com

RM-Fix v4.6b0923 (c) 2000 Magic Mysery
--------------------------------------
What is it ?
------------
This program checks a RealMedia file for errors and attempts to fix those
it can find (about 80-90% of them). It's not 100% foolproof and even though
it tries to fix the errors it finds, sometimes the file is too corrupted for
the program to be able to fix it. Also, less obvious errors (like the data
in the packets themselves) cannot be checked at the moment (Blame Real
Networks for not releasing any information about their packing algorithms ;)

Why isn't it fully automated ?
------------------------------
The program heavily relies on the user to make decisions for it because,
let's face it, just applying a set of rules to corrupt data is NEVER going
to work. If the user is smart enough,(s)he'll know which changes to accept
and which are out of the question.

Disclaimer
----------
The programmer will in no case accept responsibility for anything this program
does or doesn't do to your system/files. You use this program at your own risk.
This program isn't supported by and has nothing to do with Realnetworks inc.

Where can I get it ?
--------------------
The newest version will always be available at http://web.wanadoo.be/anime-rw

Greetz
------
* A special big THANK YOU goes to Mr. Oizo aka Duncan_00 without whom this probably
  would never have been written.
* A quite large THANK YOU goes to ShXpire for bugging me to finally add the
  patch-file creation and for writing a tutorial on how to use this program.
* A slightly smaller but still quite large Thank You goes to Wolverine for being one
  of the first people on the planet to actually use the program (well, not counting
  myself of course ;)

==================================================================================
Use
---
Usage : Rmfix <FILE> [optional parameters]
  <FILE>  : The file(s) to check
            Wildcards make it revert to v1.4 again = no data packet checker
            and no autofix
 Optional parameters :
  v & v2  : Debug parameter... writes data to [logfile]
            If logfile isn't specified, the program will ask at runtime.
            Possible parameters : v  = dumps the info blocks to file
                                  v2 = dumps even more RM data to file
                                       (not recommended)
            Requires 1 parameter  : RMFix input.rm v(2) [logfile]
            Optional parameter    : specifies the logfile to write the debug
                                    data to.
  r       : Command-line index rebuilder.  (NO WILDCARDS)
            Builds an index for the file and ends program on screen exit.
            Ends processing of a stream at the first error.
            Requires 1 parameter  : RMFix input.rm r
  r2      : Command-line FULL index rebuilder.  (NO WILDCARDS)
            Builds an index for the file and ends program on screen exit.
            Keeps going and tries to find the next valid packet.
            Requires 1 parameter  : RMFix input.rm r2
  b       : Command-line Backup restore.   (NO WILDCARDS)
            Restores the backup-file (if it exists) and ends program on
            screen exit.
            Requires 1 parameter  : RMFix input.rm b
  k       : Command-line Kernel Crash Fix. (NO WILDCARDS)
            * Demuxes & Remuxes a file and returns to command prompt.
            * Extracts the best possible audio/video combination from a 
              SureStream file.
            New file will be written to the storage dir with the same name
            as the original.
            Requires 1 parameter  : RMFix input.rm k
  p       : Command-line Patch.            (NO WILDCARDS)
            Patches the file (if the patch file exists) and ends program on
            screen exit.
            Requires 1 parameter  : RMFix input.rm p
  u       : Command-line Undo.             (NO WILDCARDS)
            Undoes the changes (if the undo file exists) and ends program on
            screen exit.
            Requires 1 parameter  : RMFix input.rm u
  i       : Command-line Information page. (NO WILDCARDS)
            Jumps straight to the information page without checking anything.
            Ends program on screen exit.
            Requires 1 parameter  : RMFix input.rm i
  d       : Command-line Demultiplexer.    (NO WILDCARDS)
            Demuxes the input file to the storage dir in the config file
            or to the current directory (if no config file exists).
            Requires 1 parameter  : RMFix input.rm d
  m       : Command-line Multiplexer.      (NO WILDCARDS)
            Muxes the specified stream0 & stream1 to file output in the
            current directory.
            Requires 4 parameters : RMFix stream0.rm m stream1.rm output.rm
  s       : Command-line Resyncer.         (NO WILDCARDS)
            Checks the file to see if it's the type I've discovered that
            unsyncs the most and tries to fix it if that's the case.
            Requires 1 parameter  : RMFix input.rm s [x]
            Optional parameter [x]: 1-3 (no parameter = 2)
                                     Allows for some finetuning. Shouldn't
                                     be necessary but you never know.
                                     1 is slightly slower than the standard
                                     setting, 3 is a slightly faster rate.
  f       : Command-line filesize checker. (NO WILDCARDS)
            Does a quick check to see if a file is complete.
            Requires 1 parameter  : RMFix stream0.rm f
  e       : Command-line error lister.     (ACCEPTS WILDCARDS)
            Lists all errors in a file to RMFixer-errorlist.txt in the
            current directory (or the parameter dir).
            Requires 1 parameter  : RMFix input.rm e [directory]

Data block check :
- Your best bet is to run a 2 pass check (due to some problems with the
  timestamp code) :
  - Autofix & stream number fix (1st pass)
  - Timestamp only (2nd pass)
  The reason for this is that faulty timestamps don't stop the player 8 out of
  10, and I'm still not happy with the timestamp fixer so it should only be used
  if the autofixer didn't fix the problem.

Autofixer :
- before writing to the file, it'll tell you the new packet size
  plus the size of the new 'next' packet along with it's stream type.
  This is because fixing packets relies a lot on the user's common sense.
  Fixing keyframes is dangerous ;)

About resyncing :
-----------------
  Resyncing changes the sampling rate of the audio slighty, so custom
  sampling rates shouldn't be disabled in Realplayer.

About SureStream files :
------------------------
  Surestream files have limited options : command-line information and
  command-line kernel crash fix. The command-line kernel crash fix will extract
  the best possible audio/video combination from the surestream file and 
  dump it in the storage directory. These extracted RMs can be read with
  both RealPlayer and RMFixer without any problems.

Limitations
-----------
- Almost everything stops at the first invalid packet size (except the checker
  of course ;)
- Only supports 1 data chunk per file.
  (I've NEVER encountered a file with more than 1 data chunk)
- Maximum 20 data streams per file, which should be more then enough.
  (Normal maximum is 2 ;)
- The timestamp fixer is able to fix a couple more errors, but it can also
  screw up a file. The rule of thumb : if it's fixed without the timestamp
  fixer turned on, don't run the timestamp fixer on it.
  Otherwise make sure you have a backup of the file and try turning the
  timestamp fixer on.
- Max filesize is about 2.14 Gig... I think that should be about enough,
  don't you ? ;)
- Most of the extra options only work on non-corrupted files (or omit/stop at
  the corrupted data).
- RMFIX DOES NOT WORK (OR ONLY OCCASIONALLY) UNDER WINDOWS 2000.

==================================================================================
To Do								When ?
-----								------
- OPTIMIZE THE CODE                                             In Progress
- File appending                                                On Hold
- File splitting                                                On Hold
- Stream conversion                                             Never Prolly

==================================================================================
Bugs
----
- Sometimes a file is fixed but then realplayer crashes the kernel X seconds
  before the fix (X being the number of seconds you buffer). I can't find any
  reason why it would, but it still does... I've even noticed some RMs that I
  hadn't processed that have the same problem so it's not my fault ;)
  FIX : Most of those errors are fixable by demuxing and remuxing the file.
- The Index Rebuilder sometimes makes a file 0 seconds long (happens when you
  mux two streams that were f*d up). Just run the index rebuilder again.
- If a chopped file is smaller then 30K, the index rebuilder can go crazy and
  interrupt you every time you try to check the file... The solution ?
  THERE's NOTHING IN A 30K PORTION OF A FILE! LEAVE WELL ENOUGH ALONE ;)

Please report all other bugs to magicmy@hotmail.com

==================================================================================
History
-------
v4.6b0923
+ Added a COMPLETE index rebuilder that tries to skip errors... 
  To turn it on with the menu version, turn on autofixing, otherwise use 
  the 'r2' parameter. It SOMETIMES crashes, but that's on errors that need
  user interaction to fix properly. 
+ Tried ANOTHER way to get RMFix to show ANYTHING on the screen in W2K...
  Need feedback people.
v4.5b0908
+ Fixed a bug with the read-only media support for the info screen and the
  lister.
+ Wildcard support for the error lister.
+ Now there's an extra switch : show the error list at the end or not
  (defaults to showing the list)
v4.5b0823
+ Can now make single stream files from surestream files. 
  Use the command-line Kernel Crash Fix (yeah I know, I didn't want to add yet
  another command-line parameter. So sue me ;)
v4.2b0821
+ Added the ability to save the errorlist to another directory.
v4.2b0808
+ Whoops! Fixed the starting position... in one of the previous builds
  I accidentally switched it off ;)
+ Fixed up the kernel crash fix to handle a couple more types of faulty
  packets.
+ Apparently remuxed streams didn't get index blocks... fixed.
v4.1b0730
+ Discovered another flag (downloading allowed) and added it. Nothing much,
  but it's a new build ;)
v4.1b0725
+ Big change in the wildcard handling (for normal use, not for command-line
  parameters). Now gives this selection after each file is loaded :
   - Check blocks
   - Sync sound
   - Info
   - Restore Undo file
   - Apply Patch file
   - Rebuild index
  which also accounts for the most used command-line parameters, so I'm not
  going to change those (well, perhaps sync & list errors will be changed
  so they accept wildcards, but I'm not sure yet)
+ Updated the installer a bit... Seems the buttons weren't readable in
  256 color modes (who uses those anyway ;). Fixed now... Looks REALLY ugly
  in 256 color modes, but then, so does everything else ;)
= Messed around with the interface a bit... I'd like some feedback on it ;)
v4.1b0723
+ Small cosmetic changes to the error list. Error lists now all written to the
  same file (rmfixer-errorlist.txt) instead of in separate files.
v4.1b0718
+ Well, the error lister didn't work. Fixed.
v4.1b0717
+ Experimental version of the error lister someone requested. Probably still
  a bit buggy, but it should (kinda ;) work. {NOT ENTIRELY TESTED YET}
+ Fixed the empty stream 1 index rebuilder bug.
v4.0b0712
+ New installer! Now comes with a nice windows GUI installer. Of course,
  this means the distribution size went up by a factor 4... Don't you just
  love windows ;)
= Ooops... turns out I inadvertently removed the streamnumber fixer in a
  previous build... sorry ;)
v4.0b0709
= Finally happy enough with it to remove the alpha release tag ;)
= Readjusted the timestamp gap to 1.5 times the gap between the first 2
  packets of a stream.
+ Start&end pos setting is now virtually instant.
- Index list creator removed.
v3.8b0708
+ Added a listing of the encountered errors at the end of a fixing session
  & allow list to be saved to user-specified file.
= More optimizations.
v3.8b0706
= Started optimizing and rewriting everything. Nothing much should
  change for you, but if you notice something doesn't work anymore, MAIL ME!
v3.8b0704
= Fixed a couple of range checking bugs.
v3.8b0629
= Minor update. Turns out G2 3.0 streams can only be played with RP8.
  Added a warning tag to the info screen.
! RMFix WON'T WORK ON A WINDOWS 2000 SYSTEM. W2K doesn't like changing
  screen modes and won't show anything on screen, whatever I try on the
  test system. W2K users will have to wait a while for Cascade to code
  the GUI version of the RMFixer.
v3.8b0627
= Minor update. Since W2K's dos mode STINKS and won't let me turn off the
  cursor (It turns off everything, giving you a black screen. Nice one MS),
  I've turned off the beautifications if the current dos version isn't 7.10.
  Still needs to be tested on a W2K system ('ll do it tomorrow but this
  should fix it...)
= Fixed a small bug in the filesize checking code. Reported incomplete files
  as both complete AND incomplete (yeah yeah, I know, I know ;)
+ Added an installer that installs the fixer to a user-specified directory,
  automatically creates the context menu and tries to add it to the windows registry.
v3.8b0619
= Slightly changed the chopped file handling... now guesses the amount of
  time you lost (not entirely accurate, but pretty close ;)
+ Command-line filesize checker added.
v3.8b0611
= Changed the invalid timestamp fixer some more... now gives the current
  stream number (always nice to know what you're working on) and gives
  the difference between this timestamp and the previous one.
+ Added the index list creator (command-line only). Probably not very useful
  to you, but I needed it so I thought I might as well leave it in ;).
v3.8b0609
+ Added the patch file options. Here's the deal : Patch file gets created
  at the same time your undo file gets created, so if you plan on spreading
  patches, make sure you know what you're doing when you make them.
  A word of warning : PATCH FILES ARE OVERWRITTEN EVERY TIME YOU TURN
                      PATCH FILE CREATION ON.
= Added rmfix.reg : Should add a context menu to RMs, allowing you to run
                    RMFix with some of the command line options from the
                    windows explorer. You'll need to edit it with a text
                    editor first, because it tries to run c:\windows\rmfix.exe
v3.7b0603
+ Added a 'gradual undo' to allow undoing only specific fixes.
v3.5b0529
= Well, seems it wasn't the last one ;) New in today's build is the ability to show the
  info screen from the command line for files on read-only media.
- Removed half of the hidden parameters.
v3.5b0521
= Developer's version with some hidden new parameters not useful to people
  out there and only half-working.
  Probably gonna be the last version for a while (finals in a week), so unless
  there's a major bug somewhere, this will be it.
v3.5b0520
+ Added a 'check with autoaccept and no undo' to the options for a chopped file.
  Use with caution ;)
v3.5b0519
= Small changes. Seems I fucked up the removal of empty undo files in one of
  the previous versions. Should be fixed now.
v3.5b0516
= Some more code cleanups. Should be slightly faster now.
+ Fixed another bug in the invalid timestamp fixer.
v3.5b0510
= Started coding the patch-file creation some people requested. Will prolly
  be in by sunday.
= Added an extra check at the beginning to quit immediately if the file
  is a SureStream file and the command-line info isn't used. (Yes people,
  I'm fed up with users telling me they can't use it on a file only to find
  out it's a SureStream file!)
+ Finally added a packet length 0 fixer I had lying around here.
  Needs another pass though to make sure everything's fixed ;)
+ Changed the demuxer a bit. Files with erroneous and/or double blocks should
  ignore those now and write 'fixed' streams. Most of the Kernel Crashes can
  be fixed now by first demuxing then remuxing a file.
+ Added the command-line kernel crash fix, which demuxes a file and immediately
  remuxes it again. Also useful for those files with unfixable and/or erroneous
  blocks.
v3.5b0509
= Changed the user interface slightly (new keyboard shortcuts).
+ One person reported problems playing a resynced stream so I've added an
  'unsync' option to put the original rates back.
= Fixed the end-time bug.
v3.5b0507
+ Some more bugs fixed.
+ Finally added the overlooked INDX block seeker for index offsets that point
  to BEFORE the actual index blocks. Checks the last 256Kb of a file (should
  be enough for the required index blocks) and sets the index offset to the
  value found. If nothing is found, it's set to the end of the file.
v3.5b0506
+ Fixed some more dumb bugs to do with the last packet to be checked.
+ Cleaned up the Index Rebuilder and closed a couple of loopholes that could
  hang the program. Added a final option : the current index block gets cut off
  when you press a key. Only to be used when the counter at the top of the
  screen jumps to 0 and stays there.
v3.5b0503
+ Fixed a stupid bug in the file muxer. Now accepts streams with extra content
  headers.
+ Sped up the (de)muxer by a factor 1000 approx. This code is extremely
  fast but could give problems on older systems. Mail me if this happens.
+ File splitting is almost complete... Chopping off an endpart works,
  chopping off a part at the beginning of the file has some problems.
v3.0b0502
+ Added the possibility to change the ending time of the data packet
  checker (rounded to the nearest indexed packet)... This will also be
  used in the file splitter.
= Switched to 80x50 display for some of the screens.
v3.0b0501
+ Added some more command-line options.
= Switched build date to mmdd instead of ddmm.
v3.0b3004
+ Added the possibility to change the starting time of the data packet
  checker (rounded to the nearest indexed packet).
v3.0b2804
+ Fixed a horrible bug in the timestamp fixer.
= Ran more tests on the sound resyncer. Works perfectly.
v3.0b2604
+ Added a 'possible unsync' warning to the information page
v3.0b2504
+ Completely rewritten sound resyncer. Seems to work on every file I've tried.
+ Command line option added for sound resyncing.
v2.9b2404
+ More info about the audio stream : Codec + sampling rate.
+ More info about the video stream : image size + framerate.
v2.9b1704
+ The muxer has been completely finished. It's as slow as the demuxer...
  Gonna see what I can do about that.
+ Command line option for batch (de)muxing files.
= Added stream number indicator next to the packet length
v2.9b1504
= Nothing much... Now you can input new timestamps as either an integer number
  or a time (format : DD:HH:MM:SS.MS)
* Work in progress version of the muxer... Muxed files aren't playable yet ;)
= Rearranging my code... Some things could be broken.
v2.8b1404
= Some small changes. Now tries to change the read-only attribute on files
  and gives an error message if it doesn't work (read-only media ?).
= Now able to check the first stream of a Surestream file... Maybe. Can give
  some errors that aren't really there due to difference between Surestream
  and single stream files.
v2.8b1204
= Rewriting timestamp fixer. Code halfway implemented. Read limitations.
  If the previous stream packet & next stream packet have the same timestamp
  then the current packet's timestamp will be set to that timestamp.
+ 'Intelligent' stream number predictor rewritten... Correct 99% of the time now.
+ Added an abort option to most checks.
+ Finally added the 'misaligned index block' code I've been meaning to add
  for ages now ;)
= Fixed various smaller bugs.
= Some small cosmetic changes.
v2.7b1004
- Fixed a small bug in the SMIL creator
- Fixed the 'Run-time error 2' error in yesterday's build (stupid typos ;)
- Fixed yesterday's build so the timestamp checker is off by default
  (as originally intended).
+ Made a switch for the stream number fixer too... In addition, stream number
  fixing is turned off in the demuxer (= packets with bad stream numbers are
  skipped).
V2.7b0904
= Discovered some weird stuff with the timestamp fixer turned on when retrying
  files fixed perfectly with versions prior to 1.7 ...
  Made a switch to allow choosing of whether you want to use it or not. (defaults to on)
+ Added option for removal of backup/undo files after restoring from them.
+ Stream demuxer is finished. Doesn't build indexes, which aren't necessary
  for a single stream file it seems.
+ Added SMIL file creation for the demuxed streams.
v2.6b0804
+ Did some more work on the sound resyncer... Tested on a couple of files,
  seems to improve syncing 50% of the time.
+ Added better LFN support.
+ The Undo function is back... everything can be undone except the creation of
  new index blocks.
v2.5b0704
= Fixed the rmfix crash bug that happened with some RMs...
  Block checking should be about twice as fast as in v2.4.
v2.5b0604
+ Rewritten the 'next timestamp' searcher... now it shouldn't bomb on
  files with a big stretch of bad data.
= More error trapping.
= Some more code cleanup.
v2.4b0204
+ Tried my hand at a sound resyncer... A first couple of test have shown
  a slight improvement in the time sound stays synced.
= Fixed the 'bug' discovered in v1.1... Turns out I picked the wrong
  possibility from the 2 offered in the documentation ;). Luckily
  it isn't in anything vital...
+ Fixed a stupid bug in the flags.
v2.3b0104
+ Rewrote the timestamp checker... Sets the maximum gap between 2 packets
  to four times the gap between the first 2 indexed packets by default,
  adjustable in a 2-10 second range.
+ Fixed indexed packet checker for stream 1.
= For those of you waiting for the undo option to reappear... undo will be
  put back in when the timestamp problems are all solved... might be a little
  while longer ;)
v2.2b2703
+ Edited timestamp support a bit... still really crap... now you have to
  input the timestamp to be used... Yes, I *KNOW* it stinks but I needed to
  be able to test something... Don't worry, I won't keep it this way...
v2.2b2603
+ Added basic timestamp fixing support... it's really crap and shouldn't be
  used too much but at least it's another type of error that might get fixed.
v2.2
+ Added a 'make backup' option... also checks if a backup already exists.
  Your best bet is to run the backup the first time you check a file and not
  to touch the backup again until you're sure the file has been fixed...
  (for people who don't trust my undo code yet... me for example since I
   didn't include it in today's build ;)
+ Added support to put backups (and undo files) in a specific directory
+ Ability to save this directory to a configuration file for further use
v2.1
+ Added some more checks to the autofixer... should eliminate all "invalid
  stream nr" errors caused by the autofixer itself
- Removed the undo option... will be back soon
v2.0
+ Completely rewritten index rebuilder from scratch... Works 100%!
+ Added an undo option
v1.8
+ Took another stab at the index rebuilder.
  Now works 70% of the time, which is an improvement over the 10% or so of
  the previous version ;)
v1.7
+ Added Index Rebuilder (buggy as hell but does allow some seeking, so I might
			 as well release it already and fix the bugs later)
v1.6
= Limited Public Release
+ Added an "Autofix" to data packet checker...
  Well, the code's all there, and everything should work perfectly, but you
  better read bugs first ;)
v1.5
+ Added a data packet checker
v1.4
+ Now accepts wildcards
+ Added a menu interface
v1.3
+ Checking of all the indexed packets for stream 0
v1.2
+ Added reading of all the index blocks
v1.1
= Fixed a bug due to an error in the official RealMedia File Format
v1.0
= First working version... read in all the stream data
