The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: exhydra on July 08, 2011, 11:51:41 PM

Title: [XP/VX/VXA] Project Optimization (Revision 2.5; Upd-07/04/15)
Post by: exhydra on July 08, 2011, 11:51:41 PM
Spoiler for Update History:
  • < Version 2.5 | 07/04/15 >
    • Updated a tutorial on time compression.
    • Updated Zeriab's Remove Comments project under Scripts.(RXDATA/RVDATA/RVDATA2) Comment Removal.
    • Removed MCP under Optional Software Tools.
  • < Version 2.1 | 10/23/12 > Added RVDATA2 Compression under Data > RVDATA2 Compression
  • < Version 2.0 | 10/09/12 > Updated for RPG Maker VX Ace; updated appearance.
  • < Version 1.9 | 08/03/11 > Added Radical Image Optimization Tool under Graphics > PNG/JPEG Optimization
  • < Version 1.8 | 07/24/11 >
    • Added a tutorial on media compression.
    • Added a tutorial on time compression.
    • Added MCP under Optional Software Tools.
  • < Version 1.7 | 07/16/11 > Removed the textual tutorial on looping and added a video tutorial.
  • < Version 1.6 | 07/14/11 > Added Blizzard's Resource Tester project under Stowaway Files (thanks GameGuysProjects)
  • < Version 1.5 | 07/13/11 > Added Zeriab's Remove Comments project under Scripts.(RXDATA/RVDATA) Comment Removal.
  • < Version 1.4 | 07/12/11 > Added JPEG & PNG Stripper under PNG/JPEG Optimization.
  • < Version 1.3 | 07/12/11 > Added the Compact RVData script under .RVData Compression.
  • < Version 1.2 | 07/08/11 > Added a tutorial on looping.
  • < Version 1.1 | 07/08/11 > Added Yeyinde's RM Data Checker under Stowaway Files (thanks cozziekuns)
  • < Version 1.0 | 07/08/11 > Initial Release

Spoiler for Easy Category:
  • \ Graphics
    • < PNG/JPEG Optimization (XP/VX/VXA) >
      One of the easiest and quickest ways to shrink your project size is to use a PNG/JPEG optimizer on all of your graphics. While saving roughly 20 kb off of a single file may not seem very impressive, if your project has a large amount of graphics, then these small bits begin to add up quickly.

      For example, I recently optimized a project for a friend which had about 1,500 PNG files. The original size for the entire graphics folder was 84,085,192 bytes (84 mb). The size of the folder after I ran a quick PNG optimization was 57,719,751 bytes (57 mb). That's a difference of 26 megabytes simply by removing excess information that's not being used by the game and then re-compressing the file. No extra scripts or advanced computer knowledge required.

      There are a plethora of options available for PNG/JPEG optimization, but I personally prefer the following programs :

      • PSYDK.ORG PNG Optimizer (http://psydk.org/PngOptimizer.php)
        This program features an easy to use interface which you can quickly drag and drop your files into. Very simple to use. By default, the program makes backups for each file that it optimizes, so remember to either disable this feature through the options menu or move the backups after optimization is complete. No installation required; free to use.

      • Radical Image Optimization Tool (http://luci.criosweb.ro/riot/)
        RIOT combines several different compression methods and options for both JPEG and PNG files into one powerful application. It offers a side-by-side comparison which updates whenever you make a change, allowing you to see the end result before it is saved. The program also has a batch optimizer function which can handle multiple files at once. Highly suggested for those wanting more control than PSYDK PNG Optimizer and JPEG & PNG Stripper without the command line aspect of OptiPNG Advanced PNG Optimizer. Small installation required; free to use.

      • OptiPNG Advanced PNG Optimizer (http://optipng.sourceforge.net/)
        Unless you're like me and find glee in squeezing every last useless kilobyte out of PNG files, use the PSYDK PNG Optimizer instead. This is a command line PNG optimizer which has advanced options not normally needed, but can occasionally eek out several more kilobytes of unneeded data from the image file. No installation required; free to use.

      • JPEG & PNG Stripper (http://www.steelbytes.com/?mid=30)
        Unlike the other two options above, this program removes useless metadata from JPEG files as well. If you are using JPEG files, I highly suggest running them through this optimizer to clear up the most amount of space possible. The program has an easy to use interface which you can quickly drag and drop your files into. Very simple to use. Please note that some anti-virus software may mark this program as malware, but it is not. No installation required; free to use.




    • < Thumbnail Cache Files (XP/VX/VXA) >
      Occasionally I see these database files just hanging around in one or more of the graphics directories, taking up space that they shouldn't be. Thumbs.DB is often the biggest offender. This file is generated automatically by Windows when browsing a folder with image files while the 'thumbnails' view is enabled. Always check to see if you have any such files before you export the release of your game, as I have seen them bloat as high as 5 mb.

    • < Stowaway Files (XP/VX) >
      Quickly run through your current graphic and audio files. Open them up, visually inspect or listen to them. Are you using all of them in your project? I've found myself guilty of allowing stowaway files into my project. That is, images that are not being used in the game and are most likely left overs from a quick graphic test or an older backup version of something that is being used in the game. These normally don't eat up very much space, but in larger games allowing these moochers to tag along can inflate the size of your project by several megabytes.

      If you're unsure if you're still using a certain graphic or music file within your game, move the file out of your project folder and use the following program or script to see if any errors crop up :

      • Yeyinde's RM Data Checker (http://rmrk.net/index.php/topic,38957.0.html) (XP/VX)

      • Blizzard's Resource Tester (http://forum.chaos-project.com/index.php/topic,113.0.html) (XP)

      • Jet's Integrity Checker (http://pastebin.com/raw.php?i=DmQ8DN6W) (VX)

Spoiler for Intermediate Category:
  • \ Audio
    • < General >
      • Suggested Software Tools

        • Audacity Sound Editor (http://audacityteam.org/download/)
          Using Audacity is not required, although all of the steps for this tutorial will be done using that program. This is a fairly easy to use and completely free sound editor.

        • fre:ac Audio Encoder/Converter (https://www.freac.org/index.php/en/downloads-mainmenu-33)
          If you already have audio files created for your project and want to manage their size through compression, I suggest using fre:ac. The program has a straight forward interface and configuration is quite easy.

      • Optional Software Tools

        • MP3Gain MP3 Audio Normalizer (http://sourceforge.net/projects/wxmp3gain/)
          Occasionally I will come across MP3s that are just outright loud or strangely quiet. I use this utility to bring their default volume up or down to a more acceptable level. This can be done within Audacity as well.




    • < Looping (VX/VXA) >
      Although the Graphics directory is often the biggest offender of project size bloat, the Audio directory can often rival or in many cases surpass its graphical neighbor.

      One way to help reduce the bulk of your Audio directory is to find a section within the music files to lock into an endless and flawless loop. To show the steps required to make a looping OGG file, I have created a short tutorial video which can be viewed below or by clicking the following link : RPG Maker VX/VXA Audio Looping Tutorial (http://www.youtube.com/watch?v=2dHo2kBkC6Y)

      <a href="http://www.youtube.com/watch?v=2dHo2kBkC6Y" target="_blank">http://www.youtube.com/watch?v=2dHo2kBkC6Y</a>



    • < Media Compression (XP/VX/VXA) >
      If the complicated process of creating audio loops for your project is not something you want to take on or is otherwise not an option, you should consider at least compressing your media so that it takes up less space. Even if you are someone who enjoys high quality audio, I'm sure that you would be surprised about how far you can compress an audio file and still maintain great quality.

      In this tutorial, I will be going through setting up fre:ac to encode and heavily compress MP3 files into OGG files. Please note that you could also use Audacity to compress your files, although fre:ac is better for handling a large quantity of files at once.

      Spoiler for:
      • < Step 1a > : Before we get started actually compressing audio files, we'll need to change a few settings from their defaults. After opening fre:ac, go to the Options menu and select the General Settings ... option.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-1.png&hash=76a3602bd752de359c24177ca04262f8fad038e5)


      • < Step 1b > : Within the Encoders tab and under the Encoder subsection, click on the drop down menu and select the Ogg Vorbis Encoder option. Next, click on the Configure Encoder button which is just to the right of the drop down menu.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-2.png&hash=f32f9bb5a33574e4eb56e5b72d5bf3ac3f6b91a7)


      • < Step 1c > : Make sure that the VBR (Variable Bitrate) option is selected before dragging the quality slide bar to the left. Personally, I prefer to set the quality to zero as I have found this squeezes the most out of the source media while leaving pretty decent quality in the end result. If you wish to adjust the slide bar and test your files at different levels of compression, simply make your changes here.

        To save the compression settings, press the OK button.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-3.png&hash=e95badc5a5412564011ef6edf560ed355f72eb34)


      • < Step 1d > : If your audio files are already in use within your RPG Maker project, you will need to change another option to keep the program from renaming your files as it encodes them. Within the Encoders tab and under the Filename Pattern subsection, click on the drop down menu and select the <filename> option. This will maintain the naming conventions that you currently have in place. Otherwise, the program will use any metadata tags (ID3, OGG comments, etc) to rename the compressed file.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-4.png&hash=54e731e8f89bfa53afd2ae3b6d2dee1e8c52fce0)


      • < Step 2a > : Now we'll add the files that we want to compress to the joblist. To do this, simply click on the Add Files button, or click on the drop down arrow beside the button for more options. In this example, I will be using the From Directory ... option, as this allows me to add an entire directory of audio very quickly.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-5.png&hash=119a13b2352b80ee72d65809d3d054f27584fe5e)


      • < Step 2b > : After clicking on the Browse button on the Add Directory window, we'll navigate to and then select the directory which contains the source audio files. After selecting the directory, press the OK button and the program will add the files to its joblist.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-6.png&hash=b713725975faa7279f9d7a1a3a78114cb23a03f4)


      • < Step 3 > : Now that the audio files have been added to the joblist, make sure that the Output Dir is set to the directory where you wish to have the compressed output sent to.

        Next, we'll make certain that our current encoder is set to Ogg Vorbis. This can easily be determined by looking at the Selected Encoder field which is just above the Output Dir field near the bottom of the program window.

        Once everything is set, we can start encoding either by pressing the Start Encoding toolbar button near the file menu at the top of the program window, or clicking on the Encode menu and selecting the Start Encoding option.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-7.png&hash=6e1907b17f38d00196fead1cf7a146f00d1c2042)


      • < Step 4 > : And we're done! Verify that all of the files have been encoded properly by listening to them before adding them to your project.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fm-compress-8.png&hash=4d53a8dda8c6b739068d0104751e758b00ac09c5)


      • < Step 5 > (Optional) : If you're worried about heavy loss of quality, you could use Audacity or your favorite media player to toggle between each file, listening carefully to determine if more quality should be applied. Simply return to Step 1c and change the quality setting should you feel that more quality is needed. However, remember that often you will be the only one to notice small drops in quality once your game is released.


Spoiler for Extreme Category:
  • \ { Base Directory }
    • < Executable Packing (XP/VX/VXA) >
      Although this is wandering into the realm of silliness, you can also shave around 30 kb from the Game.EXE file by using an executable packer. There are many options available for such compressors, although I would suggest using the following program :

      • UPX (Ultimate Packer for eXecutables) (http://upx.sourceforge.net/#downloadupx)
        This is the portable GUI version of the popular UPX program. Quick, reliable and fairly easy to use. No installation required; free to use. Using the following options should allow for optimal compression while not interfering with the normal operation of the executable :

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Fupx-options.png&hash=c4b4df7595cc1e5e3bbcca4fb0f2486c9af535c1)

        After packing the executable, remember to run and play through your game to check for any incompatibilities that might arise, although there really should not be any. If everything is running fine, delete the backup file Game.EX~. If the game crashes or displays problems after compression, delete the packed executable and rename the backup file to take its place.


  • \ Audio
    • < Time Compression (XP/VX/VXA) >
      Another trick that can be added to a fanatical kilobyte killer's arsenal utilizes RPG Maker's built-in audio pitch control.

      Using Audacity, you can change the speed at which the song plays. Since increasing the speed lowers the amount of time that the song is playing, this also means that it will take up less space once it is compressed. Normally, the newly altered song would sound like something that the Chipmunks performed, but once you import it into your RPG Maker project you can use the native pitch control to slow down the song and thereby making it listenable once more.

      The downside to this trick is that if you have a looping OGG file, you will have to find the loop points within the squished audio data all over again. Also, compressing the audio in this way may degrade its quality. Generally, I squeeze about 300 to 500 kilobytes from each file (comparing original compressed OGG versus time compressed OGG) that I apply this method to, which may not seem like much but it can add up quickly.

      Spoiler for Time Compression:
      • < Step 1 > : Launch Audacity and open the file that you wish to use. I would suggest using the highest quality of source audio available to you.


      • < Step 2 > : We'll now click on the Edit menu and place the mouse over the Select option to expand another menu. Next, we'll click on the All option to select the entire length of the audio file.


      • < Step 3a > : After that, we'll click on the Effect menu and select the Change Speed option which will bring up the Change Speed window.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Ft-compress-1.png&hash=5a2501800c8bdd8be847b27769e68995ab893bc1)

        Here you can enter the amount of change you wish to apply to the speed of the song. I would suggest entering a value divisible by five, as the pitch slider bar in RPG Maker goes up or down in increments of five. Also, since RPG Maker only allows you to alter the pitch up to fifty percent in either direction, you should not enter a value above fifty. Personally, I use either a value of 25 or 50.

        After entering the amount that you want, press the OK button and Audacity will begin altering the speed of the song.


      • < Step 3b > : If this is a file that you are wanting to use OGG looping with, remember to find the loop points again and write down the selection start and end information. See my video tutorial above about OGG looping if you are not familiar with how it works.


      • < Step 4a > : Now that we have sped up the song, all that needs to be done is export the new audio data and compress it. This can be done by clicking on the File menu and selecting the Export option.

        The Export File window should then appear and you can either select MP3 or Ogg Vorbis from the Save As Type drop down menu. Personally, I prefer using fre:ac for the encoding of my media files, so I will export the audio data as WAV (Microsoft) to keep the source audio quality high for now. Follow my tutorial on media compression above if you are following my route.

        If you are using the MP3 or Ogg Vorbis options, remember to click on the Options button on the lower right-hand side of the window and choose your desired compression settings.


      • < Step 4b > : Regardless of what format you choose, after you click the OK button, an Edit Metadata window will now appear. Again, if you are using OGG looping you will want to input the selection start and end information here. If not, simply click the OK button to instruct Audacity to begin exporting the newly sped up audio file.


      • < Step 5 > : Import the newly compressed file into your RPG Maker project. You may wish to click on the Tools menu and select the Sound Test option to try and find the correct pitch setting to restore the proper playback.

        (https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.moofah.com%2Ftemp%2Fmedia%2Fimages%2Fpng%2Fmboard%2Ft-compress-2.png&hash=9fcde11f3c7440d5d9ee0d1d49c82f061c491882)

        The displayed settings above are for an audio file which was sped up by fifty percent.



  • \ Data
    • < .RVDATA Compression (VX) >
      I've currently completed a script to allow for compressing .RVDATA within the Data directory, as its total size can often roam higher than 4 mb in large projects. Current test runs have dropped the size from roughly 5 mb to 500-ish kb (200 maps, full compliment of items, armors, weapons and animations). No third party DLLs or EXEs required.

      • Compact RVData (http://rmrk.net/index.php/topic,43155.msg492060.html) (VX)



    • < .RVDATA2 Compression (VXA) >
      Jet has ported over his own compression script to VXA, allowing for .RVDATA2 files within the Data directory to be compressed.

      • RVData2 Compression (http://www.rpgmakervxace.net/topic/214-rvdata2-compression/) (VXA)



    • < Scripts.(RXDATA/RVDATA/RVDATA2) Comment Removal (XP/VX/VXA) >
      Although the Scripts.(rxdata/rvdata/rvdata2) file cannot be compressed by the Compact RVData script above, it can still be optimized by removing commented lines and carriage returns. Zeriab has created a project for doing just that and I believe that it does its job well. For example, I have taken a heavily commented Scripts.rvdata2 which was 270 kb and come away with a 170 kb file after.

      It should be noted that removing the comments and carriage returns will make reading the code very difficult and should only be done when you are ready to release your game. You should also make a copy of your original Scripts.(rxdata/rvdata/rvdata2) and over-write the optimized version after having finalized your compressed distribution file.

      NOTE : There are no guarantees by the author of this project that scripts will be in complete working order after the comments and carriage returns are removed. Please test your game thoroughly before releasing the finished product.

      • Zeriab's Remove Comments (https://www.dropbox.com/s/c1v2ifisnt4oct5/Remove%20Comments.zip?dl=0) (XP/VX/VXA)
        To use, place your Scripts.(rxdata/rvdata/rvdata2) file in the Input folder and run Game.exe. The comment-stripped Scripts.(rxdata/rvdata/rvdata2) file is output to the base folder once the process has finished.

Title: Re: [XP/VX] Project Optimization (Revision 1.0)
Post by: pacdiggity on July 09, 2011, 12:10:14 AM
Very nice tutorial, Exhydra. I look forward to seeing more of this, and more games that won't take up 500 MB.
Title: Re: [XP/VX] Project Optimization (Revision 1.0)
Post by: modern algebra on July 09, 2011, 01:09:30 AM
This is a great tutorial. Nice work Exhydra! Where did you come from anyway? You're so helpful and awesome and I'm not used to that in new members - it's creeping me out :P
Title: Re: [XP/VX] Project Optimization (Revision 1.0)
Post by: cozziekuns on July 09, 2011, 02:12:47 AM
http://rmrk.net/index.php?topic=38957.0

This is a cool tool made by Yeyinde for checking if you have unused files in your RM Folder.  Seems a bit faster than Jet's Integrity Script. Anyways, great tutorial Exhydra!
Title: Re: [XP/VX] Project Optimization (Revision 1.1)
Post by: exhydra on July 09, 2011, 02:53:28 AM
Very nice tutorial, Exhydra. I look forward to seeing more of this, and more games that won't take up 500 MB.

Thank you! More on the way in regards to audio, which generally causes the most project bloat ...




This is a great tutorial. Nice work Exhydra! Where did you come from anyway? You're so helpful and awesome and I'm not used to that in new members - it's creeping me out :P

I've lurked around the RPG Maker scene for a while, so I'm not exactly new-new. Although it was only recently that I've become more vocal and taken a higher interest in scripting and optimization. :o




http://rmrk.net/index.php?topic=38957.0

This is a cool tool made by Yeyinde for checking if you have unused files in your RM Folder.  Seems a bit faster than Jet's Integrity Script. Anyways, great tutorial Exhydra!

Thanks, Cozzie! I've added that tool into the tutorial. I didn't even know it existed.
Title: Re: [XP/VX] Project Optimization (Revision 1.4; Upd-07/12/11)
Post by: Nessiah on July 13, 2011, 02:34:33 PM
This is really cool! Thank you for sharing these stuff bro B)
Do you mind if I spread it to other sites as well to help fellow makers? :D
Title: Re: [XP/VX] Project Optimization (Revision 1.4; Upd-07/12/11)
Post by: exhydra on July 13, 2011, 08:20:12 PM
Sure, that's fine by me. The more people with non-500 megabyte projects, the better!  :o
Title: Re: [XP/VX] Project Optimization (Revision 1.7; Upd-07/16/11)
Post by: vogelmeister on July 18, 2011, 12:35:48 PM
Thank you very much for this. You've made my day ;)
Title: Re: [XP/VX] Project Optimization (Revision 1.9; Upd-08/03/11)
Post by: Jackaroni on January 17, 2012, 09:37:53 PM
Thank you for making this! this helped me so much and now i am happy and still using these tutorials to help me ;8
Title: Re: [XP/VX] Project Optimization (Revision 1.9; Upd-08/03/11)
Post by: EvilM00s on January 23, 2012, 06:31:27 AM
Where have I been? Just found this thread and I am excited to run my VX project throught the steps to reduce its filesize!
Title: Re: [XP/VX/VXA] Project Optimization (Revision 2.5; Upd-07/4/15)
Post by: exhydra on July 04, 2015, 06:51:02 PM
Title: Re: [XP/VX/VXA] Project Optimization (Revision 2.5; Upd-07/04/15)
Post by: Acolyte on July 05, 2015, 12:28:22 AM
Kudos for maintaining this, even after four years.
Title: Re: [XP/VX/VXA] Project Optimization (Revision 2.5; Upd-07/04/15)
Post by: Gaming Princess Luna on July 05, 2015, 02:54:35 PM
This is one of the most usefull tutorials I've ever read. :D
I shrinked the size from 156,491 MB down to 84,21 MB. :D
That is a filesize difference of 46,19%. O.o
Thank you so much for that tutorial. :) (\s/)
Title: Re: [XP/VX/VXA] Project Optimization (Revision 2.5; Upd-07/04/15)
Post by: exhydra on July 05, 2015, 06:33:07 PM
I'm glad the tutorial was so useful to you. :)