ToaHartor / GI-cutscenes

A command line program playing with the cutscenes files (USM) from Genshin Impact.
GNU General Public License v3.0
614 stars 66 forks source link
cutscene decoder decryption genshin genshin-impact usm yuanshen

# GI-cutscenes

A command line program playing with the cutscenes files (USM) from Genshin Impact.

Able to extract the USM files, decrypt the tracks and convert them into readable formats, then merge them into a single MKV file. The final MKV file can then be played like a small movie, with the subtitles correctly formatted like in the game. Sometimes, subtitles can be desynchronized with the audio, but that's also the case in game (and not this program's fault).

Cutscenes from version 1.0 to 4.6 can be decrypted.

Also includes CBT3, which has the same files than the live version

If you want to extract newer cutscenes but the versions.json in the released zip is outdated, simply download the updated file in the project tree (here) and replace the file. This file will be updated with the version key every time a new version drops.

Feel free to make a pull request if you have some keys unavailable in the versions file, any help is welcome on that part.

Motivations

I made a python tool a year ago (as a proof of concept) in order to be able to rewatch any cutscenes from the game. As a first C# program, I thought it would be a good idea to rewrite it. I haven't invented the code for HCA conversion and USM demuxing, I just readapted it in C# from other projects.

Features (and roadmap)

Build

This program uses the .NET framework version 6.0, so you will need the .NET SDK. You can open this project in Visual Studio 2022 and build the solution, or use the dotnet CLI : dotnet publish -c Release -r [platform]. Otherwise, you can also modify the script build-all.sh with the desired runtimes.

Usage

You can follow the next steps to use this program :

1. Download

Grab the latest release for your platform from the release page, download the ZIP file and extract it. For each platform (Windows, Linux, MacOS), two binaries are available:

You can also get a GUI version in this repository (thanks to SuperZombi)

Starting from version 0.4.0, an merging solution was integrated without relying on external programs. However, if you wish to use other merging solutions than the one integrated, you can install MKVToolNix (which provides mkvmerge) or FFMPEG.

2. Configuration

appsettings.json contains a configuration sample with the following keys :

Clone the subtitles repository

Execute the following lines in the directory where the tool is :

git clone --depth 1 --filter=blob:none --sparse [repository URL]
cd GenshinData
git sparse-checkout set Subtitle

If you don't have git installed, you can download the zip file of the repository and unzip it in the program folder.

Managing the font files

No font file is provided in this repository, so you will have to get them in the game files. You should find them in [Game Directory]\Genshin Impact game\GenshinImpact_Data\StreamingAssets\MiHoYoSDKRes\HttpServerResources\font. You can then copy these two TTF files without renaming them in the tool's directory.

3. Commands

There are 3 different commands available to be used on the files :

Several options are available for most of the commands :

Maintenance commands and options:

Examples

The video is extracted as an IVF file (which makes codec detection (VP9) easier for mkvmerge). In order to watch it, you can open it into VLC or change the extension to .m2v.