Skip to content

Commit 9329934

Browse files
committed
Thwimp v1.2 Release!
- Changed Rip behavior from CLI_MODE, so that, when ripping assets from THPs with audio, that the MP4 and Wav files have the same file as the pathOverride variable (just different extensions) - Fixed a grammatical typo in HackIniFile's error when it can't find the [Others] tag in the 1st INI file
1 parent 4f173c3 commit 9329934

File tree

1 file changed

+102
-93
lines changed

1 file changed

+102
-93
lines changed

Thwimp/Main.vb

Lines changed: 102 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,14 +2120,23 @@ Public Class Main
21202120
End If
21212121

21222122
'ffmpeg.exe -y -i video.thp -vn -ss audio_Start -to audio_End "C:\OutputDir\file.wav"
2123+
Dim wav As String = "" 'Output file for wav
21232124

21242125
'"C:\FFMPegPath\FFMPEG.exe"
21252126
cmd = strQUOT & txtFFMPEG.Text & strPATHSEP & exeFMPeg & strQUOT
21262127
'-y -i "C:\PathToTHP\DIRtoTHP\file.thp" -vn -ss audio_Start -to audio_End output_file
21272128
'Note ToString("G9") format is the recommended one for "RoundTripping" a single
21282129
cmd &= " -y -i " & strQUOT & inFile & strQUOT & " -vn -ss " & _aStart.ToString("G9") & " -to " & _aEnd.ToString("G9") & " "
2129-
'"C:\OutputDir\file.wav"
2130-
cmd &= strQUOT & outPath & FileAndExt(inFile).Replace(".thp", ".wav") & strQUOT
2130+
2131+
'If not override flag, then replace inFile.thp with .wav; else replace outFIle.mp4 with .wav
2132+
If pathOverride = "" Then
2133+
'"C:\OutputDir\file.wav"
2134+
wav = strQUOT & outPath & FileAndExt(inFile).Replace(".thp", ".wav") & strQUOT
2135+
Else
2136+
'file.wav
2137+
wav = strQUOT & outPath & FileAndExt(outFile).Replace(".mp4", ".wav") & strQUOT
2138+
End If
2139+
cmd &= wav
21312140

21322141
'Run the cmd
21332142
'startInfo.FileName = cmd
@@ -2140,104 +2149,104 @@ Public Class Main
21402149
UpdateProg_Cur(CurPrg, "Video does NOT have an audio stream!", True, False)
21412150
CurPrg(0) += 1
21422151
End If
2143-
UpdateProg_Cur(CurPrg, "Audio stream extraction done!", False, True)
2152+
UpdateProg_Cur(CurPrg, "Audio stream extraction done!", False, True)
21442153

2145-
'Step 4: If ripping dummy ctrl frames, convert the cropped MP4 file (cropped to the ctrl area) to bmp frames, keep only 1st frame for each multiplicity
2146-
CurPrg(0) = 0
2147-
TtlPrg(0) += 1
2148-
UpdateProg_Ttl(TtlPrg, "Step 4: If ripping dummy ctrl frames, convert the cropped MP4 file (cropped to the ctrl area) to bmp frames, keep only 1st frame for each multiplicity.")
2149-
If type = True Then
2150-
Dim m As Byte = TryParseErr_Byte(txtVM_M.Text) '0-based multiplicity value
2151-
m -= 1
2152-
2153-
'If ripping dummy ctrl frames.
2154-
'Convert the cropped MP4 file (cropped to the ctrl area) to bmp frames ("dummyTemp_%0Nd.bmp"),
2155-
'Keep only 1st frame for each multiplicty, rename to "dummy_N.bmp", delete excess frames
2156-
2157-
'Set max current progress to 2 + # of mults
2158-
CurPrg(1) = 2 + m
2159-
Text = "Video HAS dummy frames!" & strNL & "Ripping all bmp frames..."
2160-
UpdateProg_Cur(CurPrg, Text, True, False)
2154+
'Step 4: If ripping dummy ctrl frames, convert the cropped MP4 file (cropped to the ctrl area) to bmp frames, keep only 1st frame for each multiplicity
2155+
CurPrg(0) = 0
2156+
TtlPrg(0) += 1
2157+
UpdateProg_Ttl(TtlPrg, "Step 4: If ripping dummy ctrl frames, convert the cropped MP4 file (cropped to the ctrl area) to bmp frames, keep only 1st frame for each multiplicity.")
2158+
If type = True Then
2159+
Dim m As Byte = TryParseErr_Byte(txtVM_M.Text) '0-based multiplicity value
2160+
m -= 1
2161+
2162+
'If ripping dummy ctrl frames.
2163+
'Convert the cropped MP4 file (cropped to the ctrl area) to bmp frames ("dummyTemp_%0Nd.bmp"),
2164+
'Keep only 1st frame for each multiplicty, rename to "dummy_N.bmp", delete excess frames
2165+
2166+
'Set max current progress to 2 + # of mults
2167+
CurPrg(1) = 2 + m
2168+
Text = "Video HAS dummy frames!" & strNL & "Ripping all bmp frames..."
2169+
UpdateProg_Cur(CurPrg, Text, True, False)
2170+
2171+
'"C:\FFMPegPath\FFMPEG.exe" -y
2172+
cmd = strQUOT & txtFFMPEG.Text & strPATHSEP & exeFMPeg & strQUOT & " -y "
2173+
2174+
'Output ctrl MP4 to .bmp frames
2175+
Dim d As String = "" 'Printf digit formatter thingy (pad to N digits)
2176+
Dim dgs As UShort = 0 'Amount of digits for printf formatter thingy
2177+
dgs = TryParseErr_UShort(txtVF_T.Text.Length) 'Set digits to the amount of digits for the total amount of frames in the video
2178+
d = "%0" & dgs.ToString() & "d" 'Set the printf digit formatter to "dgs" digits
2179+
cmd &= "-i " & strQUOT & outFile & strQUOT '-i "C:\OutputDir\file.mp4"
2180+
2181+
'"C:\OutputDir\dummyTemp_%0Nd.bmp"
2182+
file = strQUOT & FileDir(outFile) & "dummyTemp_" & d & ".bmp" & strQUOT
2183+
cmd &= " " & file
21612184

2162-
'"C:\FFMPegPath\FFMPEG.exe" -y
2163-
cmd = strQUOT & txtFFMPEG.Text & strPATHSEP & exeFMPeg & strQUOT & " -y "
2185+
'Run cmd
2186+
'startInfo.FileName = cmd
2187+
'Shell.StartInfo = startInfo
2188+
'Shell.Start()
2189+
'Shell.WaitForExit()
2190+
RunProcess(cmd)
2191+
UpdateProg_Cur(CurPrg, "All BMP frames ripped!", False, True)
2192+
UpdateProg_Cur(CurPrg, "Finding and keeping appropriate BMP frames...")
2193+
2194+
'Rename the appropriate frames to "dummy_N.bmp", remove the others
2195+
Dim i As Byte = 0 'Generic iterator
2196+
Dim j As UShort = 0 'Frame value
2197+
Dim frames As UShort = TryParseErr_UShort(txtVF_S.Text) 'The amount of frames per subvideo
2198+
2199+
'Iterate through the mults (0-based)
2200+
For i = 0 To m Step 1
2201+
CurPrg(0) += 1 'Increment current prog foreach mult
2202+
Text = "Mult " & (i + 1).ToString() 'Log "Mult M"
2203+
UpdateProg_Cur(CurPrg, Text)
2204+
2205+
j = i * frames 'Frame ID = multiplicity ID * amount of frames. This gets 1st frame for each multplicity.
2206+
j += 1 'Make FrameID 1-based
2207+
d = "_" & j.ToString(StrDup(dgs, "0")) & ".bmp" 'Set d as the frame ID string "_%0Nd.bmp"
2208+
file = "dummy_" & (i + 1).ToString() & ".bmp" 'File = "dummy_N.bmp"
2209+
2210+
'Move file "C:\OutputDir\dummyTemp_ID.bmp" to "C:\OutputDir\dummy_N.bmp"
2211+
file = FileDir(outFile) & FileAndExt(file) 'File = "C:\OutputDir\dummy_N.bmp"
2212+
file2 = FileDir(outFile) & "dummyTemp" & d 'File2 = "C:\OutputDir\dummyTemp_ID.bmp"
2213+
My.Computer.FileSystem.MoveFile(file2, file, True)
2214+
Next i
21642215

2165-
'Output ctrl MP4 to .bmp frames
2166-
Dim d As String = "" 'Printf digit formatter thingy (pad to N digits)
2167-
Dim dgs As UShort = 0 'Amount of digits for printf formatter thingy
2168-
dgs = TryParseErr_UShort(txtVF_T.Text.Length) 'Set digits to the amount of digits for the total amount of frames in the video
2169-
d = "%0" & dgs.ToString() & "d" 'Set the printf digit formatter to "dgs" digits
2170-
cmd &= "-i " & strQUOT & outFile & strQUOT '-i "C:\OutputDir\file.mp4"
2216+
CurPrg(0) = CurPrg(1)
2217+
UpdateProg_Cur(CurPrg, "All appropriate BMP frames found and kept!", False, True)
21712218

2172-
'"C:\OutputDir\dummyTemp_%0Nd.bmp"
2173-
file = strQUOT & FileDir(outFile) & "dummyTemp_" & d & ".bmp" & strQUOT
2174-
cmd &= " " & file
2219+
'Step 5: Cleanup temporary files (Delete all extra "dummyTemp_%0Nd.bmp" files)
2220+
TtlPrg(0) += 1
2221+
CurPrg(0) = 0
2222+
CurPrg(1) = 1
2223+
UpdateProg_Ttl(TtlPrg, "Step 5: Cleanup temporary files")
2224+
UpdateProg_Cur(CurPrg, "", True, False)
2225+
file = FileDir(outFile) 'file = C:\WorkingDir
2226+
file2 = "dummyTemp*.bmp" 'file2 = dummyTemp*.bmp
2227+
DeleteFilesFromFolder(file, file2, True, "Cleaning up files...", True, False) 'Delete files (with logging)
2228+
Else
2229+
CurPrg(1) = 1
2230+
Text = "Video does NOT have dummy frames!" & strNL
2231+
UpdateProg_Cur(CurPrg, Text, True, False)
2232+
CurPrg(0) += 1
2233+
UpdateProg_Cur(CurPrg, "Dummy frame extraction done!", False, True)
21752234

2176-
'Run cmd
2177-
'startInfo.FileName = cmd
2178-
'Shell.StartInfo = startInfo
2179-
'Shell.Start()
2180-
'Shell.WaitForExit()
2181-
RunProcess(cmd)
2182-
UpdateProg_Cur(CurPrg, "All BMP frames ripped!", False, True)
2183-
UpdateProg_Cur(CurPrg, "Finding and keeping appropriate BMP frames...")
2184-
2185-
'Rename the appropriate frames to "dummy_N.bmp", remove the others
2186-
Dim i As Byte = 0 'Generic iterator
2187-
Dim j As UShort = 0 'Frame value
2188-
Dim frames As UShort = TryParseErr_UShort(txtVF_S.Text) 'The amount of frames per subvideo
2189-
2190-
'Iterate through the mults (0-based)
2191-
For i = 0 To m Step 1
2192-
CurPrg(0) += 1 'Increment current prog foreach mult
2193-
Text = "Mult " & (i + 1).ToString() 'Log "Mult M"
2194-
UpdateProg_Cur(CurPrg, Text)
2195-
2196-
j = i * frames 'Frame ID = multiplicity ID * amount of frames. This gets 1st frame for each multplicity.
2197-
j += 1 'Make FrameID 1-based
2198-
d = "_" & j.ToString(StrDup(dgs, "0")) & ".bmp" 'Set d as the frame ID string "_%0Nd.bmp"
2199-
file = "dummy_" & (i + 1).ToString() & ".bmp" 'File = "dummy_N.bmp"
2200-
2201-
'Move file "C:\OutputDir\dummyTemp_ID.bmp" to "C:\OutputDir\dummy_N.bmp"
2202-
file = FileDir(outFile) & FileAndExt(file) 'File = "C:\OutputDir\dummy_N.bmp"
2203-
file2 = FileDir(outFile) & "dummyTemp" & d 'File2 = "C:\OutputDir\dummyTemp_ID.bmp"
2204-
My.Computer.FileSystem.MoveFile(file2, file, True)
2205-
Next i
2235+
TtlPrg(0) += 1
2236+
UpdateProg_Ttl(TtlPrg, "Step 5: Cleanup temporary files")
2237+
End If
22062238

2239+
'Delete temp.mp4
2240+
DeleteFilesFromFolder(FileDir(outFile), "temp.mp4")
2241+
TtlPrg(0) = TtlPrg(1)
22072242
CurPrg(0) = CurPrg(1)
2208-
UpdateProg_Cur(CurPrg, "All appropriate BMP frames found and kept!", False, True)
2209-
2210-
'Step 5: Cleanup temporary files (Delete all extra "dummyTemp_%0Nd.bmp" files)
2211-
TtlPrg(0) += 1
2212-
CurPrg(0) = 0
2213-
CurPrg(1) = 1
2214-
UpdateProg_Ttl(TtlPrg, "Step 5: Cleanup temporary files")
2215-
UpdateProg_Cur(CurPrg, "", True, False)
2216-
file = FileDir(outFile) 'file = C:\WorkingDir
2217-
file2 = "dummyTemp*.bmp" 'file2 = dummyTemp*.bmp
2218-
DeleteFilesFromFolder(file, file2, True, "Cleaning up files...", True, False) 'Delete files (with logging)
2219-
Else
2220-
CurPrg(1) = 1
2221-
Text = "Video does NOT have dummy frames!" & strNL
2222-
UpdateProg_Cur(CurPrg, Text, True, False)
2223-
CurPrg(0) += 1
2224-
UpdateProg_Cur(CurPrg, "Dummy frame extraction done!", False, True)
2225-
2226-
TtlPrg(0) += 1
2227-
UpdateProg_Ttl(TtlPrg, "Step 5: Cleanup temporary files")
2228-
End If
2229-
2230-
'Delete temp.mp4
2231-
DeleteFilesFromFolder(FileDir(outFile), "temp.mp4")
2232-
TtlPrg(0) = TtlPrg(1)
2233-
CurPrg(0) = CurPrg(1)
2234-
UpdateProg_Ttl(TtlPrg, "Done!")
2235-
UpdateProg_Cur(CurPrg, "Cleanup done!", True, True)
2243+
UpdateProg_Ttl(TtlPrg, "Done!")
2244+
UpdateProg_Cur(CurPrg, "Cleanup done!", True, True)
22362245

2237-
'Thwimp kicks dat Koopa shell away!
2238-
'Shell.Close()
2239-
If chkAudio.Checked Then My.Computer.Audio.Play(My.Resources.success, AudioPlayMode.Background)
2240-
Log_MsgBox(Nothing, "Video ripped!", MsgBoxStyle.Information, "Success!", True)
2246+
'Thwimp kicks dat Koopa shell away!
2247+
'Shell.Close()
2248+
If chkAudio.Checked Then My.Computer.Audio.Play(My.Resources.success, AudioPlayMode.Background)
2249+
Log_MsgBox(Nothing, "Video ripped!", MsgBoxStyle.Information, "Success!", True)
22412250
Catch ex As Exception
22422251
Log_MsgBox(ex, ex.Message, MsgBoxStyle.Critical, "Error during ripping!", True)
22432252
End Try
@@ -4646,7 +4655,7 @@ Public Class Main
46464655
'Close any lingering streams
46474656
KillStream(xrINIData)
46484657
KillStream(xwINIData, False, iViewINI2Temp)
4649-
Log_MsgBox(ex, ex.Message, MsgBoxStyle.Critical, "Error finding, copying, and/or hacking INI Irfanview INI file!", True)
4658+
Log_MsgBox(ex, ex.Message, MsgBoxStyle.Critical, "Error finding, copying, and/or hacking Irfanview INI file!", True)
46504659
success = False
46514660
End Try
46524661

0 commit comments

Comments
 (0)