Skip to content

Commit

Permalink
Merge pull request #2 from jonko0493/FixLongVideoBug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Giganticus authored Mar 3, 2022
2 parents 58dd6be + 7d152d7 commit 1022a62
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 23 deletions.
4 changes: 2 additions & 2 deletions THP-Converter-CS-CLI/Classes/MP4Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Convert()
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = $"/c ffmpeg.exe -i video.mp4 -r {Rate} -vf scale={Width}:{Height} temp\\frame%03d.jpg"
Arguments = $"/c ffmpeg.exe -i video.mp4 -r {Rate} -vf scale={Width}:{Height} -qscale:v 2 temp\\frame%05d.jpg"
}).WaitForExit();
File.Delete("ffmpeg.exe");
if (UseAudio)
Expand All @@ -71,7 +71,7 @@ public void Convert()
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = UseAudio ? $"/c thpconv.exe -j temp/*.jpg -r {Rate} -s temp.wav -d output.thp" : $"/c thpconv.exe -j temp/*.jpg -r {Rate} -d output.thp"
Arguments = $"/c thpconv.exe -j temp/*.jpg -r {Rate}{(UseAudio ? " -s temp.wav" : "")} -d output.thp"
}).WaitForExit();
File.Move("output.thp", OutFile.FullName);
Console.WriteLine($"Converted {InFile.Name} to {OutFile.Name}");
Expand Down
54 changes: 38 additions & 16 deletions THP-Conveter-CS/GUI/MP4.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions THP-Conveter-CS/GUI/MP4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public MP4()
{
InitializeComponent();
label1.Hide();
label2.Hide();
button2.Hide();
textBox1.Hide();
label3.Hide();
Expand All @@ -43,6 +44,7 @@ private void button1_Click(object sender, EventArgs e)
Properties.Settings.Default.mp4_video = open.FileName;
Properties.Settings.Default.Save();
label1.Show();
label2.Show();
button2.Show();
textBox1.Show();
label3.Show();
Expand Down Expand Up @@ -98,8 +100,12 @@ private void button2_Click(object sender, EventArgs e)
Classes.Manager manager = new();
manager.ExtractResource("THPConv.exe", Properties.Resources.THPConv);
manager.ExtractResource("dsptool.dll", Properties.Resources.dsptool);
string width = ((string)VideoSizeComboBox.SelectedItem)[0..((string)VideoSizeComboBox.SelectedItem).IndexOf('x')],
height = ((string)VideoSizeComboBox.SelectedItem)[(((string)VideoSizeComboBox.SelectedItem).IndexOf('x') + 1)..];
string scaleParameter = "";
if ((string)VideoSizeComboBox.SelectedItem != "Original")
{
scaleParameter = $" -vf scale={((string)VideoSizeComboBox.SelectedItem)[0..((string)VideoSizeComboBox.SelectedItem).IndexOf('x')]}:"
+ ((string)VideoSizeComboBox.SelectedItem)[(((string)VideoSizeComboBox.SelectedItem).IndexOf('x') + 1)..];
}
Directory.CreateDirectory("temp");
File.Copy(inputFile, "video.mp4");
using (Process process = new())
Expand All @@ -110,7 +116,7 @@ private void button2_Click(object sender, EventArgs e)
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = $"/c ffmpeg.exe -i video.mp4 -r {rate} -vf scale={width}:{height} temp\\frame%03d.jpg"
Arguments = $"/c ffmpeg.exe -i video.mp4 -r {rate}{scaleParameter} -qscale:v 2 temp\\frame%05d.jpg"
};
process.StartInfo = startInfo;
process.Start();
Expand All @@ -135,7 +141,7 @@ private void button2_Click(object sender, EventArgs e)
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = UseAudioCheckBox.Checked ? $"/c thpconv.exe -j temp/*.jpg -r {rate} -s temp.wav -d output.thp" : $"/c thpconv.exe -j temp/*.jpg -r {rate} -d output.thp"
Arguments = $"/c thpconv.exe -j temp/*.jpg -r {rate}{(UseAudioCheckBox.Checked ? " -s temp.wav" : "")} -d output.thp"
};
process.Start();
process.WaitForExit();
Expand Down
2 changes: 1 addition & 1 deletion THP_Converter_PY/MP4toTHP.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main():
raise FileNotFoundError
if os.path.isfile(out_file) == True:
raise FileExistsError
os.system('cmd /c ffmpeg -i "'+file+'" -r '+str(rate)+' frame%03d.jpg')
os.system('cmd /c ffmpeg -i "'+file+'" -r '+str(rate)+' -qscale:v 2 frame%05d.jpg')
os.system('cmd /c thpconv -j *.jpg -d "'+out_file+'"')
os.system('cmd /c del /f *.jpg')
print("Complete.")
Expand Down

0 comments on commit 1022a62

Please sign in to comment.