ffmpeg writer:

- make all formats editable (only custom is saved tho)
- deduce extension (since -f is required)
- restore ffv1
- fix #1325
This commit is contained in:
feos 2018-09-16 00:31:09 +03:00
parent b83c99c857
commit 0869c4b31c
3 changed files with 149 additions and 135 deletions

View File

@ -308,7 +308,7 @@ namespace BizHawk.Client.EmuHawk
public string DesiredExtension() public string DesiredExtension()
{ {
// this needs to interface with the codec token // this needs to interface with the codec token
return _token.Defaultext; return _token.Extension;
} }
public void SetDefaultVideoCodecToken() public void SetDefaultVideoCodecToken()

View File

@ -28,133 +28,132 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox(); this.listBox1 = new System.Windows.Forms.ListBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(5, 5); this.label1.Location = new System.Drawing.Point(5, 5);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13); this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "Formats:"; this.label1.Text = "Formats:";
// //
// listBox1 // listBox1
// //
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true; this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(5, 23); this.listBox1.Location = new System.Drawing.Point(5, 23);
this.listBox1.Name = "listBox1"; this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(275, 147); this.listBox1.Size = new System.Drawing.Size(275, 160);
this.listBox1.TabIndex = 1; this.listBox1.TabIndex = 1;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged); this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged);
// //
// label2 // label2
// //
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 176); this.label2.Location = new System.Drawing.Point(7, 189);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13); this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 2; this.label2.TabIndex = 2;
this.label2.Text = "Description:"; this.label2.Text = "Description:";
// //
// label3 // label3
// //
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 193); this.label3.Location = new System.Drawing.Point(6, 206);
this.label3.MaximumSize = new System.Drawing.Size(260, 0); this.label3.MaximumSize = new System.Drawing.Size(260, 0);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 13); this.label3.Size = new System.Drawing.Size(0, 13);
this.label3.TabIndex = 3; this.label3.TabIndex = 3;
// //
// label4 // label4
// //
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(10, 255); this.label4.Location = new System.Drawing.Point(10, 268);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(57, 13); this.label4.Size = new System.Drawing.Size(57, 13);
this.label4.TabIndex = 4; this.label4.TabIndex = 4;
this.label4.Text = "Command:"; this.label4.Text = "Command:";
// //
// textBox1 // textBox1
// //
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(8, 273); this.textBox1.Location = new System.Drawing.Point(8, 286);
this.textBox1.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true; this.textBox1.Size = new System.Drawing.Size(272, 20);
this.textBox1.Size = new System.Drawing.Size(272, 20); this.textBox1.TabIndex = 5;
this.textBox1.TabIndex = 5; //
// // button1
// button1 //
// this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; this.button1.Location = new System.Drawing.Point(124, 327);
this.button1.Location = new System.Drawing.Point(124, 314); this.button1.Name = "button1";
this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 6;
this.button1.TabIndex = 6; this.button1.Text = "OK";
this.button1.Text = "OK"; this.button1.UseVisualStyleBackColor = true;
this.button1.UseVisualStyleBackColor = true; //
// // button2
// button2 //
// this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.button2.Location = new System.Drawing.Point(205, 327);
this.button2.Location = new System.Drawing.Point(205, 314); this.button2.Name = "button2";
this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 7;
this.button2.TabIndex = 7; this.button2.Text = "Cancel";
this.button2.Text = "Cancel"; this.button2.UseVisualStyleBackColor = true;
this.button2.UseVisualStyleBackColor = true; //
// // label5
// label5 //
// this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label5.AutoSize = true;
this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(159, 189);
this.label5.Location = new System.Drawing.Point(159, 176); this.label5.Name = "label5";
this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(56, 13);
this.label5.Size = new System.Drawing.Size(56, 13); this.label5.TabIndex = 8;
this.label5.TabIndex = 8; this.label5.Text = "Extension:";
this.label5.Text = "Extension:"; //
// // FFmpegWriterForm
// FFmpegWriterForm //
// this.AcceptButton = this.button1;
this.AcceptButton = this.button1; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button2;
this.CancelButton = this.button2; this.ClientSize = new System.Drawing.Size(292, 362);
this.ClientSize = new System.Drawing.Size(292, 349); this.Controls.Add(this.label5);
this.Controls.Add(this.label5); this.Controls.Add(this.button2);
this.Controls.Add(this.button2); this.Controls.Add(this.button1);
this.Controls.Add(this.button1); this.Controls.Add(this.textBox1);
this.Controls.Add(this.textBox1); this.Controls.Add(this.label4);
this.Controls.Add(this.label4); this.Controls.Add(this.label3);
this.Controls.Add(this.label3); this.Controls.Add(this.label2);
this.Controls.Add(this.label2); this.Controls.Add(this.listBox1);
this.Controls.Add(this.listBox1); this.Controls.Add(this.label1);
this.Controls.Add(this.label1); this.MinimumSize = new System.Drawing.Size(300, 360);
this.MinimumSize = new System.Drawing.Size(300, 360); this.Name = "FFmpegWriterForm";
this.Name = "FFmpegWriterForm"; this.ShowIcon = false;
this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Choose Video Format";
this.Text = "Choose Video Format"; this.ResumeLayout(false);
this.ResumeLayout(false); this.PerformLayout();
this.PerformLayout();
} }

View File

@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Gets the default file extension /// Gets the default file extension
/// </summary> /// </summary>
public string Defaultext { get; } public string Extension { get; set; }
/// <summary> /// <summary>
/// get a list of canned presets /// get a list of canned presets
@ -48,8 +48,10 @@ namespace BizHawk.Client.EmuHawk
{ {
return new[] return new[]
{ {
new FormatPreset("AVI Lossless", "Lossless AVC video and uncompressed audio in an AVI container. High speed and compression, compatible with AVISource().", new FormatPreset("AVI Lossless AVC", "Lossless AVC video and uncompressed audio in an AVI container. High speed and compression, compatible with AVISource().",
"-c:a pcm_s16le -c:v libx264rgb -qp 0 -preset ultrafast -g 30 -pix_fmt rgb24 -f avi", false, "avi"), "-c:a pcm_s16le -c:v libx264rgb -qp 0 -preset ultrafast -g 10 -pix_fmt rgb24 -f avi", false, "avi"),
new FormatPreset("AVI Lossless FFV1", "Lossless FFV1 video and uncompressed audio in an AVI container. Compatible with AVISource(), if ffmpeg based decoder is installed.",
"-c:a pcm_s16le -c:v ffv1 -pix_fmt bgr0 -level 1 -g 1 -coder 1 -context 1 -f avi", false, "avi"),
new FormatPreset("AVI Uncompressed", "Uncompressed video and audio in an AVI container. Very large, don't use!", new FormatPreset("AVI Uncompressed", "Uncompressed video and audio in an AVI container. Very large, don't use!",
"-c:a pcm_s16le -c:v rawvideo -f avi", false, "avi"), "-c:a pcm_s16le -c:v rawvideo -f avi", false, "avi"),
new FormatPreset("Matroska Lossless", "Lossless AVC video and uncompressed audio in a Matroska container.", new FormatPreset("Matroska Lossless", "Lossless AVC video and uncompressed audio in a Matroska container.",
@ -104,7 +106,19 @@ namespace BizHawk.Client.EmuHawk
{ {
} }
private FormatPreset(string name, string desc, string commandline, bool custom, string defaultext) public void DeduceFormat(string commandline)
{
string formatkey = "-f ";
Extension = commandline.Substring(commandline.IndexOf(formatkey) + formatkey.Length);
// are there other formats that don't match their file extensions?
if (Extension == "matroska")
{
Extension = "mkv";
}
}
private FormatPreset(string name, string desc, string commandline, bool custom, string ext)
{ {
Name = name; Name = name;
Desc = desc; Desc = desc;
@ -114,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
? Global.Config.FFmpegCustomCommand ? Global.Config.FFmpegCustomCommand
: commandline; : commandline;
Defaultext = defaultext; DeduceFormat(Commandline);
} }
} }
@ -128,11 +142,9 @@ namespace BizHawk.Client.EmuHawk
if (listBox1.SelectedIndex != -1) if (listBox1.SelectedIndex != -1)
{ {
var f = (FormatPreset)listBox1.SelectedItem; var f = (FormatPreset)listBox1.SelectedItem;
label5.Text = "Extension: " + f.Extension;
label5.Text = "Extension: " + f.Defaultext;
label3.Text = f.Desc; label3.Text = f.Desc;
textBox1.Text = f.Commandline; textBox1.Text = f.Commandline;
textBox1.ReadOnly = !f.Custom;
} }
} }
@ -163,8 +175,11 @@ namespace BizHawk.Client.EmuHawk
Global.Config.FFmpegFormat = ret.ToString(); Global.Config.FFmpegFormat = ret.ToString();
if (ret.Custom) if (ret.Custom)
{ {
ret.Commandline = dlg.textBox1.Text; ret.Commandline =
Global.Config.FFmpegCustomCommand = dlg.textBox1.Text; Global.Config.FFmpegCustomCommand =
dlg.textBox1.Text;
ret.DeduceFormat(ret.Commandline);
} }
} }