Copy Link
Add to Bookmark
Report

How to encode quality Playstation video

PS_2's profile picture
Published in 
Playstation
 · 5 years ago

How to encode quality Playstation 1 video


Author: Michael Sabin
Source: http://jpsxdec.blogspot.com/2008/09/how-to-encode-quality-playstation-1.html

Recently I've run across a couple of groups trying to replace the video of a Playstation 1 game.
As we have to do the same thing with S.E. Lain, I thought I would share some insight on how it might be done with the highest quality output.

Since there are many things that go into encoding mpeg type images (DCT + quantization being the least of it), that task is best left to programs that know how to do it well, such as ffmpeg. It also allows you to tweak those options, and use its advanced features to get the best results.

So here is how you could do it, broken down into 6 ridiculously complicated steps.

1. Convert your video into yuv4mpeg2 (http://wiki.multimedia.cx/index.php?title=YUV4MPEG2) video (or perhaps an AVI with a yuv codec), but using the PSX specific rgb->yuv conversion (http://jpsxdec.blogspot.com/2008/01/psx-yuv-to-yuv4mpeg2.html)

2. Feed the yuv video into ffmpeg at a mpeg1 allowed fps and create a mpeg1 movie with only I-frames (http://www.cs.cf.ac.uk/Dave/Multimedia/node248.html) (-intra). This should be done at a variety of different quality levels (-qscale from 1 to n).

3. Parse the I-frames out of the movie, and parse each frame's macro-blocks

4. Convert the mpeg1 VLCs (http://en.wikipedia.org/wiki/Variable-length_code) to PSX VLCs

5. Do this for every mpeg1 quality and pick the one that fits best within the amount of space available to each frame

6. Multiplex the frames and construct all the sectors, including the correct frame headers and the sectors' ECE/EDC codes


If the new video is mostly just the old video with some changes (e.g. subtitles) then quality can
improved tremendously with this variation.

5. Use some method to determine which macro blocks to replace (manually picking them, or performing a diff on lossless video data, or a fuzzy diff on lossy video data)

6. Only replace those macro blocks with new ones of the same qscale

7. If the replaced data makes the frame too big, then either replace the entire frame with an ffmpeg created frame that will fit (qscale will probably be bigger), or remove some quality in the frame to make it smaller

8. Multiplex the frames and construct all the sectors


Alternatively have ffmpeg write an AVI using MJPG codec, then parse the JPEG frames and convert the JPEG VLCs to PSX VLCs (I'm not sure how to get ffmpeg to produce quality variations with the MJPG codec).

Encoding video by the steps above will likely have better results than if you used Sony's official PS1 SDK video encoder (and will also reduce the likelihood of serious legal trouble and C&D letters).

Here is a possible ffmpeg command-line for step 2 above.

 
ffmpeg -i source.y4m -vcodec mpeg1video -r 30 -qscale # \
-intra -dc 10 -dct faan -vstats_file qscale#.log \
-debug dct_coeff out-qscale#.mpg

-i source.y4m : yuv4mpeg2 input file
-vcodec mpeg1video : write mpeg1
-r 30 : use 30 frames/sec
(just to use something
compatible with mpeg1)
-qscale # : chosen qusale
-intra : only write I-frames
-dc 10 : use 10 bits of precision
for the DC values?
(not sure if this is helpful)
-dct faan : use a floating-point
discrete-cosine-transform
for best quality
-vstats_file qscale#.log : write a log of useful info
-debug dct_coeff : forgot what this does
out-qscale#.mpg : output file

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT