THPConv-Guide: Difference between revisions

From Super Mario Galaxy wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 22: Line 22:
[[File:THPConv-Guide_Fig-1.webp|right|thumb|Fig. 1 - Create temporal video]]
[[File:THPConv-Guide_Fig-1.webp|right|thumb|Fig. 1 - Create temporal video]]


<blockquote>
{{note |
All this information is extracted from the Wii SDK docs for THPConv.
* All this information is extracted from the Wii SDK docs for THPConv.
 
* SMG uses 59.94 fps and 640x368 video dimensions for all THP files in the <code>MovieData</code> folder. Use <code>path\to\ffmpeg.exe -i [THP video file]</code> to see it yourself.
SMG uses 59.94 fps and 640x368 video dimensions for all THP files in the <code>MovieData</code> folder. Use <code>path\to\ffmpeg.exe -i [THP video file]</code> to see it yourself.
* If you use different frame rates than 59.94 the video on SMG1 will play slower or faster but not at its "normal" speed.
 
If you use different frame rates than 59.94 the video on SMG1 will play slower or faster but not at its "normal" speed.
 
You can use different values for the width and height of the video, be sure they follow the rules said above and that the dimensions are a multiple of 16.
You can use different values for the width and height of the video, be sure they follow the rules said above and that the dimensions are a multiple of 16.
 
* To get a better video resolution on the final THP video you can use the following flags on the above command <code>-preset veryslow -b:v 21M</code> (file size will increase a lot as <code>-b:v</code> sets the bitrate of the output video). <code>21M</code> was selected because of the bitrates of the OG THP videos on the MovieData folder (you can select any value you want, <code>M</code> means megabyte).
To get a better video resolution on the final THP video you can use the following flags on the above command <code>-preset veryslow -b:v 21M</code> (file size will increase a lot as <code>-b:v</code> sets the bitrate of the output video). <code>21M</code> was selected because of the bitrates of the OG THP videos on the MovieData folder (you can select any value you want, <code>M</code> means megabyte).
}}
</blockquote>


Create a folder named <code>temp</code> in the same place the <code>[temp_video]</code> is and then type the following command (Fig. 2 and 3):
Create a folder named <code>temp</code> in the same place the <code>[temp_video]</code> is and then type the following command (Fig. 2 and 3):
Line 44: Line 40:
[[File:THPConv-Guide Fig-3.webp|right|thumb|Fig. 3 - Dump temporal video frames into folder]]
[[File:THPConv-Guide Fig-3.webp|right|thumb|Fig. 3 - Dump temporal video frames into folder]]


<blockquote>
{{ note |
JPG or JPEG can be used, the only restriction the THPConv docs say is that they need to be in the baseline DCT format (which ffmpeg automatically converts them to with the above command).
* JPG or JPEG can be used, the only restriction the THPConv docs say is that they need to be in the baseline DCT format (which ffmpeg automatically converts them to with the above command).
 
* The minimum frames a THP video can have without breaking the game is 21. Tested with <code>PrologueA.thp</code> in Riivolution.
The minimum frames a THP video can have without breaking the game is 21. Tested with <code>PrologueA.thp</code> in Riivolution.
* Very low width and height values for the THP video (16x16 for example) will allow to show blue rectangles on the screen when reproducing the associated cutscene. Tested it very little so I am unsure if this happens all the time.
 
* To get a video resolution similar to the [temp_video] on your THP video you can use the following flag on the above command <code>-q:v 1</code>
Very low width and height values for the THP video (16x16 for example) will allow to show blue rectangles on the screen when reproducing the associated cutscene. Tested it very little so I am unsure if this happens all the time.
}}
 
To get a video resolution similar to the [temp_video] on your THP video you can use the following flag on the above command <code>-q:v 1</code>
</blockquote>


Then, to get the audio part of the video execute (Fig. 4):
Then, to get the audio part of the video execute (Fig. 4):
Line 64: Line 57:
[[File:THPConv-Guide_Fig-4.webp|right|thumb|Fig. 4 - Create WAV audio file]]
[[File:THPConv-Guide_Fig-4.webp|right|thumb|Fig. 4 - Create WAV audio file]]


<blockquote>
{{ note |
WAV audios are the only audio input THPConv can process. Specifically non-compressed 16-bit PCM data ones.
* WAV audios are the only audio input THPConv can process. Specifically non-compressed 16-bit PCM data ones.
 
* WAV audios can be Mono or Stereo, they are both supported by THPConv.
WAV audios can be Mono or Stereo, they are both supported by THPConv.
* The <code>-ar 32000</code> sets the frequency of the WAV audio. 32000 Hz is needed for the audio in SMG1 since different values make the audio sound at a higher or lower pitch.
 
}}
The <code>-ar 32000</code> sets the frequency of the WAV audio. 32000 Hz is needed for the audio in SMG1 since different values make the audio sound at a higher or lower pitch.
</blockquote>


Finally, to get the THP converted file we do (Fig. 5):
Finally, to get the THP converted file we do (Fig. 5):
Line 78: Line 69:
[[File:THPConv-Guide_Fig-5.webp|right|thumb|Fig. 5 - Create THP file with THPConv]]
[[File:THPConv-Guide_Fig-5.webp|right|thumb|Fig. 5 - Create THP file with THPConv]]


<blockquote>
{{ note |
The <code>-j</code> flag is used to select the JPEG sequential frames that are going to be used in the THP video.
* The <code>-j</code> flag is used to select the JPEG sequential frames that are going to be used in the THP video.
 
* The <code>-s</code> flag is used to select the WAV audio to be used in the THP video (optional).
The <code>-s</code> flag is used to select the WAV audio to be used in the THP video (optional).
* The <code>-r</code> flag is used to set the frame rate of the THP video. If you want your video to reproduce normally on SMG1 use 59.94 as frame rate. If omitted THPConv will set the frame rate of the THP video to 29.97 fps.
 
* The <code>-d</code> flag is used to set the THP file creation path and name.
The <code>-r</code> flag is used to set the frame rate of the THP video. If you want your video to reproduce normally on SMG1 use 59.94 as frame rate. If omitted THPConv will set the frame rate of the THP video to 29.97 fps.
* The <code>-v</code> flag is used to print more info on the CMD when THPConv is converting the JPG frames and WAV audio into a THP video (optional).
 
* To check more info on the commands THPConv has, check its documentation (Wii SDK or [[THPConv | here]]).
The <code>-d</code> flag is used to set the THP file creation path and name.
}}
 
The <code>-v</code> flag is used to print more info on the CMD when THPConv is converting the JPG frames and WAV audio into a THP video (optional).
 
To check more info on the commands THPConv has, check its documentation (Wii SDK or [[THPConv | here]]).
</blockquote>


Now you can replace the THP file with the one you want from your SMG1 dump and test the video on game!
Now you can replace the THP file with the one you want from your SMG1 dump and test the video on game!


<blockquote>
{{ note |
You can use VLC Media Player to play/test THP videos as well as FFmpeg to convert THP videos to other video formats (you can't convert to THP with FFmpeg).
* You can use VLC Media Player to play/test THP videos as well as FFmpeg to convert THP videos to other video formats (you can't convert to THP with FFmpeg).
 
* When testing the THP video on console it is better to not use Riivolution but rather pack the THP into the WBFS file and run said WBFS in a USB Loader. Due to either Riivolution file copying velocity or how inefficient the THP processing algorhythm/video format is (or a combination of both) the video can't be reproduced at its normal speed when being replaced by Riivolution.
When testing the THP video on console it is better to not use Riivolution but rather pack the THP into the WBFS file and run said WBFS in a USB Loader. Due to either Riivolution file copying velocity or how inefficient the THP processing algorhythm/video format is (or a combination of both) the video can't be reproduced at its normal speed when being replaced by Riivolution.
}}
</blockquote>


''Thanks to Lord-Giganticus and EmilyTheDemon for their support during the guide!''
''Thanks to Lord-Giganticus and EmilyTheDemon for their support during the guide!''
Line 105: Line 90:


* [[THPConv | THPConv documentation]]
* [[THPConv | THPConv documentation]]
* [https://github.com/MasterofGalaxies/THPConv THPConv port to Linux]

Latest revision as of 17:21, 10 May 2024

This guide is created specifically to make THP videos for SMG1. Other games that support THP may have a different THP setup.

Required Tools

Steps

Open a CMD/Terminal in the same place the video you want to convert is and type the following command (Fig. 1):

path\to\ffmpeg.exe -i [input_video] -vf scale="[width]:[height]" -r [fps] [temp_video]

  • [input_video] is the video of your choice to convert. Can be any video format.
  • [width] is the width the [temp_video] will have. Cannot exceed 672 pixels.
  • [height] is the height the [temp_video] will have. There is no limit on this value.
  • [fps] are the frames per second the [temp_video] will have. Frame rates can be from 1.0 to 59.94.
Fig. 1 - Create temporal video
  • All this information is extracted from the Wii SDK docs for THPConv.
  • SMG uses 59.94 fps and 640x368 video dimensions for all THP files in the MovieData folder. Use path\to\ffmpeg.exe -i [THP video file] to see it yourself.
  • If you use different frame rates than 59.94 the video on SMG1 will play slower or faster but not at its "normal" speed.

You can use different values for the width and height of the video, be sure they follow the rules said above and that the dimensions are a multiple of 16.

  • To get a better video resolution on the final THP video you can use the following flags on the above command -preset veryslow -b:v 21M (file size will increase a lot as -b:v sets the bitrate of the output video). 21M was selected because of the bitrates of the OG THP videos on the MovieData folder (you can select any value you want, M means megabyte).

Create a folder named temp in the same place the [temp_video] is and then type the following command (Fig. 2 and 3):

path\to\ffmpeg.exe -i [temp_video] temp\output%03d.jpg

This will dump all the frames the [temp_video] has into JPG images.

Fig. 2 - Create temporal folder
Fig. 3 - Dump temporal video frames into folder
  • JPG or JPEG can be used, the only restriction the THPConv docs say is that they need to be in the baseline DCT format (which ffmpeg automatically converts them to with the above command).
  • The minimum frames a THP video can have without breaking the game is 21. Tested with PrologueA.thp in Riivolution.
  • Very low width and height values for the THP video (16x16 for example) will allow to show blue rectangles on the screen when reproducing the associated cutscene. Tested it very little so I am unsure if this happens all the time.
  • To get a video resolution similar to the [temp_video] on your THP video you can use the following flag on the above command -q:v 1

Then, to get the audio part of the video execute (Fig. 4):

path\to\ffmpeg.exe -i [temp_video] -acodec pcm_s16le -ar 32000 [WAV_audio].wav

  • [WAV_audio].wav is the name of the WAV audio file to use with THPConv.
This will convert the audio of the [temp_video] in a WAV audio using the pcm_s16le format.
Fig. 4 - Create WAV audio file
  • WAV audios are the only audio input THPConv can process. Specifically non-compressed 16-bit PCM data ones.
  • WAV audios can be Mono or Stereo, they are both supported by THPConv.
  • The -ar 32000 sets the frequency of the WAV audio. 32000 Hz is needed for the audio in SMG1 since different values make the audio sound at a higher or lower pitch.

Finally, to get the THP converted file we do (Fig. 5):

path\to\THPConv.exe -j temp\output*.jpg -s [WAV_audio].wav -r 59.94 -d [Output THP].thp -v

Fig. 5 - Create THP file with THPConv
  • The -j flag is used to select the JPEG sequential frames that are going to be used in the THP video.
  • The -s flag is used to select the WAV audio to be used in the THP video (optional).
  • The -r flag is used to set the frame rate of the THP video. If you want your video to reproduce normally on SMG1 use 59.94 as frame rate. If omitted THPConv will set the frame rate of the THP video to 29.97 fps.
  • The -d flag is used to set the THP file creation path and name.
  • The -v flag is used to print more info on the CMD when THPConv is converting the JPG frames and WAV audio into a THP video (optional).
  • To check more info on the commands THPConv has, check its documentation (Wii SDK or here).

Now you can replace the THP file with the one you want from your SMG1 dump and test the video on game!

  • You can use VLC Media Player to play/test THP videos as well as FFmpeg to convert THP videos to other video formats (you can't convert to THP with FFmpeg).
  • When testing the THP video on console it is better to not use Riivolution but rather pack the THP into the WBFS file and run said WBFS in a USB Loader. Due to either Riivolution file copying velocity or how inefficient the THP processing algorhythm/video format is (or a combination of both) the video can't be reproduced at its normal speed when being replaced by Riivolution.

Thanks to Lord-Giganticus and EmilyTheDemon for their support during the guide!

See also