Issues encoding STR+XA with MC32 and FFMPEG

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
Chesterfield
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Feb 27, 2022

Issues encoding STR+XA with MC32 and FFMPEG

Post by Chesterfield » March 1st, 2022, 1:27 am

Hello.

I've recently begun a translation project for a PS1 game, which, if all goes well, involves some video extraction, editing and reinsertion. All of the necessary data (text and .TIM editing) is already processed, but I'd like to go the extra mile. There are a total of 3 videos I'd like to edit, each with varying degrees of work involved. I don't mind, and actually prefer editing each individual frame, but it's been a couple of sleepless nights over this without going anywhere in terms of successful encoding, or finding an alternative...

First, I use jpsxdec_v1-00_rev3921 to extract a video from the target .ISO (a .BIN file, actually). The original format is a Compressed AVI (MJPG), with 320x420 resolution running at 15 FPS (14.985).

I then use ffmpeg to extract all of the video's frames through the command line like so:

Code: Select all

ffmpeg -i 003.avi -r 15/1 %04d.bmp
Once the individual frame edits are done, I then rebuild the .AVI using an image codec (which, if not used, does not produce a viable movie):

Code: Select all

ffmpeg -i %04d.bmp -vcodec rawvideo -pix_fmt yuv420p -s 320x240 -r 15 TEST.AVI
The movie runs without a problem, although it's necessary to adjust and tinker with the images until satisfactory. I convert the .AVI into a readable .STR format with MC32, using the options indicated here. The added -pix command is used to handle image to video conversion.

Since the video itself has sound, I can then either extract the audio from the extracted .AVI, or extract the audio directly from the ISO. But whether I use the original audio from the disc, or the audio from the extracted .AVI, MC32 produces the following message:
The size of frame 48 is too large. It must be less than 8 sectors.
If this only happened with a frame, I don't think it would be much of an issue. However, it does so for an enormous amount of frames, indicating that some should be less than 8 or 9 sectors. I have no idea if this is related to either the sound or the image quality; I would assume actual video frames, but if the frames MC32 is mentioning are actual video frames, it's referencing frames I haven't edited at all (a *lot* of them between #48 and #573). If I use .JPG instead (which is awful), the error persists.

And whatever survives the conversion always displays the same problem: analyzing the original video through jpsxdec shows a disc speed of 14.985 (15000/1001) FPS, while the new .STR indicates a disc speed of 14.223 (15375/1081) FPS. This means the new .STR video playback will finish quite a while before the audio is done playing.

I'm at a loss here. I may be using the wrong options in ffmpeg, but I don't even know if that is the case. Any ideas on what I might be doing wrong? Thanks in advance.

User avatar
mzxtuelkl
Curious PSXDEV User
Curious PSXDEV User
Posts: 20
Joined: Jul 26, 2021
PlayStation Model: SCPH-5501
Location: United States
Contact:

Post by mzxtuelkl » March 1st, 2022, 5:18 am

I'm at a loss here. I may be using the wrong options in ffmpeg, but I don't even know if that is the case. Any ideas on what I might be doing wrong? Thanks in advance.
Perhaps try using a much older version of ffmpeg? Maybe the ffmpeg devs changed a few things around that made it not work nicely with mc32 (probably not, but it's worth a shot).
And whatever survives the conversion always displays the same problem: analyzing the original video through jpsxdec shows a disc speed of 14.985 (15000/1001) FPS, while the new .STR indicates a disc speed of 14.223 (15375/1081) FPS. This means the new .STR video playback will finish quite a while before the audio is done playing.
I've also had the same issue with mc32 producing a .STR with video playing slightly faster than the audio, but I couldn't figure out what the hell I was doing wrong and gave up. My guess would be ffmpeg, but the 16-bit movconv.exe and movpack.exe tools may (or may not) be worth your time if nothing else works.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » March 1st, 2022, 12:48 pm

Chesterfield wrote: March 1st, 2022, 1:27 am The size of frame 48 is too large. It must be less than 8 sectors
It means your frame is too large for the sector size you specified in MC32. Increase the size of the framing in MC32.

Code: Select all

Sector Size / Data Rate = Frame Size
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
Shadow
Verified
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » March 1st, 2022, 12:50 pm

mzxtuelkl wrote: March 1st, 2022, 5:18 am I've also had the same issue with mc32 producing a .STR with video playing slightly faster than the audio, but I couldn't figure out what the hell I was doing wrong and gave up
Set LEAP SECTOR to ON. Enabling this will cause the PlayStation to drop frames in order to keep the audio synched as the CD-ROM drive doesn't read every single frame perfectly. You can only leave it off on things like emulators or PSIO where the CD-ROM data stream is read perfectly 'sector-for-sector'.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
mzxtuelkl
Curious PSXDEV User
Curious PSXDEV User
Posts: 20
Joined: Jul 26, 2021
PlayStation Model: SCPH-5501
Location: United States
Contact:

Post by mzxtuelkl » March 1st, 2022, 4:31 pm

Shadow wrote: March 1st, 2022, 12:50 pm
mzxtuelkl wrote: March 1st, 2022, 5:18 am I've also had the same issue with mc32 producing a .STR with video playing slightly faster than the audio, but I couldn't figure out what the hell I was doing wrong and gave up
Set LEAP SECTOR to ON. Enabling this will cause the PlayStation to drop frames in order to keep the audio synched as the CD-ROM drive doesn't read every single frame perfectly. You can only leave it off on things like emulators or PSIO where the CD-ROM data stream is read perfectly 'sector-for-sector'.
Thanks Shadow! I'll try it when I attempt FMV stuff again :)

Chesterfield
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: Feb 27, 2022

Post by Chesterfield » March 2nd, 2022, 12:25 pm

Thank you all for your replies.

It seems I did it, but I also noticed something else. The previous .AVI to .STR conversions had some problem, likely to how I was converting the movie through ffmpeg. It converted 1022 frames into 614. Turns out that the -r option wasn't helping; what I had to do was specify the actual framerate:

Code: Select all

ffmpeg -i %d.bmp -framerate 15/1 -pix_fmt yuv420p -vcodec rawvideo -s 320x240 -an TESTE8.avi
Another thing was that when extracting the original movie from the disc, jPSXdec declared 1020 frames; I have no idea why ffmpeg extracted 1021 or 1022, but once I finished the edits, I deleted the last 2 frames (black screens, basically). Doing so made MC32 recognize the proper amount of frames as well.

I've just tested the new video with both jPSXdec and .ISO/.BIN insertion through mkpsxiso, and it seems to work so far (though the compression seems very, very slightly more noticeable)!

Thank you once again!

(PS: Does mkpsxiso actually require LBA info? The video I've inserted worked just by replacing the .STR file and without editing the generated .XML, though I think the movie was the same size as the original...)

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests