27 October 2016

Patches and xdelta3

"Patches" are small scripts that take an existing file, a difference file (patch.vcdiff) and create a new file based on those differences. This is usually done using a program called xdelta3 which implements RFC 3284.

Concept: FileA + differences.vcdiff = FileB

Usually a shell language is used for the actual script like batch and/or bash and the patch bundle includes the xdelta3 binary.

Use Cases:

Patches are typically used when needing to make very small changes to very large files in a binary exact way (the hash of newFileB must match the hash of originalFileB).

  • One example is when a group releases a version 2 of an existing release. The myfile.v2.mkv is nearly identical to the original myfile.v1.mkv. So, instead of asking users to download hundreds of MB a second time, patches allow for smaller download (typically less than10MB) if the myfile.v1.mkv is already present.
  •  Another example is when an easily obtainable raw release currently exists (untranslated.mkv) and a group would like to add soft-subs to it without being responsible for distributing the very large files directly.
  • The patch concept could also be extended to include mkvmerge and dub.aac in order to add a dual-audio track to release.mkv and make it release(dual-audio).mkv. "Patches" that utilize mkvmerge in this way will not produce binary exact duplicates, unlike RFC 3284 compliant ones.
To use a patch:
  1. Obtain the original file (such as the raw.v1.mkv or raw.mkv)
  2. Obtain the patch.zip
  3. Extract the patch.zip contents to the same directory the original files
  4. Double-click on ApplyPatch.bat OR drag and drop the original over ApplyPatch.bat (depending upon the instructions)
  5. Double-click on Cleanup.bat to remove the patch files OR just delete them
    Note: Cleanup.bat may or may not remove the original files
To create a patch: Concept: FileA + FileB = differences.vcdiff Note: The file order is important.
  • CLI: xdelta3 -e 9 -s old_file new_file delta_file
    • Note: Delta means "change."
  • Or xdelta3 GUI for GUI people

For more information see BakaBT's Patching Guide, 13ack.Stab's Guide to V2 Patches and these examples.

No comments:

Post a Comment