[REQUEST] Script/program for extracting PS2 VAG files.

Codecs, formats, encoding/decoding of game audio, video and music
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by aluigi »

Just for reference, the following is the tool that I wrote many years ago and it's no longer indexed on my website:
http://aluigi.org/papers/vagguess.zip

As you can imagine there is and there will be no support from me.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

aluigi wrote:the following is the tool that I wrote many years ago and it's no longer indexed on my website

No worries pal, I already got your tool.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

The first results are good. The tool can detect VAG streams in 99% cases. There are some false positives and false negatives depending on settings, but at least I think we'll be able to detect audio inside of archives (like in examples you uploaded here)
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Here's the first experimental version. Works only with mono files now.

What it does:

Scan the whole file by 256-byte blocks trying to detect VAG stream analyzing its statistical data. Can detect VAGs with any alignment (even if it starts, say, from offset 0x5B07). Then read the stream until the end-of-stream flag and dump it.

No good detection for stream start yet, and no support for interleaving.
Last edited by id-daemon on Thu Apr 21, 2016 3:32 pm, edited 1 time in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

I tested your tool and although it needs some work, it was quite useful in the end. At least, with the latter archive file I provided.

This .vag file, for example, has three audio files tied together(see the attachment below).

That's just what I wanted to report though. Good luck on your tool, I guess.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Yes, there are no "end" flag in these streams. They have a "start" flag instead. Do you have correct meanings for VAG flags? Becuase I'm just guessing them.

I think this tool must have a lot of settings. In this case, for example, a block of zeroes will be used as an end of stream.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

id-daemon wrote:I think this tool must have a lot of settings. In this case, for example, a block of zeroes will be used as an end of stream.

Then they are dumped as raw VAG files, correct?
And speaking of settings, how can I use them? Your tools always consisted of "drag-and-drop the original file" kind of approach.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

AnonBaiter wrote:Then they are dumped as raw VAG files, correct?

I can also decode them to WAV.

AnonBaiter wrote:Then they are dumped as raw VAG files, correct?
And speaking of settings, how can I use them? Your tools always consisted of "drag-and-drop the original file" kind of approach.

No, not always.

It can be GUI tool like Evolution engine tool viewtopic.php?f=6&t=1960
Or command line parameters, like usual. When you "drop the file" it means you have only have 1 parameter (file name), but there may be more.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

What game is that 8225 file from?
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

id-daemon wrote:What game is that 8225 file from?

World Soccer Winning Eleven 5.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Ok, after many tests I can confirm that universal approach for this tool can only be based on manual switching of different methods for detecting stream start, end, and interleave. There are many types, and there's no way to detect this automatically.

So for example, you will need to run scan in "mono" mode first, then stereo.

I will try and support most usual cases, and then maybe if there will be interest in this, I can expand it.

If you have more examples that you think will be interesting, send them.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

id-daemon wrote:If you have more examples that you think will be interesting, send them.

I'll try my best!
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Things are going good. 2 common interleave types already implemented. Used in "the warriors" and your World Soccer Winning Eleven.

Must say that Luigi's vaguess tool didn't work right with "the warriors", and couldn't detect interleave in all cases. As a result, his tool extracts 299 files, while there are actually 349. My current tool works better and currently detects 343 files there. While the remaining 6 have size exactly divisible by its interleave, making it impossible to detect by "zero blocks".

It's possible to decode even those, but only manually.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

For example, if we have stream with length = 0x221100, then out of all possible Warriors interleaves (from 6E00 to 8000 with step 40) we have only one exact divider, and it is 72C0. So this will be an interleave for this stream. I checked that and its working.

Image
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Howether, for another stream of 0x2B1100 bytes, there are three dividers: 6E40, 7080 & 7A80, so I had to check them all to find the right one. It was 6E40.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

At last, after lots of testing, I'm ready to present the first tool version that supports stereo interleaved streams. For now, it will only scan file and output raw files, that you can check. After more testing, I think I can add decoding too.

Usage:
vag_scanner [file_name] [mode]

modes:
s1 - stereo with last short block (like in soccer)
s2 - stereo with all blocks of equal size (like in warriors)
s3 - stereo with "end of stream" markers
anything else - mono mode

If you don't set [mode] parameter, it will presume mono. So if you just drag a file onto the tool, it will work mono,

Usually all streams in one game will be the same type. So you only need to find the right mode, and it will extract all stereo streams. Some games may work with two modes (for example s1 & s3). Additional run may be needed for mono files, while most stereo modes will also output mono files correctly.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

I think no need to decode them. Just make SVAG headers, and they will be playable.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

So let me know, if I can leave it like this, make the tool add headers, or it would be better to decode to WAV.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by AnonBaiter »

id-daemon wrote:So let me know, if I can leave it like this, make the tool add headers, or it would be better to decode to WAV.

I think it would be best to leave the tool as is. The rest is up to you.
id-daemon
Posts: 1040
Joined: Sun Mar 22, 2015 7:09 pm

Re: [REQUEST] Script/program for extracting PS2 VAG files.

Post by id-daemon »

Ok. I already made some adjustments for better handling mode s3, I will update the tool soon. If you'll encounter any files that it can't handle, let me know, maybe I can add more modes.