Skip to content

Commit

Permalink
Easier UI and explicit commandline args for picking video and audio c…
Browse files Browse the repository at this point in the history
…odecs for ffmpeg
  • Loading branch information
maxim-zhao committed Jun 30, 2024
1 parent 90a9a37 commit 7228b8b
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 217 deletions.
14 changes: 10 additions & 4 deletions LibSidWiz/Outputs/FfmpegOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ public class FfmpegOutput : IGraphicsOutput
private readonly Process _process;
private readonly BinaryWriter _writer;

public FfmpegOutput(string pathToExe, string filename, int width, int height, int fps, string extraArgs, string masterAudioFilename)
public FfmpegOutput(string pathToExe, string filename, int width, int height, int fps, string extraArgs, string masterAudioFilename, string videoCodec, string audioCodec)
{
// Build the FFMPEG commandline
var arguments = "-y -hide_banner"; // Overwrite, don't show banner at startup

// Audio part
// Audio input
if (File.Exists(masterAudioFilename))
{
arguments += $" -i \"{masterAudioFilename}\"";
}

// Video part
arguments += $" -f rawvideo -pixel_format bgr0 -video_size {width}x{height} -framerate {fps} -i pipe: -movflags +faststart";
// Video input
arguments += $" -f rawvideo -pixel_format bgr0 -video_size {width}x{height} -framerate {fps} -i pipe:";

// Audio output
arguments += $" -codec:a {audioCodec}";

// Video output
arguments += $" -codec:v {videoCodec} -movflags +faststart";

// Extra args
arguments += $" {extraArgs} \"{filename}\"";
Expand Down
154 changes: 101 additions & 53 deletions SidWiz/SidWizPlusGUI.Designer.cs

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

12 changes: 10 additions & 2 deletions SidWiz/SidWizPlusGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private class Settings
public Color BackgroundColor { get; set; } = Color.Black;
public string BackgroundImageFilename { get; set; }
public PreviewSettings Preview { get; } = new() {Enabled = true, Frameskip = 1};
public EncodeSettings EncodeVideo { get; } = new() {Enabled = false};
public EncodeSettings EncodeVideo { get; } = new() {Enabled = false, VideoCodec = "h264", AudioCodec = "aac"};
public int RenderThreads { get; set; } = Environment.ProcessorCount;

public MasterAudioSettings MasterAudio { get; } = new() {IsAutomatic = true, ApplyReplayGain = true};
Expand All @@ -110,6 +110,8 @@ public class MasterAudioSettings
public class EncodeSettings
{
public bool Enabled { get; set; }
public string VideoCodec { get; set; }
public string AudioCodec { get; set; }
}

public class PreviewSettings
Expand Down Expand Up @@ -138,6 +140,8 @@ public void FromControls(SidWizPlusGui form)
Preview.Enabled = form.PreviewCheckBox.Checked;
Preview.Frameskip = (int) form.PreviewFrameskip.Value;
EncodeVideo.Enabled = form.EncodeCheckBox.Checked;
EncodeVideo.VideoCodec = form.VideoCodec.Text;
EncodeVideo.AudioCodec = form.AudioCodec.Text;
MasterAudio.IsAutomatic = form.AutogenerateMasterMix.Checked;
MasterAudio.ApplyReplayGain = form.MasterMixReplayGain.Checked;
MasterAudio.Path = form.MasterAudioPath.Text;
Expand All @@ -161,6 +165,8 @@ public void ToControls(SidWizPlusGui form)
form.PreviewCheckBox.Checked = Preview.Enabled;
form.PreviewFrameskip.Value = Preview.Frameskip;
form.EncodeCheckBox.Checked = EncodeVideo.Enabled;
form.VideoCodec.Text = EncodeVideo.VideoCodec;
form.AudioCodec.Text = EncodeVideo.AudioCodec;
form.AutogenerateMasterMix.Checked = MasterAudio.IsAutomatic;
form.MasterMixReplayGain.Checked = MasterAudio.ApplyReplayGain;
form.MasterAudioPath.Text = MasterAudio.Path;
Expand Down Expand Up @@ -809,7 +815,9 @@ private void RenderButton_Click(object sender, EventArgs e)
_settings.Height,
_settings.FrameRate,
_programSettings.FfmpegExtraParameters,
_settings.MasterAudio.Path));
_settings.MasterAudio.Path,
_settings.EncodeVideo.VideoCodec,
_settings.EncodeVideo.AudioCodec));
}
}

Expand Down
Loading

0 comments on commit 7228b8b

Please sign in to comment.