Persona 4 Golden

Persona 4 Golden

116 ratings
Unp4cker - Fix Stutter, Extract, and Edit P4G Cutscenes
By Lulech23
**Now with GUI!** Unp4cker is a *.pac archive editor designed to view and extract P4G cutscenes for modification. It can also repackage them back into the game! Replace the Golden intro with the PS2 classic, re-encode to fix stuttering, and more!
13
   
Award
Favorite
Favorited
Unfavorite
Introduction

Unp4cker is a PowerShell script which uses GNU CoreUtils to automatically identify and extract P4G PC video files. It can also repackage them for in-game playback, although this feature is currently experimental.

File Format Breakdown
Persona 4 Golden cutscenes on PC are quite different from their PlayStation Vita counterparts. Vita used plain MP4 files in a simple folder, whereas the PC version has them packed into archives. These archives essentially smash a bunch of video files together into one big file with some extra data at the beginning to tell the game where to find each video.

On PC, P4G cutscenes are encoded in WMV2 (likely to avoid MP4 licensing fees) at 1920x1080, using some sort of upscaling filter to smooth out the 960x544 Vita originals. Despite Windows reporting they're encoded at just ~200Kbps and 15FPS, the encoder was allowed to go much higher and real-world results land at ~8Mbps and 29.97FPS (pretty much standard for 1080p). Some files go much higher (>30Mbps) which causes stuttering for some users on slower drives!

There's 41 cutscenes total split across three archives:

movie00000.pac movie00001.pac movie00002.pac

Unp4cker Methodology Breakdown
Unp4cker works by searching these archives for WMV2 byte headers and then splitting them out to individual .wmv files. Doing the reverse is also possible, but with one big caveat: currently, any modified files must be exactly the same size down to the byte, otherwise the game will not be able to locate any files that come after them. Unp4cker handles this by padding smaller files to match their originals, but larger files will require deeper modification (unimplemented).

Naturally, this does not apply to the last file in any archive, which means that, incidentally, the English intro video can safely be replaced with the PS2 original, since it is the last file in the last archive.
Download

Latest Version

What's New
  • Fixed compatibility with the latest update of the game
  • Improved file identification accuracy--random occurrences of the file pattern in code are now far less likely to be erroneously included in results.
  • Added support for subfolders in archives. However, as LQ videos appear to use an unidentified alternative format, LQ videos will currently be ignored as a workaround.

Previous Versions
Setup

Unp4cker is a PowerShell script that can run in both command-line and GUI modes. No installation is necessary; just a few simple steps to set it up:

1. Extract
First, download Unp4cker and extract the .zip file contents anywhere on your PC.

2. Enable PowerShell Scripts
By default, PowerShell disallows running any custom scripts to protect against malicious scripts. If you've never used PowerShell scripts before, you'll need to enable them in one of three ways:
  • Right-click on the included "Enable PowerShell Scripts (Run as Admin).bat" file and--you guessed it--choose "Run as adminstrator"
  • Right-click on the Windows Start menu button and choose "Windows PowerShell (Admin)". In the PowerShell window that appears, run the command:
    Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
    You may also need to unblock the script file from the file Properties menu, or unblock it from PowerShell:
    Unblock-File -Path ".\unp4cker.ps1"
  • Open the Windows Settings app and navigate to Update & Security > For Developers. Scroll down to the PowerShell section and check the box "Change execution policy to allow local PowerShell scripts to run without signing" and click Apply.
How-To

GUI Mode
Unp4cker v1.0.0 and newer include an optional GUI which can be used to issue commands through a simple interface.

To activate GUI mode, simply run the unp4cker.ps1 script without any command-line arguments. From a file browser, this can be achieved by right-clicking the script and choosing "Run with PowerShell". Simply choose an operation to perform from the GUI, and it will walk you through each step.

Command-line Mode
If you'd prefer to use Unp4cker without a GUI, you'll find its command-line syntax just as simple!

To start, hold Shift and right-click anywhere in the file browser window where you've extracted Unp4cker. Choose "Open PowerShell window here" to open PowerShell with the active directory pre-configured to the Unp4cker folder. You're now ready to start issuing commands!

To get started, it is highly recommended to check the built-in help dialog for the most up-to-date details on syntax and features. This can be done by entering the name of the Unp4cker script followed by "-h" or "--help" (note the dashes!):

.\unp4cker.ps1 --help
Note: The ".\" tells PowerShell to look for Unp4cker in the current directory. If you start typing "unp4cker" and press Tab, it will autocomplete this part for you.

The basic syntax of Unp4cker is as follows:

.\unp4cker -command "C:\input" "C:\output"

Primary commands include list (-l) unpack (-u), pack (-p), extract (-e), and replace (-r).

List
.\unp4cker.ps1 -l "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac"

The list command is often a good place to start before issuing other commands. This will display a list of a *.pac archive's video contents, including both its numerical index and literal filename. There's no need to unpack an archive just to find out what's inside!

Unpack
.\unp4cker.ps1 -u "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac" ".\movies"

The unpack command will take a *.pac archive and extract all video contents to the specified output folder.

Note: If the output folder path contains spaces, make sure to enclose it in quotes!

If the output folder does not exist, it will be created automatically. A subfolder will also be created, named after the input archive. Here, you can access unpacked movie files and make any modifications you like! (See the examples below!)

Pack
.\unp4cker.ps1 -p ".\movies\movie00000" "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac"

The pack command will take a previously unpacked folder of video files and pack them back into the original archive. This is key, as Unp4cker currently cannot create entirely new archives on its own--the destination archive must already exist so that Unp4cker can read and use its metadata.

It's also important to note that repacking an archive requires the input folder to contain the same number of files with the same filenames as the original archive, or the resulting modified archive will not work in-game!

With all files present and accounted for, once the operation is complete, you're ready to run the game and see the results!

Extract
.\unp4cker.ps1 -e "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac p4ct001.usm .\movies"
.\unp4cker.ps1 -e "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac 0 .\movies"

The extract command will take a *.pac archive and extract a single video to the specified output folder. No subfolders will be created.

It is highly recommended to use the list (-l) command first to see available files before extracting. Both the numerical index and literal filename are acceptable inputs for choosing a file to extract.

Replace
.\unp4cker.ps1 -r .\movies\p4ct001.usm.wmv "S:\SteamLibrary\SteamApps\common\Day\movie00000.pac"

The replace command will take a single video and add it to the specified *.pac archive, overwriting an existing file of the same name. This is key, as it means the input filename must be valid. Extensions will be ignored. If a matching file cannot be found in the archive, it will not be replaced.

If you aren't sure what archive a filename belongs to, it is highly recommended to use the list (-l) command first.

Encode
.\unp4cker.ps1 -n .\movies\p4ct001.usm.wmv
.\unp4cker.ps1 -n .\movies

The encode command will take a video or folder of videos and re-encode them using a moderate bitrate to avoid stutter. If the resulting video file is larger than the original, it will be discarded to avoid in-game errors.

Note: File size checks will only be performed when encoding original videos. Other video files can be encoded with this method to make them P4G compatible, but it's up to you to keep them smaller than the originals. Otherwise, the game will likely crash.

While the settings used by Unp4cker's built-in encoder should provide a suitable balance of quality for everyone, advanced users may wish to manually encode videos using their own custom settings instead.
Example: Replace Golden intro with PS2 intro

Note: Different versions of the game may store specific cutscenes in different files. If you don't find the filename you're looking for in the expected archive, check the other archives using the List command.

A simple modification with Unp4cker you may be interested in is replacing the remade Golden intro with the classic PS2 intro. This intro was included with P4G as an unlockable bonus, but can be copied in place of the updated intro as well.

Tip: This example will demonstrate command-line, but don't forget, you can follow along each step in the GUI too!

First, extract the classic PS2 intro:

.\unp4cker.ps1 -e "S:\SteamLibrary\SteamApps\common\Day\movie00002.pac" p4ctop1.usm ".\movies"

This will create the file "p4ctop1.usm.wmv" in a "movies" folder next to Unp4cker. Rename this file to "p4ctop3_e.usm", which is the name of the English Golden intro.

Tip: To confirm the filename for yourself, list the contents of "movie00002.pac":

.\unp4cker.ps1 -l "S:\SteamLibrary\SteamApps\common\Day\movie00002.pac"

Finally, replace the English Golden intro in the original archive with the extracted PS2 intro (a backup will be created automatically):

.\unp4cker.ps1 -r ".\movies\p4ctop3_e.usm" "S:\SteamLibrary\SteamApps\common\Day\movie00002.pac"

Now launch the game and enjoy the classic intro!
Example: Fix Stutter

Some users may experience stutter during certain cutscenes due to the wildly varying bitrate between video files. While most stay within a reasonable range (~8Mbps), some go as high as 30Mbps and more! This should pose no problem for a fast SSD, but slower hard drives and other storage mediums may struggle to read the video file fast enough to keep up.

By re-encoding the video to a lower bitrate, we can solve the stuttering problem once and for all!

Tip: This example will demonstrate command-line, but don't forget, you can follow along each step in the GUI too!

To start, unpack the archive with the video giving you trouble. In this example, we'll be using the Golden intro, which is contained within "movie00002.pac":

.\unp4cker.ps1 -u "S:\SteamLibrary\SteamApps\common\Day\movie00002.pac" ".\"

Next, navigate to the newly-created "movie00002" folder next to Unp4cker. Here you'll find four files, with "p4ctop3_e.usm.wmv" being the English intro.

As of version 1.0.1, Unp4cker includes its own version of FFMPEG[www.ffmpeg.org], a very powerful free and open-source video conversion application. Once you've unpacked some files, you can use the built-in encode command to reduce high-bitrate files to a more moderate bitrate while mostly retaining image quality:

.\unp4cker.ps1 -n ".\movie00002"

This example command will process the entire folder, but you can also process a single file at a time, if you wish. Just change the folder path to the path of a single file!

Tip: If you'd like to handle encoding yourself, you can also use the included FFMPEG application directly:

.\bin\ffmpeg.exe -i ".\movie00002\p4ctop3_e.usm.wmv" -c:v wmv2 -b:v 12M -vf "deblock=filter=strong:block=4, fspp=4, scale=1920:1080" -c:a copy -map 0 -y ".\movie00002\p4ctop3_e.usm.copy.wmv"

When FFMPEG is finished, simply pack the folder back into the original archive (a backup will be automatically created):

.\unp4cker.ps1 -p ".\movie00002" "S:\SteamLibrary\SteamApps\common\Day\movie00002.pac"

From now on, your video playback will be smooth as silk!
Known Issues

Unp4cker is an experimental file modification script, and comes without guarantee, warranty, or support. While it has been tested and found to be generally reliable, please keep in mind the following known issues and caveats when using it:

  • When repacking, all files must be LESS THAN or equal to the size of the original files, otherwise the game will not be able to read any cutscenes following the mismatched cutscene in the same archive. Attempting to play modified archives with larger file sizes will crash the game (with the exception of the last file in each archive).
242 Comments
Yukimaru Feb 3 @ 6:10pm 
Does anyone have a P3R equivalent tool?
Lulech23  [author] May 13, 2021 @ 3:19pm 
There's not really any need anymore. Make sure your game is on the latest update/beta branch. The official cutscenes have been re-encoded and are now excellent.
Sol21 May 13, 2021 @ 8:23am 
I can't seem to use FFMPEG and how to use it?
Oddworldmaniac Nov 23, 2020 @ 6:24am 
yo thanks, this was very helpful, and the command-line very well explained, thanks :approved:
Magicman Scott40k Nov 15, 2020 @ 10:18pm 
ok ill check discussions. im not good at finding things but ill try.
Lulech23  [author] Nov 15, 2020 @ 3:41pm 
@magic man scott f. - There already is one. Check the Discussions for official guides on updating to the latest hotfix update.
Magicman Scott40k Nov 15, 2020 @ 12:55am 
suoer confusing for a guy like me. no idea what any of it meant, im hoping the patch for the game comes out soon.
facing_w0rlds Oct 18, 2020 @ 8:35am 
Thank you for that, fingers crossed we'll someday be able to replace stuff in those subfolders but this at least makes things clearer for now. :happymeat:
Lulech23  [author] Oct 16, 2020 @ 1:56pm 
I just looked into LQ cutscenes a bit. They're in movie00000.pac, but they appear to use a different video format than the HQ cutscenes. I wasn't able to quickly identify the LQ format, but while I was at it, I updated Unp4cker to at least recognize subfolders in archives and ignore LQ videos in search results. That should at least fix compatibility with the latest updates for HQ cutscenes. 🙂
facing_w0rlds Oct 16, 2020 @ 6:12am 
Does anyone know which file contains the new low-quality cutscenes? I want to replace the Golden intro with the PS2 ver. with 'Animation Quality: Low' selected. Thanks.