-
-
Notifications
You must be signed in to change notification settings - Fork 4
Shrinking media files
The originals of photos and audiorecordings are often huge files. Usually, you'll want to shrink down any copies that Anki and other software will use, after backing up the originals. If you have very many media files, batch-editing software is the most efficient way to do the shrinking. The best file formats are:
-
Audio: MP3 at fairly low quality (e.g.
Constant Bit Rate, 64 kbps, Joint Stereo
) is the most portable choice. OGG is a better format (and non-proprietary) but currently isn't quite as widely supported (works fine in Anki/Mplayer). WAV files aren't good because they are uncompressed--they must be far bulkier to achieve comparable quality.Note: To many people's ears, CD quality falls somewhere around MP3 160 kbps VBR (Variable Bit Rate), which is comparable to OGG at 128 kpbs.
-
Images: PNG's lossless compression works best for images with solid colors (clip art, line drawings, logos, etc.); PNG is much like a zipped BMP--always looks just as good and is smaller. JPG usually gives better compression for photos, but JPG loses quality each time you save it.
If the images are just for use in flashcards, it may be sufficient to save photos using JPG at 75% quality, and with the longer dimension (width or height) to 240px. It partly depends on whether the image is ever intended to be shown full-screen.
If you really want the best bang-for-the-byte, you might try using a tracing tool to convert your photos into line drawings. (See tools such as XnConvert, potrace, InkScape, etc.) If you convert a JPG photo to an SVG line drawing, you can either use it as is (SVG scales to any resolution) or save it to PNG (more portable, and no change to filename, but you must choose a DPI/resolution).
-
Video: MP4 is a well-supported format. Sizes on disk can get very big, very fast, so you may need to be cutthroat on size/quality. The shared ASL deck uses a width of 172px and usually a height of 128px. Be sure to verify up front that Anki (actually, MPlayer) can play your selected video file format. Note that there is no special link format for videos; instead you create an audio link. Example:
[sound:jump.mp4]
Back up your collection.media
folder first. This is especially important if you've directly created any media files while editing in Anki, as those may be your only copies.
-
Paste this path,
%userprofile%/Documents/Anki
, into Windows Explorer's address bar and hit Enter. By default, the media folder isUser 1/collection.media
. (If you are actively using FlashGrab, you may need to leave your username set to this default.) -
Right-click your
collection.media
folder, then Send to / Compressed (zip) file. Rename the resulting backup file to include a date/description.
Anki requires that all media files be in your collection.media
folder. They must all be crammed together, and not in subfolders, so any images pulled in by FlashGrab will be given names starting with the deck name, e.g. lift-dictionary_house.jpg
. This is also a good practice for any media files you add to Anki. Sorting by filename makes it much easier to edit or delete related media files.
In its internal database, Anki just stores the names of the files, surrounded by the special formatting that indicates a link to an image or audio file. So, it is quite safe and proper to modify those media files directly, provided you don't change the file names. (Shrinking a large JPG to a small one is simple, whereas shrinking a BMP by converting it to PNG or JPG involves a name change--and thus an update to Anki's link to the file.)
If you are using FlashGrab to 'pull' you data from elsewhere, you should perform the resizing on the originals (e.g. house.jpg
in a WeSay or FLEx project) and then do a fresh sync to pull the newly-shrunk files into Anki.
If you are not using FlashGrab, you should perform the resizing directly on the files in collection.media
(after making a backup, of course). Note that even if the files originally came from somewhere else on your hard drive (such as %userprofile%/Pictures
) Anki will automatically make its own copy in collection.media
.
IrfanView is free and full of features, and even with its bundle of addons, it's not a big download. It can process multiple images at once--this is mainly useful for shrinking or standardizing the sizes of images.
-
In IrfanView, choose File, Batch Conversion...
-
Manually browse to the location of the files, which is typically
%userprofile%\Documents\Anki\User 1\collection.media
, using the Look In field. Or, you can paste a folder path directly into the File Name field. -
Choose a target location. If you've made a backup of
collection.media
, it's simplest to click the "Use Current" button and just overwrite the existing files in situ. -
Set the
Output format
to the same file type as the original (typically PNG, or JPG for photos). The reason for not changing the file type is because it would change the file name. NOTE: Irfanview can do type conversions too, all in one swoop, but these are best done before ever bringing the files into Anki. -
Select the files to be processed, pressing Add (or Add All) to have the batch process edit them. You can use Shift or Ctrl to select a group of files, but remember to still click the Add button afterwards. It's often helpful to switch the file view to
View / Details
mode and make sure it's sorted properly. -
Open the Advanced Options dialog and tick Resize. Choose to
Set long side
to a small size (240px is pretty good for laptops). For JPG, also set the regular options to be somewhat compressed. -
Click
Start Batch
. -
Go to the target folder in Windows Explorer, do a Refresh (F5), and verify that the output files are small enough and look ok. Do some spot-checking in Anki as well, by drilling a bit with those cards.
Audio files can likewise be resized en masse using a program such as Audacity (or Audacity Portable.
As mentioned above, shrinking an MP3 to a smaller MP3 is simple. Shrinking a WAV into an MP3 involves a change to the filename--and thus a need to update Anki's link to it. Again, this is why it's best to shrink the media files (or to at least pick a shrinkable format) before bringing the files into Anki (or into WeSay/FLEx, for that matter).
In Audacity, go to File, Edit Chains
to set up a conversion process, and then use File, Apply Chain, Apply to Files
to run the process on a batch of audio files. Here, our 'chain' will consist of a single operation--an Export to MP3.
-
Run Audacity, press the Record button (red circle), then Stop (yellow square). Or, use the
Generate, Silence
option. -
Now that you have some audio, go to
File, Export
, set the file type to MP3, then clickOptions
to choose some fairly low-quality settings, such asConstant Bit Rate, 64 kbps, Joint Stereo
. -
Cancel the export, or test it on your current file. Either way, your MP3 export settings will be remembered.
-
Close the project (no need to save it), or save the project.
-
Under
File, Edit Chains
, verify that you have a chain you like that includes the ExportMp3 command. To create one: (a) click Add and choose a name such as "Export as MP3", (b) click Insert and double-click on the ExportMp3 command, (c) click Ok twice to save the chain. -
Choose
File, Apply Chain
, select your chain, clickApply to Files
, and browse to your files. For example, you'd either browse to the location FlashGrab pulls media files from, or else to%userprofile%\Documents\Anki\User 1\collection.media
. (You can copy/paste that path.) Select all the files you wish to shrink, then click Open. WARNING: Acleaned
subfolder will be used or created, and any existing files with matching names will be silently overwritten. -
Verify that the file sizes and sound quality are acceptable. If not, change the settings and run the export again. Once satisfied, cut and paste the files back up one level, overwriting the original files. (Again, we are assuming you made a backup.)
-
If using FlashGrab, your weren't working directly on the
collection.media
folder, so you still need to sync these latest files over to Anki. (FLEx users, you may need to export to LIFT first, but only if you did not configure FlashGrab to pull directly from your FLEx project's LinkedFiles folder.)
For an actual chaining example, see http://www.howtogeek.com/57571/how-to-quickly-edit-multiple-files-in-audacity/ .
Handbrake is a popular free program for converting video files. There are various tutorials (and alternatives) on the web:
-
Alternatives:
https://www.google.com/webhp?q=best+batch+convert+video
http://lifehacker.com/five-best-video-converters-1191180767
http://www.digitaltrends.com/computing/best-free-video-converters/
-
http://www.howtogeek.com/199993/converting-videos-by-the-batch-with-handbrake/
-
A more streamlined version (probably): http://www.macworld.com/article/2049117/handbrakebatch-review-easy-does-it-batch-video-conversion.html