├── .gitignore ├── LICENSE ├── README.md └── repair.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Kevin Coulombe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kingdom Hearts Cutscene Repair Tool For SteamDeck 2 | 3 | [Kingdom Heart HD 1.5+2.5 ReMIX](https://store.epicgames.com/en-US/p/kingdom-hearts-hd-1-5-2-5-remix) is available on the Epic store and can be installed on the SteamDeck (and Linux in general) through [Heroic Launcher](https://heroicgameslauncher.com/). 4 | 5 | However, there is a problem... The cutscenes don't work! 6 | 7 | # Current situation 8 | 9 | The MP4 cutscenes are corrupted. I managed to repair a good portion of them, but they only play with VLC or some other player. They **will not play within the game**, I believe because of this issue (I get the same arch issues with gstreamer looking for avcodec libs) : https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/issues/1291 10 | 11 | My current script repairs about half of the cutscenes. Use the -clean flag to delete the remaining broken files and allow the games to at least play those that are repaired (take a backup). 12 | 13 | I do intend on working to fix the remaining half by improving on a relatively generic MP4 repair tool. I might see what I can do about making them play within the game after that... 14 | 15 | ## How to run 16 | 17 | 1. Open Desktop Mode (if you're not using a SteamDeck, just turn ON the Linux box :) ) 18 | 1. Copy the [repair.sh](https://github.com/stonkie/kingdom-hearts-cutscene-repairer/blob/main/repair.sh) file from this repository into the `/home/deck/Games/Heroic/KH_1.5_2.5/EPIC` directory. 19 | 1. You may want to make a backup copy of the EPIC directory just in case. 20 | 1. Open a terminal in that directory (right click on repair.sh and the option should be there) 21 | 1. Run the following command `chmod a+x repair.sh` 22 | 1. Run the following command `./repair.sh . -clean` 23 | 24 | # What is broken in those files? 25 | 26 | The main issue seems to be that the start of the MP4 files are either corrupted or in a format neither me not most media players recognize. 27 | 28 | The bash script overwrites the beginning of the MP4 files with a valid equivalent and that repairs a certain proportion of the files. 29 | 30 | ## Why are some cutscenes still broken then? 31 | 32 | Some of the files were formatted in a way where important information was supposed to be at the beginning of the files. And that's just not there. 33 | 34 | That important information is a "moov box" header. We see the content is actual present in those files, but it's missing too much of the header to be repairable this easily. We need to repair the header with a custom crafted bit of binary that recreates the parts of the header that were corrupted. 35 | 36 | I planned on fixing everything though bash to make it safe. The code is pretty easy to read and assess for security risks. Creating custom binary strings however is a bit complicated in bash, so I will likely switch to a full fledged programming language to implement the fix. -------------------------------------------------------------------------------- /repair.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | for f in $(find "$1" -maxdepth 10 -type f -name '*.mp4') 4 | do 5 | echo "Repairing $f" 6 | 7 | unset moovoffset 8 | 9 | if [[ "$f" == *kh015.mp4 ]] 10 | then 11 | echo "File $f is filtered out" 12 | elif [[ "$f" == *kh027.mp4 ]] 13 | then 14 | echo "File $f is filtered out" 15 | elif [[ "$f" == *kh150.mp4 ]] 16 | then 17 | echo "File $f is filtered out" 18 | elif [[ "$f" == *kd803.mp4 ]] 19 | then 20 | echo "File $f is filtered out" 21 | elif [[ "$f" == *opn.mp4 ]] 22 | then 23 | echo "File $f is filtered out" 24 | elif [[ "$f" == *zz_event_084.mp4 ]] 25 | then 26 | echo "File $f is filtered out" 27 | elif [[ "$f" == *zz_event_140.mp4 ]] 28 | then 29 | echo "File $f is filtered out" 30 | else 31 | moovoffset=$(grep --only-matching --byte-offset --max-count=1 -a -o --perl-regexp "\x6D\x6F\x6F\x76" "$f" | grep -oP '^\d+' -m 1) 32 | echo "moovoffset=$moovoffset" 33 | fi 34 | 35 | if [ -z "$moovoffset" ] 36 | then 37 | echo "File $f has no moov, cannot repair" 38 | 39 | if [ "$2" == "-clean" ] 40 | then 41 | rm "$f" 42 | fi 43 | else 44 | printf "\x00\x00\x00\x1C\x66\x74\x79\x70\x69\x73\x6F\x6D\x00\x00\x02\x00\x69\x73\x6F\x6D\x69\x73\x6F\x32\x61\x76\x63\x31\x00\x00\x00\x08\x66\x72\x65\x65\x00\x00\x00\x00\x6D\x64\x61\x74" | dd of=$f bs=1 seek=0 conv=notrunc 2> /dev/null 45 | mdatsize=$(echo $((moovoffset - 40)) | xargs printf '%08x') 46 | echo "mdatsize=$mdatsize" 47 | printf "\x${mdatsize:0:2}\x${mdatsize:2:2}\x${mdatsize:4:2}\x${mdatsize:6:2}" | dd of="$f" bs=1 seek=36 count=4 conv=notrunc 2> /dev/null 48 | fi 49 | done 50 | --------------------------------------------------------------------------------