elishacloud / Silent-Hill-2-Enhancements

A project designed to enhance Silent Hill 2 (SH2) graphics and audio for the PC. It also includes scripts to build or modify SH2 audio files (SFX, BGM and Dialog).
http://www.enhanced.townofsilenthill.com/SH2/
zlib License
573 stars 41 forks source link

Bink video limitations #35

Open OregonPacifist opened 6 years ago

OregonPacifist commented 6 years ago

Hey everyone. I just have a question. Is the Bink video format limited to 24 FPS or can it handle 60 FPS?

What I'd like to try is convert the .bik videos (for the cutscenes) to .mp4, then artificially double the frames and clean it up as much as possible, then re-convert it back to .bik format. As improved as the video files are (with the Enhanced pack), I think they could be even better.

Does anyone know if this has been attempted before?

Thanks!

Polymega commented 6 years ago

Hi @OregonPacifist ,

This is something that we looked in to at the early stages found here: https://github.com/elishacloud/Silent-Hill-2-Enhancements/issues/13#issuecomment-407188237 (Also read the several posts above it, too)

@angularGraphics has expressed interest in re-doing their work at 60 FPS this time. But that's been the extent of this work done, so far.

angularGraphics commented 6 years ago

I haven't worked more on it since, last I heard in the above linked thread, 60 fps playback isn't smooth.

And one shouldn't artificially double the frames in the first place, proper handling of the PS2 videos already gives you 60 fps. I just discarded every other frame when I created my pack, to keep it at 30.

OregonPacifist commented 6 years ago

@Polymega @angularGraphics

OK, so I've been playing around with this.

Good news!: I have been able to successfully convert the videos from 30 FPS to 60 FPS using a video editing program. The program adds artificial frames between the existing ones by "guessing" what happens between the two. The result is an incredibly smooth video playback, and (in my opinion) indistinguishable from the original PS2 cutscenes. It's true 60 FPS.

Bad news: The first time I tested it, the game stopped responding when I tried to skip the cutscene halfway through playback (using the escape key). I tested it 3 more times and it worked perfectly afterwards. I'm not sure what happened the first time. Also, the game has to be set to run at 60 FPS. Otherwise, the video pauses intermittently during playback and just plain sucks.

So basically, this is potentially great news for people who've wanted to play through the game with the 60 FPS cutscenes. I think I may convert all of them to 60 FPS and see if I can clean the image quality up even more. I hope that one day, players can choose to run the game at 30 FPS and the cutscenes at 60 FPS (for an authentic SH2 experience). Anyone know if it's possible to program the game to run at 60 FPS but only during cutscene playback?

Polymega commented 6 years ago

Anyone know if it's possible to program the game to run at 60 FPS but only during cutscene playback?

This is the issue we ran into as discussed here: https://github.com/elishacloud/Silent-Hill-2-Enhancements/issues/13#issuecomment-407188237

I have been able to successfully convert the videos from 30 FPS to 60 FPS using a video editing program.

Not that you said you were, but if you don't mind me asking: Would you please not share your 60 FPS versions of these movie online? Since there are negative effects when playing the game at 30 FPS and videos at 60 it'll create a lot more support tickets from people who try to use these video files. This will cause headaches for us as it's something we haven't addressed/possibly fixed yet.

Also, as @angularGraphics mentioned, since we have the resources to be able to, it'd be preferable to use true PS2 source videos (60 FPS) when creating a "FMV Enhancement Pack 2.0" for the most visually accurate representation possible.

OregonPacifist commented 6 years ago

Has anyone created .bik files from the original PS2 version? I only tested with the “open.bik” file but was very impressed with the results, personally. I’m going to re-convert the file and clean it up to the best of my ability. The version I made as a test had the conversion software watermark in the video. I didn’t want to buy any software unless I knew it’d be worth it for SH2.

Polymega commented 6 years ago

This is from angular graphic's notes on the original FMV Enhancement Pack:


Silent Hill 2 [PC] FMV Widescreen Enhancement Pack v1.0 by NeoGAF's angular graphics


Users have figured out how to have Silent Hill 2 run at a 16:9 widescreen ratio by patching the game's executable with a new resolution and FoV, but unfortunately this makes the prerendered FMVs look stretched.

In my quest to re-encode them to an aspect ratio that will look right on widescreen monitors, I've discovered the PC version's FMVs suffer significantly in quality compared to the other versions:

  • PS2: PSS (MPEG2), 512x384 (wrong aspect ratio, it gets corrected during playback), 29.9x fps, interlaced

  • Xbox: SFD (MPEG1), 640x384, 29.9x fps, progressive. As far as I can tell these are the PS2 version's FMVs, deinterlaced and resized to the correct aspect ratio and thus they include additional compression artifacts. Furthermore the deinterlacing is not exactly the best it could be since there are ghosting artifacts.

  • PC: BINK, 640x384, 29.9x fps, progressive. These are the Xbox version's FMVs, re-encoded. Ewww. Even more compression artifacts!

  • Xbox 360 HD Collection: BINK, 1280x720 (wrong aspect ratio, the game displays them incorrectly stretched), 29.9x fps, progressive. These have more ghosting artifacts than the Xbox/PC version, so they likely are PS2 encodes, resized. In any case they are of worse quality compared to the PS2 assets carefully upscaled.

Likewise, regarding the audio quality, the FMVs that sound best are the PS2 ones. Basically every other version seems to be a re-encode (or re-re-encode) of PS2's assets.

Since I've gone to all this trouble to compare all versions, of course I decided to change my main source from the PC's terrible FMVs to the PS2 ones.

Using a bunch of avisynth plugins I've deinterlaced them and upscaled them to a resolution of 1280x to the best possible quality. Most of them have been touched up with mild de-haloing, noise reduction, antialiasing and sharpening filters before the upscaling process, mostly so that any unwanted artifacts don't get enhanced as well. In no way have I tampered with their colors, contrast and their overall look. In fact for a couple of clips that I thought the filters would do more harm than good, I disabled them. This has made them a bit softer, but it has improved their quality in other ways. Also this made them easier compressible by BINK, which was the process' final step.

In detail, there are four types of FMVs and all of them have been remastered, albeit in various ways: 1) Opening FMV, 2) Story FMVs, 3) Credit FMVs, 4) Trailer FMVs

1) For the Opening FMV, I decided to use "The Art of Silent Hill" DVD as the source for the video and one of the audio tracks, because it seems to be the best quality source available. For the other audio track, I used the one from the PS2. Some very minor denoising has been applied to the video (it is supposed to have a film grain effect).

2) For the Story FMVs, I used the PS2 version as the video and audio source, except for one FMV ("water"), where due to issues I had to use the second best quality source, the Xbox version. The FMVs of this category had the aforementioned filter enhancements applied to, some, of them.

3) For the Credit FMVs, I used the PS2 version for the video, but I didn't upscale them to 1280x in order to keep their size down. For about half of them, I've used the Silent Hill 2 Soundtrack CD as the audio source, so they sound as good as they possibly could. For those FMVs that I couldn't easily use the Soundtrack CD, I used the PS2 audio, which isn't bad at all.

4) For the two Silent Hill 3 and one Silent Hill 2 Trailer FMVs accessible through the menu, I used the "Lost Memories - The Art & Music of Silent Hill" and "The Art of Silent Hill" DVDs as a source. I didn't upscale those either. My encodes look significantly better than the ones shipped with the PC version, as those were full of interlacing artifacts.


Overall, I feel that the FMVs now look and sound as best as they could.. arguably better than they ever did.

Dedicated to: Team Silent

OregonPacifist commented 6 years ago

Ok, so the cutscene movies in the “Enhanced” pack were ripped from the original PS2 versions. That’s good because those are the ones I used to convert back to 60 FPS. I’m not sure if the colors/ contrast could be improved any more than they already are but I can give it a shot.

OregonPacifist commented 6 years ago

Here’s the 60 FPS version of the open.bik Enhanced file:

https://youtu.be/xs9_0RJs4SU

angularGraphics commented 6 years ago

I just randomly clicked at 02:00 in the above video and it's pretty jumpy the way James and Maria move.

This is not the way of doing it in my eyes. I will work with the source files and provide true(-er) 60 fps videos, if the game is made to properly handle them.

OregonPacifist commented 6 years ago

I noticed a little bit of jumpiness too in some spots, but I think that may be a byproduct of the software I used to convert the .bik to .m4v (VLC). I originally used another piece of software for the conversion and didn’t notice any jumpiness but it had a watermark that I could only remove if I paid $20 :( Still, it would be awesome to have the cutscenes at their original PS2 frame rate.

Polymega commented 6 years ago

Don't worry, if we find a way to have them play smoothly at 60 FPS, regardless if the player has the game running at 30/60/X, @angularGraphics expressed interest in revising their amazing work at 60 FPS this time.

but I think that may be a byproduct of the software I used to convert the .bik to .m4v (VLC).

Also, you wouldn't want to do this. M4V is a lossy codec and each time you convert/re-encode the files to another lossy format you are compressing/losing more quality. For example, when I made angular graphic's videos 16:9 friendly I did the following (this is an addendum to the "Read Me" file for said package):

NOTE: In this package angular graphic's videos have been re-rendered to fill a 16:9 aspect ratio, done by another party. Please read below.

angular graphic's Story FMVs (which play during gameplay) were saved at 1360 x 768 (which is ~16:10 aspect ratio) which results in black pillar boxes when played on a 16:9 (standard widescreen) resolution. angular made the videos this way so as not to a) distort the videos or b) crop the videos.

The 16:9 conversion process aims to remove the pillar boxes and re-save them at a universal widescreen resolution (16:9) of 1280 x 720.

Removing the pillar boxes from angular's videos already puts the videos at 1280 width. But to fit the videos to 720 height the videos would either need to be "squashed" by 6.2% (48 pixels) or cropped off 48 pixels vertically.

So as not to lose any image information from cropping, the videos were slightly squashed instead. While the difference in stretching is minor, the stretching is ever-so-slightly noticeable. This 16:9 edit of angular's work is for people who prefer not to see the black pillar boxes and are okay with slight vertical squashing of the videos.

For this 16:9 project angular's videos, which are easily the best versions of the game's FMVs, were converted to a loseless .bmp image sequence and re-sized to fill a 16:9 aspect ratio. The videos were then saved out as loseless .avi files then converted back to Bink (.bik) format for the game to read/play. The quality settings for the Bink conversion were set high to ensure that there was no noticeable image degradation from the re-render. This is also why the videos are larger in file size than angular's original files.

Lastly, the Opening and Credit FMVs, which were smaller in resolution than angular's Story FMVs, were also enlarged/re-sized to fill the 1280 x 720 resolution which is why they're significantly larger in file size in this package.

The SH2/SH3 bonus trailers remain fully untouched from angular's original edits.

Polymega commented 6 years ago

I will work with the source files and provide true(-er) 60 fps videos, if the game is made to properly handle them.

Also, @angularGraphics , please consider having options for your "2.0" work on these, if you make them. I'd want cropping over anything else, and would settle for pillarboxes. I don't want stretching at all and would keep using the "1.0" videos if stretching was the only option. (I made "1.0" 16:9 stretched videos for others who prefer them; definitely not for my own use.)

angularGraphics commented 6 years ago

We have talked about this and I remember, don't worry. A final crop and/or stretch step after everything else has already been done, is not difficult to do for an alt version of the pack.

Polymega commented 6 years ago

Much love to you, then. <3

OregonPacifist commented 6 years ago

I guess I'll leave the video adjustments to the pros, then :) I'm just anxious for those 60 FPS cut scenes lol

mirh commented 3 years ago

I'd like to underline a previous comment of mine for this issue https://github.com/elishacloud/Silent-Hill-2-Enhancements/issues/54#issuecomment-693442845 Avoiding to download 3GBs of poorly compressed video is possible.

Polymega commented 3 years ago

#54 (comment)

Has there been any more progress on reverse engineering the Bink 1 format and allowing other codecs to be wrapped/used in Bink's place?

Avoiding to download 3GBs of poorly compressed video is possible.

With the next update to the FMV Pack, story FMVs will be 1280x820 and the intro/ending FMVs will be 1280x720. I am currently using the higher end of Bink's recommended data rate for 720 video (using their specs for PS3/Wii at 220000), and the max value for bandwidth allocation at 64.

mirh commented 3 years ago

There's nothing really to RE, when the api has even official documentation... https://github.com/fromasmtodisasm/realistic_ai_mod/tree/master/Bin32/Sources/CryGame%20C++/Solution1/BinkSDK/htmlhelp

Polymega commented 3 years ago

Has someone made a tool with this documentation that allows the use of better compressible codecs in the Bink 1 shell? And Bink files that have multiple audio tracks stored in them are still called/play correctly?

elishacloud commented 3 years ago

I think the idea is that we compress the files using something completely different than Bink and then we add our own decoder into the game and intercept the Bink calls and feed the game the data it expects via the Bink APIs. Basically we replace Bink ourselves.

To do this we would need to build a shim that goes between the game and the videos and converts the calls on the fly.

mirh commented 3 years ago

Yup. And as Kostya said in my email exchange, audio is totally not an issue with this solution.

Btw, I mentioned shipping ffmpeg, but I suppose you could also just rely on system vfw/directshow/mf codecs for decoding.

mirh commented 2 years ago

BEHOLD PEOPLE. https://github.com/drdaxxy/bink2-libass/issues/1#issuecomment-1013764120