Difference between revisions of "WavPack"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
(Added file extention and magic number)
m (A word on the CoolEdit format.)
(17 intermediate revisions by one user not shown)
Line 5: Line 5:
 
| caption = Hybrid Lossless Audio Compression
 
| caption = Hybrid Lossless Audio Compression
 
| maintainer = David Bryant
 
| maintainer = David Bryant
| stable_release = 5.1.0 (20-01-2017)
+
| stable_release = 5.5.0 (2022-07-07)
 
| preview_release = None
 
| preview_release = None
| operating_system = Windows, Mac OS/X, Linux/BSD/Unix
+
| operating_system = Windows, MacOSX, Linux/BSD/Unix, ...
 
| use = Encoder/Decoder
 
| use = Encoder/Decoder
 
| license = BSD license
 
| license = BSD license
Line 13: Line 13:
 
}}
 
}}
  
'''WavPack''' is a royalty-free, open source and [[lossless]] or high-quality lossy audio compression format developed by David Bryant.
+
'''WavPack''' (pronounced "wave-pack") is a [[lossless]] audio [[codec]], also offering optionally a [[hybrid codec| hybrid lossless/lossy]] mode.  It is distributed as a free open-source encoder/decoder with a library and a large number of tools, including a Windows GUI and a range of plugins for both audio players and other software. Third party implementations are available, including ffmpeg.  WavPack supports and/or can be played back on a large number of platforms/OSes including mobile (Android, iOS), portable ([[Rockbox]]) and even web apps.  
  
== Description ==
+
WavPack is arguably the most feature-rich lossless compressor, supporting a unique range of audio signals including [https://en.wikipedia.org/wiki/Direct_Stream_Digital Direct-Stream Digital]. While many special features might require the user to apply the WavPack executable directly (which may be achieved with drag+drop, see the ''Using WavPack'' section below), everyday use is supported by a wide range of players and taggers.
WavPack (pronounced "wave-pack") allows users to compress (and restore) all [[PCM]] audio formats including 8, 16, 24 and 32-bit ints; 32-bit floats; DSD audio; [[mono]], [[stereo]], and [[multichannel]]; [[sampling rate]]s from 6 to 192 kHz. Like other lossless compression schemes the data reduction varies with the source, but it is generally between 30 % and 70 % for typical popular music and somewhat better than that for classical music and other sources with greater dynamic range.
+
  
WavPack also incorporates a unique "hybrid" mode that provides all the advantages of lossless compression with an additional bonus. Instead of creating a single file, this mode creates both a relatively small, high-quality lossy file that can be used all by itself, and a "correction" file that (when combined with the lossy file) provides full lossless restoration. For some users this means never having to choose between lossless and lossy compression!
+
Performance-wise, WavPack defaults to a fast codec &ndash; less CPU intensive than [[ALAC]], but typically not as fast as [[FLAC]] or [[TAK]], especially in decoding CPU usage.<ref>[http://www.audiograaf.nl/losslesstest Martijn van Beurden: <em>Lossless audio codec comparison archive</em>], all comparisons in this wiki article consistent with CDDA results from revision 5, 2022, using WavPack 5.4.0.</ref> In the age of low-power portable Rockbox-equipped players, WavPack could be seen as a reasonable middle ground between FLAC's low CPU footprint and long battery life, and the smaller files but more CPU-intensive [[Monkey's Audio]]<ref>[https://www.rockbox.org/wiki/CodecPerformanceComparison CodecPerformanceComparison] at the Rockbox wiki</ref> &ndash; invoking WavPacks high mode and extra compression that would compress to smaller sizes than FLAC.
  
* Default file extentsion: <code>.wv</code>
+
WavPack has inspired other codecs<ref>Monkey's Audio FAQ {{webarchive|http://web.archive.org/web/20001017210206/http://www.monkeysaudio.com/faq.html|2000-10-17}}</ref> and their features<ref>[http://losslessaudio.org/DualStream.php OptimFROG's "DualStream"] hybrid encoding</ref>.  For more on WavPack, including on its history and technology, see the [https://en.wikipedia.org/wiki/WavPack Wikipedia entry].
* Magic number: <code>wvpk</code> (4 bytes)
+
  
== Feature Summary ==
 
* Fast and efficient encoding and decoding
 
* [[Open source]], released under a BSDish license
 
* Audio files > 4GB
 
* Multiplatform
 
* Hardware support
 
* Error robustness
 
* Streaming support
 
* Supports multichannel audio and high resolutions
 
* DSD compression
 
* Hybrid/lossy mode
 
* Tagging support ([[ID3v1]], [[APE tags]])
 
* Supports [[RIFF]] chunks
 
* Supports embedded CUE sheets
 
* Includes MD5 hashes for quick integrity checking
 
* Ability to create self extracting files for Win32 platform
 
* [[ReplayGain]] compatible
 
  
== History ==
+
= Features =
David Bryant started development on WavPack in mid-1998, with the release of version 1.0. This first version compressed and decompressed audio losslessly, nothing else, but by then it already featured one of the best efficiency versus speed ratio among lossless encoders.
+
For an end-user considering WavPack as a an audio format, its feature-richness might be the big selling point. WavPack supports pretty much all the more common features noted at [[Lossless_comparison| HA Wiki's Lossless Codec Comparison]] as in the following first list, but several users might consider the more unique features listed under the subsequent headline.
  
Very soon after the release of version 1.0, Bryant released v. 2.0, which featured lossy encoding (using only quantization for data reduction – no psychoacoustic process was applied to the stream).
+
* Seekable and streaming playback.
 +
* Error handling:  upon playback, it will detect and report corrupted frames, mute to protect against static/noise output, and continue playback. Since version 5, WavPack can also check for corruption without decoding, hence quicker than any decoding format.  Optional MD5 audio checksum can also be added upon encoding for file fingerprinting.
 +
* High-resolution audio support (see next headline)
 +
* Multichannel support: currently capped at 256 channels, supports [https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatextensible WAVEFORMATEXTENSIBLE] channel masks. 
 +
* Piping support for encoding, and support for RAW PCM input/output.
 +
* RIFF chunks supported for recreating also ''non-audio'' chunks of the original files; by default, WavPack will restore to a file bit-identical to the original.
 +
* Tagging: APEv2. (ID3v1 is possible, but not advisable.)  
 +
* Cuesheet support. In practice, some applications handle ''embedded'' cuesheets better in WavPack than in some other formats.
 +
* Unicode support.
 +
* Can be used in the [[Matroska]] container.
 +
* Windows GUI available.
  
In 1999, the developer released version 3.0, which featured novelties such as a fast mode (with reduced compression ratio), compression of RAW files and error detection using CRC checksums.
+
WavPack also handles bit depths not divisible by 8, and is known to employ a "wasted bits" strategy: For, say, a 20 bit signal in a 24 bit container, WavPack will detect that bits 21 to 24 are "wasted" and compressed as 20-bits without size penalty.
  
WavPack development is still going on, and a major feature added in late 3.x versions is the hybrid mode, where the encoder generates a lossy file + a correction file, so that both can be decompressed back to the original PCM stream.
+
== Special/unique features ==
 +
Most of these features are shared with only a few if any notable codecs, or extend to signal types or file types others do not support (comparisons given).
 +
* DSD support: can losslessly compress Philips DSDIFF and Sony DSF files (see "Using WavPack" below); can import ID3v2.3 tags from DSF. (No other end-user codec compresses DSD.)
 +
* High-resolution support for bit depth 1-bit to 32-bit integer and sampling rates up to 2 GiHz in integer steps. (Officially, 1 GHz is supported &ndash; it is ''gigaherz'', not MHz, the upper limit being in the UHF radio frequency band.  Monkey's Audio, OptimFROG and MPEG-4 ALS support the entire WAVE range up to 4 GiHz.)
 +
* 32-bit ''floating-point'' supported &ndash; also including CoolEdit/Adobe Audition's own float format (use the <tt>-a</tt> option only if the .wav was generated by CoolEdit/Audition).  (This line like OptimFROG.)
 +
* As much as 256 channels currently supported (version 5.5.0; [https://github.com/dbry/WavPack/issues/117 can be extended to the thousands] &ndash; for even more, MPEG-4 ALS supports 66536.)
 +
* Hybrid lossy/lossless mode (can also be used as lossy).  (Like OptimFROG.)
 +
* Can in addition to PCM in WAVE files also read and output to RF64, Sony's Wave64, and CAF (including > 4 GB files and both endianness CAF &ndash; the latter apparently unique among lossless formats).  Also, WavPack will upon decoding recreate any (standards-compliant) file bit by bit including non-audio parts, to whatever input format it supports.  (Monkey's/OptimFROG/TAK do the same to the input formats they support.)
 +
* Recompression: Can recompress .wv files in place, with tag transfer.  (Like FLAC on .flac files.)
 +
* Drag and drop support: Dropping a file on to wavpack.exe/wvunpack.exe will encode/decode it to source directory. (Like FLAC.)  From 5.5.0, one can also apply options to drag and drop by renaming the executable, and drop several files.
  
WavPack 4 has been released in 2004. It included important changes, such as fast seeking, multichannel support, high resolution audio support, etc. turning it into one of the most full featured and modern lossless audio compressors.
+
== Limitations ==
 +
The following limitations are certainly not unique to WavPack. None seem to be able to force WAVE version (though some can force RF64), only FLAC can force decoding to AIFF (big-endian only) and only Monkey's support AIFF with full file structure restore (big-endian only) or the legacy AU/SND format.
 +
* Despite being available for several platforms, PCM in AIFF is currently not supported. (See below for workarounds.)
 +
* Although output can be forced to various filetypes, there seems not to be an easy way to force output to a given version of the WAVE format (apparently no other codec does this either) &ndash; nor to force RF64 if less than 4 GiB output.
 +
* DSD: Will reject DST-compressed DSD (which are already compressed heavier than WavPack does); can currently not import ID3v2.4, only ID3v2.3 (use [[Mp3tag]] to copy tags).  
  
WavPack 5 finally released on 6th December, 2016.  
+
As of version 5.4.0, some features are discontinued.  XP support is officially dropped (though an "unofficial" build is available<ref>[https://hydrogenaud.io/index.php/topic,122710.msg1013765.html#msg1013765 XP-compatible 5.5.0 build posted at the HA forum]</ref> &ndash; otherwise, 5.3.0 released April 2020 supports XP), version 5 does no longer offer compression to Windows .sfx self-extracting file (cf. OptimFROG) nor the <tt>-p</tt> feature.  Furthermore, WavPack version 3.x files are no longer supported. To recompress these files (if any are still around, WavPack 4 was released in 2004) to WavPack 5 files (for the fast decoding-free error checking feature), one must first recompress by WavPack 4.80 (still available) or lower, and then by WavPack 5.  
Now it accepts audio files bigger than 4 GB and can compress the Direct-Stream Digital (DSD) audio recording format.
+
Including handling with many new file formats like Sony Wave64 or Philips DSDIFF makes WavPack to an "universal audio archiving solution".
+
  
== Software support ==
+
As of 5.5.0, MacOS versions must be built with e.g. HomeBrew.
=== Players ===
+
 
* NullSoft [[Winamp]] (plugin with ReplayGain & Media Library support) and Winamp-compatible players
+
WavPack has traditionally had less hardware support than FLAC ([[Rockbox]] having been the most notable platform, others listed at https://www.wavpack.com/index.html#Hardware ), but with WavPack playback through Android and iOS players, the distinction between "hardware" and "software" is arguably blurred. There have been issues getting certain Android solutions to recognize media files including WavPack.<ref>[https://hydrogenaud.io/index.php/topic,122768] HA thread with link to Android bug report by the Monkey's Audio author</ref>
* [[foobar2000]] Advanced Audio Player (official encoding/decoding addon, with ReplayGain & Cuesheets support)
+
Third-party support for hybrid-encoded lossless playback (the correction files, see below) might be limited.
 +
 
 +
 
 +
= Using WavPack =
 +
WavPack files can be played back in supported players (see below), and several of these can encode to WavPack, invoking the official tools.  However, there are situations where certain WavPack features are accessible only through the WavPack executables directly.  For example, you cannot count on RIFF support by encoding through players which often deliver only the audio to the encoder &ndash; and you cannot count on such players to restore non-audio data faithfully when decoding.  Also, the input format might exceed the player's internal decoding; e.g. trying to convert 32-bit integer or DSD with foobar2000 will yield a warning that it will not be lossless (also, converting DSD to PCM leads to files many times the size, being inherently different formats).
 +
 
 +
Unlike most other codecs, WavPack has separate encoding and decoding executables (wavpack and wvunpack).
 +
 
 +
== Drag and drop (Windows) ==  
 +
The simplest encoding/decoding might be ''dragging and dropping'' a (supported) file to wavpack.exe (/wvunpack.exe).  Then the file will be encoded/decoded with the default options.  Dropping a .wv file onto wavpack.exe will recompress it, prompting before overwrite (again, using default settings &ndash; possibly a bad deal if it was encoded with high -x switches).  Drag and drop also works on a shortcut to the executable. It is not possible to drop a folder, but from version 5.5.0, there is a way to drag and drop ''several'' files.
 +
 
 +
From version 5.5.0, drag and drop supports ''options'' by renaming the executable.  The user can rename a copy of the executable according to preferred settings, which will be applied to the process upon drag and drop.  The example given by the developer in [https://hydrogenaud.io/index.php/topic,122626.msg1012159.html#msg1012159 in this HA forum post]<ref>[https://hydrogenaud.io/index.php/topic,122626.msg1012159.html#msg1012159 HA forum post on how to rename executable for drag and drop]</ref> uses encoding options that many WavPack users will recommend (better compression than default, verification and MD5 fingerprinting), and novice users can choose to copy that filename for the executable.  For fine-tuning performance or for more specialized tasks, more options are described below.
 +
 
 +
== Basic command line usage [[Windows_command_line_tips|(for Windows: command-line hints here)]] ==
 +
The basic ''encoding'' usage is <tt>wavpack filename.extension</tt> (which creates <tt>filename.wv</tt>) &ndash; this is what drag and drop accomplishes.  Wildcards are supported, e.g <tt>wavpack *.wav</tt>.  For a single input file, one can specify output like e.g. <tt>wavpack infilename.wav -o outfilename.wv</tt> (on Windows, the <tt>-o</tt> can be omitted).  Input file extension ".wav" can be dropped, and output ".wv" extension as well &ndash; but <tt>wavpack foo</tt> will only find foo.wav, not e.g. foo.w64. 
 +
 
 +
The basic ''decoding'' usage &ndash; as will be accomplished by drag and drop &ndash; is <tt>wvunpack filename.wv</tt>.  By default, wvunpack will restore the exact same file (metadata and file structure and all), with suffix as appropriate: filename.wav / filename.w64 / filename.caf.  (Though WavPack then knows the original input format, it does not store the original file name &ndash; but timestamp can be stored by using <tt>-t</tt>.) If only audio was encoded (from a player, pipe or using <tt>-r</tt>), output defaults to filename.wav.
 +
Just like for the wavpack encoder, file extensions can be dropped; e.g., using <tt>wvunpack foo bar</tt> will decode foo.wv to bar.wav/bar.w64/bar.caf, extension chosen from original format. This can be overridden by assigning an output fileextension &ndash; e.g. bar.w64 will write a Wave64 file regardless of input format.
 +
 
 +
=== Several input files ===
 +
Wildcards are supported, like <tt>wavpack *.wav</tt>.  To give several filenames as input to wavpack/wvunpack, there are slight differences between the Windows version and the *n*xes:
 +
Windows (requires WavPack 5.5.0): use the <tt>--drop</tt> option as in the above example given by the developer.  It is intended for drag and drop (hence the name of the option) and will write the output to same directory as source.  However it can also be used with command-line:  <tt>wavpack --drop firstfile secondfile</tt> will compress firstfile.wav to firstfile.wv and secondfile.wav to secondfile.wv.  Note that without the <tt>--drop</tt>, the command <tt>wavpack firstfile secondfile</tt> will compress firstfile.wav to secondfile.wv, as <tt>-o</tt> is optional on Windows &ndash; indeed that is why the <tt>--drop</tt> had to be introduced.  An arbitrary number of files can be processed, e.g. <tt>wvunpack --drop firstfile secondfile thirdfile fourthfile fifthfile</tt> will decode firstfile.wv, ..., fifthfile.wv.
 +
For *n*x, one can omit the <tt>--drop</tt>, and it also works with older WavPack versions.
 +
 
 +
== Applying options ==
 +
For tuning performance or other settings, one might want to apply command-line options.  Some external applications can apply options without the user having to type &ndash; e.g. encoding with [[foobar2000]], there are two compression sliders, one for the fast-to-extra-high and one for the <tt>-x</tt> settings (see below) &ndash; but in the Windows GUI one will want to type them in.  Options can be concatenated for short, like for example writing <tt>-hh -x2 -m -v -y</tt> as <tt>-hhx2mvy</tt>. 
 +
 
 +
The user should beware that the wavpack encoder and the wvunpack decoder (and wvtag/wvgain) have to "re-use letters" for different purposes, and e.g. <tt>-b</tt>, <tt>-c</tt> do not have related functions upon decoding as upon encoding.  However some do the same in the wvunpack and wavpack (like <tt>-d</tt> for delete input file, <tt>-y</tt> for "yes to all" and <tt>-l</tt> for "run with low priority" (Windows only)) &ndash; and others cover the same purpose in both executables (like <tt>-m</tt> and <tt>-v</tt>)
 +
 
 +
=== Encoding options (lossless) ===
 +
Encoding using <tt>-hxm</tt> seems a sensible trade-off between compression and CPU load.  The manual (online, or included as wavpack_doc.html in the distribution) gives an exhaustive reference, and the following is merely a selection. 
 +
* Compression.  WavPack has four compression modes that affect compression as well as encoding ''and'' decoding time: fast (<tt>-f</tt>), default, high (<tt>-h</tt>) and very high (<tt>-hh</tt>).  The CPU load of <tt>-hh</tt> is measured to around twice that of <tt>-f</tt> (and could in the early 2000s be too heavy for portable players, although it does decode faster than any Monkey's).  On top these modes, the optional extra processing <tt>-x1</tt> to <tt>-x6</tt> settings will apply extra compression effort that does not increase ''decoding'' CPU load. <tt>-x</tt> without number is synonymous to <tt>-x1</tt>, which is often recommended (in all modes, fast/normal/high/extra high).  The official manual calls <tt>-x4</tt> to <tt>-x6</tt> "extremely slow", but the size gains might be significant for high resolution audio in particular (van Beurden's revision 5, testing <tt>-x4</tt>). 
 +
With DSD files, there are only two compression settings, normal and high; the option <tt>-f</tt> will select normal, <tt>-h</tt>/<tt>-hh</tt> will both select high, and the <tt>-x</tt> switches are silently ignored.
 +
5.5.0 introduces optional switches for the default compression: <tt>-g</tt> for normal mode and <tt>-x0</tt> for "no <tt>-x</tt>".  These are redundant for basic use, but can be used to switch off options already given (e.g. in renamed executables, or custom builds): <tt>-x6 -x0</tt> will switch off the extra processing, and <tt>-h -f -g</tt> will encode as normal, whereas previous versions would abort with an error.
 +
* Guarding against errors upon encoding: The "<tt>-m</tt>" switch will compute an audio MD5 sum (like FLAC does by default) and store it for later verification.  The "<tt>-v</tt>" switch will verify by decoding the file after encoding and writing the file to disk<ref>[https://hydrogenaud.io/index.php?topic=121714.msg1008108#msg1008108 HA forum comment:] verification checks the written file after closing and reopening</ref>. <tt>-vm</tt> will do both &ndash; that is, calculate the MD5s to verify, and store it.  (Using the corresponding switches in wvunpack will check without producing output file, however wvunpack also has a faster corruption check switch <tt>-vv</tt> for WavPack 5-encoded files.)
 +
* <tt>--import-id3</tt> will import ID3v2.3 tags (currently not v2.4 nor v2.2) present in the source file &ndash; typically in Sony DSF files &ndash; and convert them to WavPack's preferred APE tags.  (It will still keep the chunk for restoring the original file.)  By default, importing is limited to 1 MB; for more, use <tt>--allow-huge-tags</tt>.  Same option works in wvtag.
 +
* <tt>-r</tt>: remove extra (non-audio) chunks.  By default, WavPack will store these in the .wv file for later bit-by-bit restoration of everything, not only the audio. Use <tt>-r</tt> to throw them away and encode audio only &ndash; like encoding through most players appear to do.
 +
* <tt>-t</tt>: copy input file's time stamp.  (To restore the file with the original time stamp, use <tt>-t</tt> both when encoding and when decoding.)
 +
* <tt>--pause</tt>: (Windows only!) waits for keypress at the end.  Useful for reading output before exit when calling wavpack/wvunpack in a separate window (which both drag-and-drop the Windows front-end do).
 +
* <tt>-y</tt>: "yes" to everything.  Use with caution, will overwrite.  From 5.5.0 there is also a <tt>--no-overwrite</tt> that will skip instead of asking to overwrite.
 +
* <tt>-d</tt>: delete source file upon successful completion.  Again, use with caution.
 +
* <tt>-l</tt> will force WavPack to run at low priority (Windows only)
 +
* <tt>-c</tt> with <tt>-b</tt> to select lossy quality: hybrid lossless/lossy use, see below.
 +
 
 +
WavPack can recompress .wv files in place (using a temporary file until done).  For example, <tt>wavpack -hx4mvy wavpackfile.wv</tt> will recompress wavpackfile.wv the file in high mode using <tt>-x4</tt> extra processing, write audio MD5 to it, open the temp file and re-read for verification &ndash; and once verified, replace the old wavpackfile.wv. Tags will be transferred.  <tt>wavpack -hx4rlmvy wavpackfile.wv</tt> will also run with low priority (assuming the Windows platform), and will discard non-audio chunks &ndash; that is, the ones used to restore the original file's metadata; the .wv file's APE tags will still be copied.  As an example, one can compress an ID3v2.4-tagged DSF file by drag and drop; WavPack will then store the tag chunk, but WavPack cannot import v2.4.  Then open both in Mp3tag, copy the ID3v2.4 tags to the WavPack file, decide that there is no need to restore the original file's ID3v2.4 upon any unpacking, and apply the <tt>wavpack -hx4rlmvy wavpackfile.wv</tt> command; it will then discard that chunk (but keep the tags that Mp3tag wrote!), recompress using high (silently ignoring the -x4 that has no effect on DSD) with low priority, write an MD5 sum, verify the process and replace the .wv file by the new recompressed file.
 +
 
 +
=== (Incomplete:) hybrid lossless & lossy encoding ===
 +
(Needs to be expanded. Notes: DSD can currently not be hybrid-encoded and floating-point files should not be.  The correction file will be omitted by a lot of applications/players, including ffmpeg; thus, using ffmpeg or ffmpeg-based players to convert/play hybrid-encoded WavPack will be lossy.)
 +
 
 +
Basic use: the <tt>-b</tt> switch &ndash; and for losslessness, with <tt>-c</tt> to create a correction file. The <tt>b</tt> takes a numerical value signifying ''bits per sample'' if < 24 and ''kbit/second'' if 24 to 9600. E.g. <tt>-b12.5</tt> (no space in between, with . even if your locale uses comma for decimal point).
 +
<tt>wavpack -b234.56 -c filename</tt> will create filename.wv file and correction file filename.wvc.  As long as both are present, playback and decoding (by <tt>wvunpack filename</tt> the ordinary way) will be lossless.
 +
The file filename.wv &ndash; which is at most 234.56 kbit/s &ndash; can be copied to a different location and played back stand-alone as a lossy compressed file.  The same will happen if the .wvc file is deleted or not found (it has to be same path/filename except with the ".wvc" suffix in place of ".wv") &ndash; or equivalently, if the <tt>-c</tt> is omitted during encoding, then no correction file will be created in the first place.  For example:
 +
<tt>wavpack -b13.5 -hx filename</tt> will create a ''lossy'' filename.wv compressed with the <tt>-hx</tt> option, size constrained to 13.5 bits per sample. (Should 13.5 bits be sufficient for lossless encoding, WavPack will tell you at the end of the encoding process &ndash; but that information is not stored in the file.)
 +
 
 +
WavPack will refuse to recompress lossy-generated .wv to "lossless .wv" as that would make a false pretense of being a lossless file.  It will also refuse so even in the presence of .wvc; you will have to wvunpack it and and then wavpack it again.
 +
 
 +
 
 +
=== (Incomplete:) decoding options ===
 +
In addition to the basic usage above (drag and drop or <tt>wvunpack filename.wv</tt> or <tt>wvunpack infilename.wv -o outfilename_possibly_with_desired_suffix_to_override_input_filetype.caf</tt>), the wvunpack executable offers several options.  For use with the Windows front-end or drag and drop, the Windows-only <tt>--pause</tt> (waits for keypress at the end, like for wavpack.exe) is essential to read the output report.  Also Windows-only options like <tt>--drop</tt> and <tt>-l</tt> work as for wavpack.exe, and so do <tt>-d</tt> (use with caution!) and <tt>-y</tt> (ditto!).
 +
 
 +
Many of the options are arguably for power users, like for example:
 +
* <tt>-b</tt>: "blindly" decode until end (potentially useful if a .wv file is corrupted)
 +
* <tt>-t</tt>: copy input file's time stamp to output file(s)
 +
* switches to force output file format: <tt>--wav</tt>, <tt>--w64</tt>, <tt>--caf-be</tt>, <tt>--caf-le</tt>, <tt>--raw</tt>
 +
* some switches to perform ''lossy'' operations on floating-point files, DSD streams or dropping hybrid-encoded correction files.  See the documentation.
 +
* <tt>--skip</tt> and/or <tt>--until</tt>: only decode a portion of the file (again, see documentation)
 +
 
 +
wvunpack is also the utility to display information from .wv files even when it does not involve decoding, see the next section.
 +
 
 +
== Other file handling ==
 +
{stub-subsections, incomplete}
 +
 
 +
=== Error checking and other file info ===
 +
wvunpack can get information about WavPack files without decoding to file:
 +
* <tt>-vv</tt>: Quick verify without decoding (WavPack 5 files only).  This functionality seems to be unavailable outside the official wvunpack (other applications which verify will fall back to the next item, -v):
 +
* <tt>-v</tt>: Verify (will decode to check that everything is OK &ndash; but not write any file).
 +
* <tt>-s</tt>/<tt>-ss</tt>: <tt>-s</tt> displays summary of the file, <tt>-ss</tt> a long summary including tags
 +
* <tt>-x</tt> FIELD: Shows tag, e.g. <tt> -x comment </tt> shows the <comment> field.  Also <tt> wvtag -x </tt> does the same thing.
 +
* <tt>-c</tt>: Like <tt> -x cuesheet</tt>.  Also <tt> wvtag -c </tt> does the same thing.
 +
 
 +
=== (To fill in:) Tagging (wvtag) and replaygain management (wvgain) ===
 +
(... most of these options are available in HA's fave taggers/player?)
 +
 
 +
== Using 3rd party tools; FFmpeg's WavPack encoder/decoder, and others ==
 +
FFmpeg can encode/decode to/from WavPack, with some limitations.  FFmpeg can decode WavPack 5 files, but will only write WavPack 4 (thus, no ''fast verification'').  Also, compression presets are different, defaulting to fast but not particularly good compression.<ref>[https://hydrogenaud.io/index.php?topic=118278.msg976262#msg976262  HA forum comment comparing the compression presets]</ref> On the other end, FFmpeg offers even slower modes than <tt>-hhx6</tt>.
 +
 
 +
There is potential information loss in using FFmpeg; it will ignore hybrid correction files, so decoding/playing hybrid-encoded WavPack with ffmpeg or ffmpeg-based players will be lossy.  Furthermore, ffmpeg will default to 16 bits when outputting WAVE/AIFF, whether or not the input file is 16 bits; to unpack a 24-bit .wv to WAVE/AIFF, 24-bit output must be specified.  (For AIFF by way of CAF, see below.)
 +
Also, RIFF metadata will be lost (or AIFF metadata &ndash; which WavPack cannot store in any case).
 +
 
 +
=== From/to AIFF &ndash; preserving bit depth ===
 +
Reference WavPack will encode a 20-bit (or 17, for that matter) .wav file and keep the information that it is 20 (/17) bits.  FFmpeg on the other hand, will delete the information that it was ever 20 (/17) bits. Also, FFmpeg will by default produce 16-bits WAVE/AIFF files, and additional specification must be applied to ensure lossless decoding of 24-bit files; safest is to use wvunpack to decode, but reference WavPack cannot handle .aiff. It does handle .caf, so the following procedure and preserve bit depth, divisible by 8 or not:
 +
* To decode .wv to AIFF and preserve bit depth: <tt>wvunpack "infile.wv" --caf-be - | ffmpeg -i - -codec copy "outfile.aiff"</tt>.
 +
* To encode AIFF, possibly with bit depths like 17 preserved: There are AIFF to WAVE conversion software that will preserve bit depth flags (here ffmpeg doesn't), but presuming a a lossless audio user has flac.exe around:  <tt> flac --fast --lax "aiff infile.aiff" -o - | flac -d - -o - | wavpack - "wavpack outfile.wv" </tt> will do a flac encode/decode provided bit depth is 4 to 24.
 +
 
 +
(One limitation of ffmpeg is that RIFF chunks will be discarded &ndash; but for AIFF that is not an issue anyway, as WavPack cannot store AIFF metadata.)
 +
 
 +
=== Splitting WavPack files by cuesheet ===
 +
wvunpack cannot split WavPack files by neither embedded nor external cuesheet, but some external applications can (and will have to decode/re-encode):  [[CUETools]] can if it is CDDA (44.1 kHz 16-bit stereo), and can re-encode back to WavPack.  refalac can decode & split by cuesheets with the appropriate WavPack library DLL file<ref>[https://github.com/nu774/qaac/wiki/refalac-usage refalac usage] includes how to split by cuesheet</ref>, outputting WAVE or ALAC-in-MP4.
 +
 
 +
 
 +
= Software support =
 +
With Android support and playback through ffmpeg, it might no longer be feasible to maintain a list of applications that can play WavPack files, and  the following is  most certainly incomplete &ndash; as is the list at https://www.wavpack.com/#Software . 
 +
 
 +
== Players ==
 +
* [[foobar2000]] advanced freeware audio player plays/decodes WavPack out of the box on both Windows, MacOS, Android and iOS (Windows: supports encoding if wavpack.exe is installed, and redistributes the official wavpack.exe through its "Free encoder pack" addon for encoding.  With ReplayGain & cuesheets support.) Also [[Boom]] from the same author.
 +
* [http://www.videolan.org/vlc/download-windows.html VLC] multiplatform media player
 
* [http://www.vuplayer.com/vuplayer.php VUPlayer] (official plugin, supports encoding)
 
* [http://www.vuplayer.com/vuplayer.php VUPlayer] (official plugin, supports encoding)
 +
* NullSoft [[Winamp]] (plugin with ReplayGain & Media Library support) and Winamp-compatible players
 
* [[Windows Media Player]] and other directshow-based players (MPC, TCMP, RadLight) (with [http://www.hydrogenaudio.org/forums/index.php?showtopic=103693 CoreWavPack] directshow filter)
 
* [[Windows Media Player]] and other directshow-based players (MPC, TCMP, RadLight) (with [http://www.hydrogenaudio.org/forums/index.php?showtopic=103693 CoreWavPack] directshow filter)
 
* [http://cogosx.sourceforge.net/ Cog] Audio player for MacOS X.
 
* [http://cogosx.sourceforge.net/ Cog] Audio player for MacOS X.
 +
* [https://wiki.jriver.com/index.php/WavPack JRiver Media Center]
 
* [[XMMS]] (with Kuniklo's plugin)
 
* [[XMMS]] (with Kuniklo's plugin)
 
* [http://fondriest.frederic.free.fr/realisations/lamip/ LAMIP] (official plugin)
 
* [http://fondriest.frederic.free.fr/realisations/lamip/ LAMIP] (official plugin)
 
* [http://mpxplay.sourceforge.net/ MPXplay] for DOS!
 
* [http://mpxplay.sourceforge.net/ MPXplay] for DOS!
 
* [http://aqualung.sourceforge.net/ Aqualung] for GNU/Linux
 
* [http://aqualung.sourceforge.net/ Aqualung] for GNU/Linux
* [http://www.videolan.org/vlc/download-windows.html VLC Player]
+
* Cowon [http://www.jetaudio.com/ JetAudio Player] and CD ripper
* Cowon [http://www.jetaudio.com/ JetAudio Player]
+
* [http://www.un4seen.com/ XMPlay] Plugin required (WavPack input plugin) and (bass library) to play 'wv' files
* Konvertor [http://www.logipole.com/index.html Konvertor]
+
*[http://www.un4seen.com/ XMPlay] Plugin required (WavPack input plugin) and (bass library) to play 'wv' files
+
  
=== Frontends ===
+
== Converters, CD rippers etc. ==
 +
Several of the ''players'', like Cowon JetAudio, foobar2000 and VUplayer, also have converters that can create WavPack files. More:
 
* Custom Windows [http://www.wavpack.com/WavPack_frontend.zip WavPack frontend] (by Speekenbrink)
 
* Custom Windows [http://www.wavpack.com/WavPack_frontend.zip WavPack frontend] (by Speekenbrink)
 
+
* [http://www.dbpoweramp.com/ dBpowerAMP] Music Converter CD ripper/writer / Audio Player / (official addon)
=== Converters ===
+
* [[fre:ac]] multi-platform CD ripper/converter
'''Note:''' ''Several players, like Cowon JetAudio, foobar2000 and VUplayer, can also convert from other formats to WavPack!''
+
* [[Exact Audio Copy]] CD Ripper (guide at this wiki<ref>[[EAC_and_WavPack | HA Wiki: Configuring EAC and WavPack]]</ref>)
 
+
* [http://www.dbpoweramp.com/ dBpowerAMP] Music Converter / Audio Player / CD Writer (official addon)
+
* [http://www.easeaudioconverter.com/wavpack.htm Ease Audio Converter] (Shareware / NOT Freeware)
+
* [http://media.io/ Online Audio Converter]
+
* Konvertor [http://www.logipole.com/index.html Konvertor]
+
 
+
=== Editors ===
+
* [[Adobe Audition]] and Cool Edit (filter with 32-bit floats & extra info save support)
+
 
+
=== CD writers/rippers ===
+
 
* [http://www.nero.com/eng/ Nero]
 
* [http://www.nero.com/eng/ Nero]
* [[Exact Audio Copy]] CD Ripper
 
 
* [http://cdexos.sourceforge.net CDex] CD ripper
 
* [http://cdexos.sourceforge.net CDex] CD ripper
* Cowon [http://www.jetaudio.com/ JetAudio Player]
+
* [http://www.easeaudioconverter.com/wavpack.htm Ease Audio Converter] (Shareware / NOT Freeware)
 +
* [http://media.io/ Media.io Online Audio Converter]
 +
* [http://www.logipole.com/index.html Konvertor]
 +
* [http://cuetools.net CUETools] converter and AccurateRip/CTDB checker
 +
* [https://github.com/nu774/qaac refalac]
  
=== Taggers ===
+
== Taggers ==
 
* [http://www.mp3tag.de/en/index.html Mp3tag] Universal Tag Editor
 
* [http://www.mp3tag.de/en/index.html Mp3tag] Universal Tag Editor
 +
* [https://picard.musicbrainz.org/ MusicBrainz Picard] Tagger with audio identification
 
* [http://www.jtclipper.eu/thegodfather/ The GodFather] Tagger / Music manager
 
* [http://www.jtclipper.eu/thegodfather/ The GodFather] Tagger / Music manager
 
* [[Tag.exe|Case's Tag]] command line tagger
 
* [[Tag.exe|Case's Tag]] command line tagger
  
=== Other tools ===
+
== Other tools ==
 +
* [[Adobe Audition]] and Cool Edit (filter with 32-bit floats & extra info save support)
 
* [http://mr-questionman.en.uptodown.com/windows Mr. QuestionMan]
 
* [http://mr-questionman.en.uptodown.com/windows Mr. QuestionMan]
 
* [http://www.bunkus.org/videotools/mkvtoolnix/ mkvtoolnix] – tool to multiplex WavPack streams inside the Matroska container
 
* [http://www.bunkus.org/videotools/mkvtoolnix/ mkvtoolnix] – tool to multiplex WavPack streams inside the Matroska container
 
''It's worth mentioning the [[Matroska]] guys decided to concentrate on WavPack as the lossless compressor of choice for their container. Quite an honor... :-)''
 
''It's worth mentioning the [[Matroska]] guys decided to concentrate on WavPack as the lossless compressor of choice for their container. Quite an honor... :-)''
 +
* [https://support.pkware.com/display/PKSZLU/PKZIP+Toolkit+for+Windows PKWare]'s .zip format compresses audio by WavPack since version 6.3.2 (2007).  Beware that there is no expectation that other decompression software handles these zip files; even if PKWare co-designed the format and PKZip was the original .zip implementation, their subsequent compression methods are outside the ISO/IEC standardized zip format specification.
  
->[http://www.wavpack.com/#Software WavPack Software Section]
 
 
== Hardware Support ==
 
* iRiver iHP-120/iHP-140 with the open source [http://www.rockbox.org Rockbox firmware]
 
* Roku PhotoBridge HD (with [http://www.wavpack.com/downloads.html#binaries plugin])
 
->[http://www.wavpack.com/index.html#Hardware WavPack Hardware Section]
 
 
== Technology description ==
 
To ensure high-speed operation, WavPack uses a very simple predictor that is implemented entirely in integer math. In its "fast" mode the prediction is simply the arithmetic extrapolation of the previous two samples. For example, if the previous two samples were -10 and 20, then the prediction would be 50. For the default mode a simple adaptive factor is added to weigh the influence of the earlier sample on the prediction. In our example the resulting prediction could then vary between 20 for no influence to 50 for full influence. This weight factor is constantly updated based on the audio data's changing spectral characteristics, which is why it is called "adaptive".
 
 
The prediction generated is then subtracted from the actual sample to be encoded to generate the error value. In mono mode this value is sent directly to the coder. However, stereo signals tend to have some correlation between the two channels that can be further exploited. Therefore, two error values are calculated that represent the difference and average of the left and right error values. In the "fast" mode of operation these two new values are simply sent to the coder instead of the left and right values. In the default mode, the difference value is always sent to the coder along with one of the other three values (average, left, or right). An adaptive algorithm continuously determines the most efficient of the three to send based on the changing balance of the channels.
 
 
The developer has developed a unique data encoder for WavPack that he believes is better than Rice coding in two different areas. It is impossible to encode more efficiently than Rice coding because it represents the optimal bit coding (sometimes known as the Huffman code) for this type of data. WavPack's encoder is slightly less efficient than this, but only by about 0.15 bits/sample (or less than 1% for 16-bit data). The first advantage of WavPack's coder is that it does not require the data to be buffered ahead of encoding, instead it converts each sample directly to bitcodes. This is more computationally efficient and it is better in some applications where coding delay is critical. The second advantage is that it is easily adaptable to lossy encoding because all significant bits (except the implied "one" MSB) are transmitted directly. In this way it is possible to only transmit, for example, the 3 most significant bits (with sign) of each sample. In fact, it is possible to transmit only the sign and implied MSB for each sample with an average of only 3.65 bits/sample.
 
 
This coding scheme is used to implement the "lossy" mode of WavPack. In the "fast" mode the output of the non-adaptive decorrelator is simply rounded to the nearest codable value for the specified number of bits. In the default mode the adaptive decorrelator is used (which reduces the average noise about 1 dB) and also both the current and the next sample are considered in choosing the better of the two available codes (which reduces noise another 1 dB).
 
 
The developer has decided to not use any floating-point arithmetic in WavPack's data path because he believes that integer operations are less susceptible to subtle chip to chip variations that could corrupt the lossless nature of the compression, the Pentium floating point bug being a blatant example of this. It is possible that a lossless compressor that used floating-point math could generate different output when running on that faulty Pentium. Even disregarding actual bugs, floating-point math is complicated enough that there could be subtle differences between "correct" implementations that could cause trouble for this type of application. To further ensure confidence in the integrity of WavPack's compression, the encoder includes a 32-bit error detection code to the generated streams.
 
 
WavPack source code is very portable. It has been compiled on several Unices (Linux, Mac OS X, Solaris, FreeBSD, OpenBSD, NetBSD, Compaq Tru64, HP-UX...) as well as Windows, DOS and OpenVMS. It works on architectures such as x86, ARM, PowerPC, SPARC, DEC Alpha, PA-RISC, MIPS, Motorola 68k...
 
  
== External links ==
+
= Links =
 
* [http://www.wavpack.com/ Official website]
 
* [http://www.wavpack.com/ Official website]
* [http://www.rarewares.org/lossless.html Unofficial multiplatform versions] at RareWares
+
* [https://github.com/dbry/WavPack Github repository]
* [[Lossless_comparison|Lossless Codec Comparison]]
+
* [http://www.rarewares.org/lossless.html Unofficial 4.32 multiplatform versions] at RareWares
* [[EAC_and_WavPack | Configuring EAC and WavPack]]
+
* [https://en.wikipedia.org/wiki/WavPack WavPack at Wikipedia]
 +
* [https://wiki.multimedia.cx/index.php/WavPack WavPack at Multimediawiki] (not updated with version 5)
 +
* [[Lossless_comparison| HA Wiki's Lossless Codec Comparison]] originally by [[User:Rjamorim|Rjamorim]]  
 +
* An older (2005) performance comparison of lossless audio compressors {{webarchive|https://web.archive.org/web/20151027213336/http://members.home.nl/w.speek/comparison.htm|2015-10-27}} by Speek, using WavPack version 4.0
 +
<references/>
  
 +
{{navbox audio codecs}}
 
[[Category:Codecs]]
 
[[Category:Codecs]]
 
[[Category:Lossless]]
 
[[Category:Lossless]]

Revision as of 20:35, 15 August 2022

WavPack
Official WavPack logo

Hybrid Lossless Audio Compression
Developer(s) David Bryant
Release information
Initial release {{{released}}}
Stable release 5.5.0 (2022-07-07)
Preview release None
Compatibility
Operating system Windows, MacOSX, Linux/BSD/Unix, ...
Additional information
Use Encoder/Decoder
License BSD license
Website http://www.wavpack.com/

WavPack (pronounced "wave-pack") is a lossless audio codec, also offering optionally a hybrid lossless/lossy mode. It is distributed as a free open-source encoder/decoder with a library and a large number of tools, including a Windows GUI and a range of plugins for both audio players and other software. Third party implementations are available, including ffmpeg. WavPack supports and/or can be played back on a large number of platforms/OSes including mobile (Android, iOS), portable (Rockbox) and even web apps.

WavPack is arguably the most feature-rich lossless compressor, supporting a unique range of audio signals including Direct-Stream Digital. While many special features might require the user to apply the WavPack executable directly (which may be achieved with drag+drop, see the Using WavPack section below), everyday use is supported by a wide range of players and taggers.

Performance-wise, WavPack defaults to a fast codec – less CPU intensive than ALAC, but typically not as fast as FLAC or TAK, especially in decoding CPU usage.[1] In the age of low-power portable Rockbox-equipped players, WavPack could be seen as a reasonable middle ground between FLAC's low CPU footprint and long battery life, and the smaller files but more CPU-intensive Monkey's Audio[2] – invoking WavPacks high mode and extra compression that would compress to smaller sizes than FLAC.

WavPack has inspired other codecs[3] and their features[4]. For more on WavPack, including on its history and technology, see the Wikipedia entry.


Features

For an end-user considering WavPack as a an audio format, its feature-richness might be the big selling point. WavPack supports pretty much all the more common features noted at HA Wiki's Lossless Codec Comparison as in the following first list, but several users might consider the more unique features listed under the subsequent headline.

  • Seekable and streaming playback.
  • Error handling: upon playback, it will detect and report corrupted frames, mute to protect against static/noise output, and continue playback. Since version 5, WavPack can also check for corruption without decoding, hence quicker than any decoding format. Optional MD5 audio checksum can also be added upon encoding for file fingerprinting.
  • High-resolution audio support (see next headline)
  • Multichannel support: currently capped at 256 channels, supports WAVEFORMATEXTENSIBLE channel masks.
  • Piping support for encoding, and support for RAW PCM input/output.
  • RIFF chunks supported for recreating also non-audio chunks of the original files; by default, WavPack will restore to a file bit-identical to the original.
  • Tagging: APEv2. (ID3v1 is possible, but not advisable.)
  • Cuesheet support. In practice, some applications handle embedded cuesheets better in WavPack than in some other formats.
  • Unicode support.
  • Can be used in the Matroska container.
  • Windows GUI available.

WavPack also handles bit depths not divisible by 8, and is known to employ a "wasted bits" strategy: For, say, a 20 bit signal in a 24 bit container, WavPack will detect that bits 21 to 24 are "wasted" and compressed as 20-bits without size penalty.

Special/unique features

Most of these features are shared with only a few if any notable codecs, or extend to signal types or file types others do not support (comparisons given).

  • DSD support: can losslessly compress Philips DSDIFF and Sony DSF files (see "Using WavPack" below); can import ID3v2.3 tags from DSF. (No other end-user codec compresses DSD.)
  • High-resolution support for bit depth 1-bit to 32-bit integer and sampling rates up to 2 GiHz in integer steps. (Officially, 1 GHz is supported – it is gigaherz, not MHz, the upper limit being in the UHF radio frequency band. Monkey's Audio, OptimFROG and MPEG-4 ALS support the entire WAVE range up to 4 GiHz.)
  • 32-bit floating-point supported – also including CoolEdit/Adobe Audition's own float format (use the -a option only if the .wav was generated by CoolEdit/Audition). (This line like OptimFROG.)
  • As much as 256 channels currently supported (version 5.5.0; can be extended to the thousands – for even more, MPEG-4 ALS supports 66536.)
  • Hybrid lossy/lossless mode (can also be used as lossy). (Like OptimFROG.)
  • Can in addition to PCM in WAVE files also read and output to RF64, Sony's Wave64, and CAF (including > 4 GB files and both endianness CAF – the latter apparently unique among lossless formats). Also, WavPack will upon decoding recreate any (standards-compliant) file bit by bit including non-audio parts, to whatever input format it supports. (Monkey's/OptimFROG/TAK do the same to the input formats they support.)
  • Recompression: Can recompress .wv files in place, with tag transfer. (Like FLAC on .flac files.)
  • Drag and drop support: Dropping a file on to wavpack.exe/wvunpack.exe will encode/decode it to source directory. (Like FLAC.) From 5.5.0, one can also apply options to drag and drop by renaming the executable, and drop several files.

Limitations

The following limitations are certainly not unique to WavPack. None seem to be able to force WAVE version (though some can force RF64), only FLAC can force decoding to AIFF (big-endian only) and only Monkey's support AIFF with full file structure restore (big-endian only) or the legacy AU/SND format.

  • Despite being available for several platforms, PCM in AIFF is currently not supported. (See below for workarounds.)
  • Although output can be forced to various filetypes, there seems not to be an easy way to force output to a given version of the WAVE format (apparently no other codec does this either) – nor to force RF64 if less than 4 GiB output.
  • DSD: Will reject DST-compressed DSD (which are already compressed heavier than WavPack does); can currently not import ID3v2.4, only ID3v2.3 (use Mp3tag to copy tags).

As of version 5.4.0, some features are discontinued. XP support is officially dropped (though an "unofficial" build is available[5] – otherwise, 5.3.0 released April 2020 supports XP), version 5 does no longer offer compression to Windows .sfx self-extracting file (cf. OptimFROG) nor the -p feature. Furthermore, WavPack version 3.x files are no longer supported. To recompress these files (if any are still around, WavPack 4 was released in 2004) to WavPack 5 files (for the fast decoding-free error checking feature), one must first recompress by WavPack 4.80 (still available) or lower, and then by WavPack 5.

As of 5.5.0, MacOS versions must be built with e.g. HomeBrew.

WavPack has traditionally had less hardware support than FLAC (Rockbox having been the most notable platform, others listed at https://www.wavpack.com/index.html#Hardware ), but with WavPack playback through Android and iOS players, the distinction between "hardware" and "software" is arguably blurred. There have been issues getting certain Android solutions to recognize media files including WavPack.[6] Third-party support for hybrid-encoded lossless playback (the correction files, see below) might be limited.


Using WavPack

WavPack files can be played back in supported players (see below), and several of these can encode to WavPack, invoking the official tools. However, there are situations where certain WavPack features are accessible only through the WavPack executables directly. For example, you cannot count on RIFF support by encoding through players which often deliver only the audio to the encoder – and you cannot count on such players to restore non-audio data faithfully when decoding. Also, the input format might exceed the player's internal decoding; e.g. trying to convert 32-bit integer or DSD with foobar2000 will yield a warning that it will not be lossless (also, converting DSD to PCM leads to files many times the size, being inherently different formats).

Unlike most other codecs, WavPack has separate encoding and decoding executables (wavpack and wvunpack).

Drag and drop (Windows)

The simplest encoding/decoding might be dragging and dropping a (supported) file to wavpack.exe (/wvunpack.exe). Then the file will be encoded/decoded with the default options. Dropping a .wv file onto wavpack.exe will recompress it, prompting before overwrite (again, using default settings – possibly a bad deal if it was encoded with high -x switches). Drag and drop also works on a shortcut to the executable. It is not possible to drop a folder, but from version 5.5.0, there is a way to drag and drop several files.

From version 5.5.0, drag and drop supports options by renaming the executable. The user can rename a copy of the executable according to preferred settings, which will be applied to the process upon drag and drop. The example given by the developer in in this HA forum post[7] uses encoding options that many WavPack users will recommend (better compression than default, verification and MD5 fingerprinting), and novice users can choose to copy that filename for the executable. For fine-tuning performance or for more specialized tasks, more options are described below.

Basic command line usage (for Windows: command-line hints here)

The basic encoding usage is wavpack filename.extension (which creates filename.wv) – this is what drag and drop accomplishes. Wildcards are supported, e.g wavpack *.wav. For a single input file, one can specify output like e.g. wavpack infilename.wav -o outfilename.wv (on Windows, the -o can be omitted). Input file extension ".wav" can be dropped, and output ".wv" extension as well – but wavpack foo will only find foo.wav, not e.g. foo.w64.

The basic decoding usage – as will be accomplished by drag and drop – is wvunpack filename.wv. By default, wvunpack will restore the exact same file (metadata and file structure and all), with suffix as appropriate: filename.wav / filename.w64 / filename.caf. (Though WavPack then knows the original input format, it does not store the original file name – but timestamp can be stored by using -t.) If only audio was encoded (from a player, pipe or using -r), output defaults to filename.wav. Just like for the wavpack encoder, file extensions can be dropped; e.g., using wvunpack foo bar will decode foo.wv to bar.wav/bar.w64/bar.caf, extension chosen from original format. This can be overridden by assigning an output fileextension – e.g. bar.w64 will write a Wave64 file regardless of input format.

Several input files

Wildcards are supported, like wavpack *.wav. To give several filenames as input to wavpack/wvunpack, there are slight differences between the Windows version and the *n*xes: Windows (requires WavPack 5.5.0): use the --drop option as in the above example given by the developer. It is intended for drag and drop (hence the name of the option) and will write the output to same directory as source. However it can also be used with command-line: wavpack --drop firstfile secondfile will compress firstfile.wav to firstfile.wv and secondfile.wav to secondfile.wv. Note that without the --drop, the command wavpack firstfile secondfile will compress firstfile.wav to secondfile.wv, as -o is optional on Windows – indeed that is why the --drop had to be introduced. An arbitrary number of files can be processed, e.g. wvunpack --drop firstfile secondfile thirdfile fourthfile fifthfile will decode firstfile.wv, ..., fifthfile.wv. For *n*x, one can omit the --drop, and it also works with older WavPack versions.

Applying options

For tuning performance or other settings, one might want to apply command-line options. Some external applications can apply options without the user having to type – e.g. encoding with foobar2000, there are two compression sliders, one for the fast-to-extra-high and one for the -x settings (see below) – but in the Windows GUI one will want to type them in. Options can be concatenated for short, like for example writing -hh -x2 -m -v -y as -hhx2mvy.

The user should beware that the wavpack encoder and the wvunpack decoder (and wvtag/wvgain) have to "re-use letters" for different purposes, and e.g. -b, -c do not have related functions upon decoding as upon encoding. However some do the same in the wvunpack and wavpack (like -d for delete input file, -y for "yes to all" and -l for "run with low priority" (Windows only)) – and others cover the same purpose in both executables (like -m and -v).

Encoding options (lossless)

Encoding using -hxm seems a sensible trade-off between compression and CPU load. The manual (online, or included as wavpack_doc.html in the distribution) gives an exhaustive reference, and the following is merely a selection.

  • Compression. WavPack has four compression modes that affect compression as well as encoding and decoding time: fast (-f), default, high (-h) and very high (-hh). The CPU load of -hh is measured to around twice that of -f (and could in the early 2000s be too heavy for portable players, although it does decode faster than any Monkey's). On top these modes, the optional extra processing -x1 to -x6 settings will apply extra compression effort that does not increase decoding CPU load. -x without number is synonymous to -x1, which is often recommended (in all modes, fast/normal/high/extra high). The official manual calls -x4 to -x6 "extremely slow", but the size gains might be significant for high resolution audio in particular (van Beurden's revision 5, testing -x4).

With DSD files, there are only two compression settings, normal and high; the option -f will select normal, -h/-hh will both select high, and the -x switches are silently ignored. 5.5.0 introduces optional switches for the default compression: -g for normal mode and -x0 for "no -x". These are redundant for basic use, but can be used to switch off options already given (e.g. in renamed executables, or custom builds): -x6 -x0 will switch off the extra processing, and -h -f -g will encode as normal, whereas previous versions would abort with an error.

  • Guarding against errors upon encoding: The "-m" switch will compute an audio MD5 sum (like FLAC does by default) and store it for later verification. The "-v" switch will verify by decoding the file after encoding and writing the file to disk[8]. -vm will do both – that is, calculate the MD5s to verify, and store it. (Using the corresponding switches in wvunpack will check without producing output file, however wvunpack also has a faster corruption check switch -vv for WavPack 5-encoded files.)
  • --import-id3 will import ID3v2.3 tags (currently not v2.4 nor v2.2) present in the source file – typically in Sony DSF files – and convert them to WavPack's preferred APE tags. (It will still keep the chunk for restoring the original file.) By default, importing is limited to 1 MB; for more, use --allow-huge-tags. Same option works in wvtag.
  • -r: remove extra (non-audio) chunks. By default, WavPack will store these in the .wv file for later bit-by-bit restoration of everything, not only the audio. Use -r to throw them away and encode audio only – like encoding through most players appear to do.
  • -t: copy input file's time stamp. (To restore the file with the original time stamp, use -t both when encoding and when decoding.)
  • --pause: (Windows only!) waits for keypress at the end. Useful for reading output before exit when calling wavpack/wvunpack in a separate window (which both drag-and-drop the Windows front-end do).
  • -y: "yes" to everything. Use with caution, will overwrite. From 5.5.0 there is also a --no-overwrite that will skip instead of asking to overwrite.
  • -d: delete source file upon successful completion. Again, use with caution.
  • -l will force WavPack to run at low priority (Windows only)
  • -c with -b to select lossy quality: hybrid lossless/lossy use, see below.

WavPack can recompress .wv files in place (using a temporary file until done). For example, wavpack -hx4mvy wavpackfile.wv will recompress wavpackfile.wv the file in high mode using -x4 extra processing, write audio MD5 to it, open the temp file and re-read for verification – and once verified, replace the old wavpackfile.wv. Tags will be transferred. wavpack -hx4rlmvy wavpackfile.wv will also run with low priority (assuming the Windows platform), and will discard non-audio chunks – that is, the ones used to restore the original file's metadata; the .wv file's APE tags will still be copied. As an example, one can compress an ID3v2.4-tagged DSF file by drag and drop; WavPack will then store the tag chunk, but WavPack cannot import v2.4. Then open both in Mp3tag, copy the ID3v2.4 tags to the WavPack file, decide that there is no need to restore the original file's ID3v2.4 upon any unpacking, and apply the wavpack -hx4rlmvy wavpackfile.wv command; it will then discard that chunk (but keep the tags that Mp3tag wrote!), recompress using high (silently ignoring the -x4 that has no effect on DSD) with low priority, write an MD5 sum, verify the process and replace the .wv file by the new recompressed file.

(Incomplete:) hybrid lossless & lossy encoding

(Needs to be expanded. Notes: DSD can currently not be hybrid-encoded and floating-point files should not be. The correction file will be omitted by a lot of applications/players, including ffmpeg; thus, using ffmpeg or ffmpeg-based players to convert/play hybrid-encoded WavPack will be lossy.)

Basic use: the -b switch – and for losslessness, with -c to create a correction file. The b takes a numerical value signifying bits per sample if < 24 and kbit/second if 24 to 9600. E.g. -b12.5 (no space in between, with . even if your locale uses comma for decimal point). wavpack -b234.56 -c filename will create filename.wv file and correction file filename.wvc. As long as both are present, playback and decoding (by wvunpack filename the ordinary way) will be lossless. The file filename.wv – which is at most 234.56 kbit/s – can be copied to a different location and played back stand-alone as a lossy compressed file. The same will happen if the .wvc file is deleted or not found (it has to be same path/filename except with the ".wvc" suffix in place of ".wv") – or equivalently, if the -c is omitted during encoding, then no correction file will be created in the first place. For example: wavpack -b13.5 -hx filename will create a lossy filename.wv compressed with the -hx option, size constrained to 13.5 bits per sample. (Should 13.5 bits be sufficient for lossless encoding, WavPack will tell you at the end of the encoding process – but that information is not stored in the file.)

WavPack will refuse to recompress lossy-generated .wv to "lossless .wv" as that would make a false pretense of being a lossless file. It will also refuse so even in the presence of .wvc; you will have to wvunpack it and and then wavpack it again.


(Incomplete:) decoding options

In addition to the basic usage above (drag and drop or wvunpack filename.wv or wvunpack infilename.wv -o outfilename_possibly_with_desired_suffix_to_override_input_filetype.caf), the wvunpack executable offers several options. For use with the Windows front-end or drag and drop, the Windows-only --pause (waits for keypress at the end, like for wavpack.exe) is essential to read the output report. Also Windows-only options like --drop and -l work as for wavpack.exe, and so do -d (use with caution!) and -y (ditto!).

Many of the options are arguably for power users, like for example:

  • -b: "blindly" decode until end (potentially useful if a .wv file is corrupted)
  • -t: copy input file's time stamp to output file(s)
  • switches to force output file format: --wav, --w64, --caf-be, --caf-le, --raw
  • some switches to perform lossy operations on floating-point files, DSD streams or dropping hybrid-encoded correction files. See the documentation.
  • --skip and/or --until: only decode a portion of the file (again, see documentation)

wvunpack is also the utility to display information from .wv files even when it does not involve decoding, see the next section.

Other file handling

{stub-subsections, incomplete}

Error checking and other file info

wvunpack can get information about WavPack files without decoding to file:

  • -vv: Quick verify without decoding (WavPack 5 files only). This functionality seems to be unavailable outside the official wvunpack (other applications which verify will fall back to the next item, -v):
  • -v: Verify (will decode to check that everything is OK – but not write any file).
  • -s/-ss: -s displays summary of the file, -ss a long summary including tags
  • -x FIELD: Shows tag, e.g. -x comment shows the <comment> field. Also wvtag -x does the same thing.
  • -c: Like -x cuesheet. Also wvtag -c does the same thing.

(To fill in:) Tagging (wvtag) and replaygain management (wvgain)

(... most of these options are available in HA's fave taggers/player?)

Using 3rd party tools; FFmpeg's WavPack encoder/decoder, and others

FFmpeg can encode/decode to/from WavPack, with some limitations. FFmpeg can decode WavPack 5 files, but will only write WavPack 4 (thus, no fast verification). Also, compression presets are different, defaulting to fast but not particularly good compression.[9] On the other end, FFmpeg offers even slower modes than -hhx6.

There is potential information loss in using FFmpeg; it will ignore hybrid correction files, so decoding/playing hybrid-encoded WavPack with ffmpeg or ffmpeg-based players will be lossy. Furthermore, ffmpeg will default to 16 bits when outputting WAVE/AIFF, whether or not the input file is 16 bits; to unpack a 24-bit .wv to WAVE/AIFF, 24-bit output must be specified. (For AIFF by way of CAF, see below.) Also, RIFF metadata will be lost (or AIFF metadata – which WavPack cannot store in any case).

From/to AIFF – preserving bit depth

Reference WavPack will encode a 20-bit (or 17, for that matter) .wav file and keep the information that it is 20 (/17) bits. FFmpeg on the other hand, will delete the information that it was ever 20 (/17) bits. Also, FFmpeg will by default produce 16-bits WAVE/AIFF files, and additional specification must be applied to ensure lossless decoding of 24-bit files; safest is to use wvunpack to decode, but reference WavPack cannot handle .aiff. It does handle .caf, so the following procedure and preserve bit depth, divisible by 8 or not:

  • To decode .wv to AIFF and preserve bit depth: wvunpack "infile.wv" --caf-be - | ffmpeg -i - -codec copy "outfile.aiff".
  • To encode AIFF, possibly with bit depths like 17 preserved: There are AIFF to WAVE conversion software that will preserve bit depth flags (here ffmpeg doesn't), but presuming a a lossless audio user has flac.exe around: flac --fast --lax "aiff infile.aiff" -o - | flac -d - -o - | wavpack - "wavpack outfile.wv" will do a flac encode/decode provided bit depth is 4 to 24.

(One limitation of ffmpeg is that RIFF chunks will be discarded – but for AIFF that is not an issue anyway, as WavPack cannot store AIFF metadata.)

Splitting WavPack files by cuesheet

wvunpack cannot split WavPack files by neither embedded nor external cuesheet, but some external applications can (and will have to decode/re-encode): CUETools can if it is CDDA (44.1 kHz 16-bit stereo), and can re-encode back to WavPack. refalac can decode & split by cuesheets with the appropriate WavPack library DLL file[10], outputting WAVE or ALAC-in-MP4.


Software support

With Android support and playback through ffmpeg, it might no longer be feasible to maintain a list of applications that can play WavPack files, and the following is most certainly incomplete – as is the list at https://www.wavpack.com/#Software .

Players

  • foobar2000 advanced freeware audio player plays/decodes WavPack out of the box on both Windows, MacOS, Android and iOS (Windows: supports encoding if wavpack.exe is installed, and redistributes the official wavpack.exe through its "Free encoder pack" addon for encoding. With ReplayGain & cuesheets support.) Also Boom from the same author.
  • VLC multiplatform media player
  • VUPlayer (official plugin, supports encoding)
  • NullSoft Winamp (plugin with ReplayGain & Media Library support) and Winamp-compatible players
  • Windows Media Player and other directshow-based players (MPC, TCMP, RadLight) (with CoreWavPack directshow filter)
  • Cog Audio player for MacOS X.
  • JRiver Media Center
  • XMMS (with Kuniklo's plugin)
  • LAMIP (official plugin)
  • MPXplay for DOS!
  • Aqualung for GNU/Linux
  • Cowon JetAudio Player and CD ripper
  • XMPlay Plugin required (WavPack input plugin) and (bass library) to play 'wv' files

Converters, CD rippers etc.

Several of the players, like Cowon JetAudio, foobar2000 and VUplayer, also have converters that can create WavPack files. More:

Taggers

Other tools

It's worth mentioning the Matroska guys decided to concentrate on WavPack as the lossless compressor of choice for their container. Quite an honor... :-)

  • PKWare's .zip format compresses audio by WavPack since version 6.3.2 (2007). Beware that there is no expectation that other decompression software handles these zip files; even if PKWare co-designed the format and PKZip was the original .zip implementation, their subsequent compression methods are outside the ISO/IEC standardized zip format specification.


Links

  1. Martijn van Beurden: Lossless audio codec comparison archive, all comparisons in this wiki article consistent with CDDA results from revision 5, 2022, using WavPack 5.4.0.
  2. CodecPerformanceComparison at the Rockbox wiki
  3. Monkey's Audio FAQ (archived on October 17, 2000)
  4. OptimFROG's "DualStream" hybrid encoding
  5. XP-compatible 5.5.0 build posted at the HA forum
  6. [1] HA thread with link to Android bug report by the Monkey's Audio author
  7. HA forum post on how to rename executable for drag and drop
  8. HA forum comment: verification checks the written file after closing and reopening
  9. HA forum comment comparing the compression presets
  10. refalac usage includes how to split by cuesheet
  11. HA Wiki: Configuring EAC and WavPack