1
0
mirror of https://github.com/SirusDoma/VoxCharger.git synced 2024-11-27 17:00:51 +01:00
VoxCharger/Sources/Encoders/S3VTool.cs
CXO2 b8f49e3e2d Update 0.9.12c
- Fix naming and other code style issues
- Fix `float` and `double` parsing issue when current System Culture comma separator is not `.` - This fixes issue when parsing BPM and other floating numbers.
- Fix song selection when the program doesn't support the latest datecode in the future - It will disable Game Version and Infinite Version selection.
- Replaced ancient `FolderBrowserDialog` with `CommonFileDialog`
- Update default GameVersion and BackgroundId to latest version
- Implement Radar information in `LevelEditorForm`
- Implement built-in 2DX Encoder
- Start Offset / TimeStamp and Fader effect for audio preview is now supported
- Audio preview files is no longer divided into multiple files by default when audio files are unique. It still possible to specify unique preview via `LevelEditorForm`
- Implement advanced configuration when importing .ksh chart
- Add draft codes for Effect Mapping configurations and S3V support
- Other Bugfixes and QoL improvements
2023-01-06 20:59:21 +07:00

54 lines
2.4 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
namespace VoxCharger
{
public static class S3VTool
{
public static string ConverterFileName { get; set; } = "ffmpeg.exe";
public static void Convert(string inputFileName, string outputFileName, AudioImportOptions opt = null)
{
opt = opt ?? AudioImportOptions.Default;
if (!File.Exists(ConverterFileName))
throw new FileNotFoundException($"{ConverterFileName} not found", ConverterFileName);
/*
* TODO: DO NOT USE! Original .s3v (.asf) file seems encoded by Windows Media Audio Pro 10 encoder with close to Lossless quality.
* FFMPEG doesn't support this, and thus, this will generate non-working audio file for the game
*
* Format: 256000 Bit Rate with 44100 Sample Rate 24 Bit depth @ 2 Channels
*/
string previewArgs = "";
if (opt.IsPreview)
previewArgs = $"-ss {opt.PreviewOffset / 60:00}:{opt.PreviewOffset % 60:00} -t 10 -af afade=t=in:st={opt.PreviewOffset}:d=1,afade=t=out:st={opt.PreviewOffset + 9}:d=1";
string args = $"-y -i \"{inputFileName}\" {previewArgs} -maxrate 297k -minrate 297k -bufsize 297 -vb 280k -ab 380k -ac 2 -ar 44100 -f asf \"{outputFileName}\"";
var info = new ProcessStartInfo()
{
FileName = ConverterFileName,
Arguments = args,
WorkingDirectory = Environment.CurrentDirectory,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
using (var process = Process.Start(info))
{
process.WaitForExit();
if (process.ExitCode != 0)
{
int exitCode = process.ExitCode;
string stdout = (process.StandardOutput.ReadToEnd() + ' ' + process.StandardError.ReadToEnd().Trim()).Trim();
if (string.IsNullOrEmpty(stdout))
stdout = "Unknown error.";
throw new ApplicationException($"{Path.GetFileName(ConverterFileName)} execution failed.\n({exitCode}): {stdout}");
}
}
}
}
}