Skip to content

Commit 7f63414

Browse files
committed
chages for 3.39.0
* Add in caption filter crop zone when it exist previously * Improve preview performance * Improve shadow under dynamic points * Refactor rotate filter to ffmpeg commands * Update ffmpeg to v6.1
1 parent c484a35 commit 7f63414

File tree

12 files changed

+121
-38
lines changed

12 files changed

+121
-38
lines changed

Binaries/Win64/ffmpeg.exe

3.39 MB
Binary file not shown.

Components/PreviewFrame.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public RotateFlipType RotateFlip
3434
set { rotateFlipType = value; GeneratePreview(); }
3535
}
3636

37-
38-
3937
public PreviewFrame()
4038
{
4139
if (Program.VideoSource != null)
@@ -46,11 +44,16 @@ public PreviewFrame()
4644

4745
frame = Program.VideoSource.GetFrame((int)framenumber);
4846

49-
if (frame.EncodedResolution.Width * frame.EncodedResolution.Height > 2073600) // 1080p (1920*1080)
47+
if (frame.EncodedResolution.Width * frame.EncodedResolution.Height >= 2073600) // 1080p (1920*1080)
5048
{
5149
encodeW = frame.EncodedResolution.Width / 2;
5250
encodeH = frame.EncodedResolution.Height / 2;
5351
}
52+
else if (frame.EncodedResolution.Width * frame.EncodedResolution.Height >= 8294400)
53+
{
54+
encodeW = frame.EncodedResolution.Width / 4;
55+
encodeH = frame.EncodedResolution.Height / 4;
56+
}
5457
else
5558
{
5659
encodeW = frame.EncodedResolution.Width;
@@ -94,7 +97,6 @@ private int FixValue(int number)
9497

9598
public void GeneratePreview(bool force)
9699
{
97-
98100
if (Program.VideoSource == null)
99101
return;
100102

@@ -105,7 +107,6 @@ public void GeneratePreview(bool force)
105107
{
106108
Picture.BackgroundImage = MainForm.cache[(int)framenumber];
107109
Picture.ClientSize = new Size(width, height);
108-
Picture.Refresh();
109110
SetPadding();
110111
return;
111112
}
@@ -136,7 +137,6 @@ public void GeneratePreview(bool force)
136137
MainForm.cache.TryAdd((int)framenumber, (Bitmap)destImage.Clone());
137138

138139
Picture.BackgroundImage = destImage;
139-
Picture.Refresh();
140140
SetPadding();
141141
cachedframenumber = (int)framenumber;
142142
}

Filters/Caption.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,35 @@ public partial class CaptionForm : Form
1818
Size videoResolution;
1919
Point held;
2020
Point beforeheld;
21+
private RectangleF cropPercent;
2122

2223
public CaptionForm()
2324
{
2425
InitializeComponent();
2526
SetFrameRange();
2627
SetEvents();
28+
SetCrop();
2729
}
2830

2931
public CaptionForm(CaptionFilter filterToEdit)
3032
{
3133
InitializeComponent();
3234

3335
SetFrameRange();
34-
36+
SetCrop();
3537
numericStartFrame.Value = filterToEdit.Start;
3638
numericEndFrame.Value = filterToEdit.End;
3739
InputFilter = filterToEdit;
3840

3941
SetEvents();
4042
}
4143

44+
private void SetCrop()
45+
{
46+
if (Filters.Crop != null)
47+
cropPercent = Filters.Crop.cropPercent;
48+
}
49+
4250
private void SetFrameRange()
4351
{
4452
numericStartFrame.Maximum = Program.VideoSource.NumberOfFrames;
@@ -48,6 +56,7 @@ private void SetFrameRange()
4856
private void SetEvents()
4957
{
5058
previewFrame.Picture.Paint += new PaintEventHandler(this.previewPicture_Paint);
59+
previewFrame.Picture.Paint += new PaintEventHandler(this.previewPicture_Crop);
5160
previewFrame.Picture.MouseDown += new MouseEventHandler(this.previewPicture_MouseDown);
5261
previewFrame.Picture.MouseMove += new MouseEventHandler(this.previewPicture_MouseMove);
5362
}
@@ -119,6 +128,34 @@ void previewPicture_Paint(object sender, PaintEventArgs e)
119128
g.DrawPath(new Pen(new SolidBrush(colorDialogBorderColor.Color), (float)numericBorderThickness.Value * scale), path);
120129
}
121130

131+
private void previewPicture_Crop(object sender, PaintEventArgs e)
132+
{
133+
if (Filters.Crop == null)
134+
return;
135+
136+
var g = e.Graphics;
137+
var edgePen = new Pen(Color.White, 1f);
138+
var dotBrush = new SolidBrush(Color.White);
139+
var outsideBrush = new HatchBrush(HatchStyle.Percent50, Color.Transparent);
140+
141+
var maxW = previewFrame.Picture.Width;
142+
var maxH = previewFrame.Picture.Height;
143+
var x = cropPercent.X * previewFrame.Picture.Width;
144+
var y = cropPercent.Y * previewFrame.Picture.Height;
145+
var w = cropPercent.Width * maxW;
146+
var h = cropPercent.Height * maxH;
147+
148+
//Darken background
149+
g.FillRectangle(outsideBrush, 0, 0, maxW, y);
150+
g.FillRectangle(outsideBrush, 0, y, x, h);
151+
g.FillRectangle(outsideBrush, x + w, y, maxW - (x + w), h);
152+
g.FillRectangle(outsideBrush, 0, y + h, maxW, maxH);
153+
154+
//Edge
155+
g.DrawRectangle(edgePen, x, y, w, h);
156+
157+
}
158+
122159
void previewPicture_MouseDown(object sender, MouseEventArgs e)
123160
{
124161
held = e.Location;

Filters/Crop.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public partial class CropForm : Form
2525
private RectangleF cropPercent;
2626
private int currentFrame;
2727
private IDictionary<int, CropPoint> cropsList = new Dictionary<int, CropPoint>();
28+
private bool open = true;
2829
private enum Corner
2930
{
3031
TopLeft,
@@ -53,6 +54,18 @@ public CropForm()
5354
SetEvents();
5455
}
5556

57+
private void LoadDynamicCrop()
58+
{
59+
if (Filters.DynamicCrop != null)
60+
{
61+
open = false;
62+
dynamicCropActive.Checked = true;
63+
cropsList = Filters.DynamicCrop.crops;
64+
cropPercent = Filters.DynamicCrop.cropArea;
65+
open = true;
66+
}
67+
}
68+
5669
private void SetEvents()
5770
{
5871
trackVideoTimeline.Maximum = Program.VideoSource.NumberOfFrames - 1;
@@ -99,6 +112,7 @@ void CropForm_Load(object sender, EventArgs e)
99112
trackVideoTimeline.Maximum = Filters.MultipleTrim.Trims[Filters.MultipleTrim.Trims.Count - 1].TrimEnd;
100113
trimTimingToolStripMenuItem.Enabled = true;
101114
}
115+
LoadDynamicCrop();
102116
}
103117

104118
private void previewPicture_MouseDown(object sender, MouseEventArgs e)
@@ -378,7 +392,7 @@ private void AddCropPan(int width, int height)
378392

379393
private void GenerateFilter(IDictionary<int, CropPoint> cropsList)
380394
{
381-
GeneratedCropPanFilter = new DynamicCropFilter(cropsList, trackVideoTimeline.Maximum);
395+
GeneratedCropPanFilter = new DynamicCropFilter(cropsList, trackVideoTimeline.Maximum, cropPercent);
382396
}
383397
private void GenerateFilter(int width, int height)
384398
{
@@ -709,7 +723,9 @@ private void dynamicCropActive_CheckedChanged(object sender, EventArgs e)
709723
{
710724
dynamicCropActive.ForeColor = dynamicCropActive.Checked ? Color.Green : Color.Black;
711725

712-
if (newHeight == 0 && dynamicCropActive.Checked)
726+
cropBars.Enabled = dynamicCropActive.Checked ? false : true;
727+
728+
if (newHeight == 0 && dynamicCropActive.Checked && open)
713729
ShowNewDimension();
714730
}
715731

@@ -719,10 +735,12 @@ private void cropBars_CheckedChanged(object sender, EventArgs e)
719735
if (cropBars.Checked)
720736
{
721737
Filters.CropBarsFilter = new CropBarsFilter();
738+
dynamicCropActive.Enabled = false;
722739
}
723740
else
724741
{
725742
Filters.CropBarsFilter = null;
743+
dynamicCropActive.Enabled = true;
726744
}
727745

728746
}
@@ -767,9 +785,13 @@ public CropFilter(int left, int top, int right, int bottom, RectangleF cropPerce
767785
public class DynamicCropFilter
768786
{
769787
private readonly string cropFilter;
788+
public IDictionary<int, CropPoint> crops { get; }
789+
public RectangleF cropArea { get; }
770790

771-
public DynamicCropFilter(IDictionary<int, CropPoint> cropsList, int maximum)
791+
public DynamicCropFilter(IDictionary<int, CropPoint> cropsList, int maximum, RectangleF cropPercent)
772792
{
793+
cropArea = cropPercent;
794+
crops = cropsList;
773795
List<KeyValuePair<int, CropPoint>> listCrops = cropsList.ToList();
774796
string crop = listCrops[0].Value.Crop;
775797
string easeType = "easeInOutSine";

Filters/Dynamic.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Collections;
1010
using WebMConverter.Objects;
1111
using System.Text;
12+
using System.Collections.Generic;
1213

1314
namespace WebMConverter
1415
{
@@ -117,23 +118,30 @@ private void previewPicture_Paint(object sender, PaintEventArgs e)
117118
var g = e.Graphics;
118119
var edgePen = new Pen(Color.White, 2f);
119120
var dotBrush = new SolidBrush(Color.Red);
120-
var outsideBrush = new HatchBrush(HatchStyle.Percent80, Color.Transparent);
121-
122-
g.FillRectangle(outsideBrush, 0, 0, previewFrame.Size.Width, previewFrame.Size.Height);
121+
var outsideBrush = new HatchBrush(HatchStyle.Percent70, Color.Transparent);
123122

124123
PointF[] drawPoints = new PointF[points.Count];
125124

126125
var h = previewFrame.Picture.Size.Height;
127126
var w = previewFrame.Picture.Size.Width;
127+
List<PointF> polygon = new List<PointF>();
128+
polygon.Add(new PointF(0, h));
128129

129130
for (int i = 0; i < points.Count; i++)
130131
{
131132
SpeedPoint point = (SpeedPoint)points.GetByIndex(i);
132133
int keyFrame = (int)points.GetKey(i);
133-
134-
drawPoints[i] = new PointF(((((float)keyFrame - trimStart) * 100) / (trimEnd - trimStart)) / 100 * w , (h * (1 - (float)point.Speed)) / 2 + h / 2);
134+
float x = ((((float)keyFrame - trimStart) * 100) / (trimEnd - trimStart)) / 100 * w;
135+
float y = (h * (1 - (float)point.Speed)) / 2 + h / 2;
136+
var pointF = new PointF(x, y);
137+
drawPoints[i] = pointF;
138+
polygon.Add(pointF);
135139
}
136-
140+
141+
polygon.Add(new PointF( w, h));
142+
polygon.Add(new PointF(0, h));
143+
144+
g.FillPolygon(outsideBrush, polygon.ToArray());
137145
g.DrawLines(edgePen, drawPoints);
138146

139147
float diameter = 6;

Filters/RotateForm.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,24 @@ public override string ToString()
220220
command = "";
221221
break;
222222
case RotateMode.Right:
223-
command = "TurnRight() ";
223+
command = "transpose=1";
224224
break;
225225
case RotateMode.Twice:
226-
command = "TurnRight() TurnRight() ";
226+
command = "transpose=2";
227227
break;
228228
case RotateMode.Left:
229-
command = "TurnLeft() ";
229+
command = "transpose=3";
230230
break;
231231
}
232232

233233
if (FlipHorizontal)
234234
{
235-
command += "FlipHorizontal() ";
235+
command += ", hflip";
236236
}
237237

238238
if (FlipVertical)
239239
{
240-
command += "FlipVertical()";
240+
command += ", vflip";
241241
}
242242

243243
return command;

Filters/Trim.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Drawing;
34
using System.IO;
45
using System.Windows.Forms;
56
using WebMConverter.Dialogs;

MainForm.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,16 +1058,11 @@ void buttonRotate_Click(object sender, EventArgs e)
10581058
{
10591059
if (form.ShowDialog(this) == DialogResult.OK)
10601060
{
1061-
if (boxAdvancedScripting.Checked)
1062-
{
1063-
textBoxProcessingScript.AppendText(Environment.NewLine + form.GeneratedFilter);
1064-
}
1065-
else
1066-
{
1067-
Filters.Rotate = form.GeneratedFilter;
1068-
listViewProcessingScript.Items.Add("Rotate", "rotate");
1069-
(sender as ToolStripItem).Enabled = false;
1070-
}
1061+
1062+
Filters.Rotate = form.GeneratedFilter;
1063+
listViewProcessingScript.Items.Add("Rotate", "rotate");
1064+
(sender as ToolStripItem).Enabled = false;
1065+
UpdateArguments(sender, e);
10711066
}
10721067
}
10731068
}
@@ -1240,6 +1235,7 @@ void listViewProcessingScript_ItemActivate(object sender, EventArgs e)
12401235
if (form.ShowDialog(this) == DialogResult.OK)
12411236
{
12421237
Filters.Rotate = form.GeneratedFilter;
1238+
UpdateArguments(sender, e);
12431239
}
12441240
}
12451241
break;
@@ -2223,7 +2219,9 @@ void Preview()
22232219
string avsFileName = GetTemporaryFile();
22242220
WriteAvisynthScript(avsFileName, input);
22252221

2222+
List<string> listVF = new List<string>();
22262223
string levels = string.Empty;
2224+
22272225
switch (comboLevels.SelectedIndex)
22282226
{
22292227
case 1:
@@ -2237,11 +2235,20 @@ void Preview()
22372235
break;
22382236
}
22392237

2240-
if (!string.IsNullOrEmpty(levels))
2241-
levels = " -vf " + levels;
2238+
if (!String.IsNullOrEmpty(levels))
2239+
listVF.Add(levels);
2240+
2241+
if (Filters.Rotate != null)
2242+
listVF.Add(Filters.Rotate.ToString());
2243+
2244+
string filter = string.Empty;
2245+
2246+
if (listVF.Count > 0)
2247+
filter = $" -vf \"{UnionVF(listVF)}\"";
22422248

22432249
var disableAudio = boxAudio.Checked ? "" : "-an";
2244-
var ffplay = new FFplay($@"-window_title Preview -loop 0 -f avisynth -v error {disableAudio}{levels} ""{avsFileName}""");
2250+
var a = $@"-window_title Preview -loop 0 -f avisynth -v error {disableAudio} {filter} ""{avsFileName}""";
2251+
var ffplay = new FFplay($@"-window_title Preview -loop 0 -f avisynth -v error {disableAudio} {filter} ""{avsFileName}""");
22452252
ffplay.Exited += delegate
22462253
{
22472254
string error = ffplay.ErrorLog;
@@ -2505,6 +2512,9 @@ string GenerateArguments()
25052512
if (!String.IsNullOrEmpty(textBoxdB.Text) && boxAudio.Checked)
25062513
audioFilter = $" -filter:a \"volume={textBoxdB.Text}dB\" ";
25072514

2515+
if (Filters.Rotate != null)
2516+
listVF.Add(Filters.Rotate.ToString());
2517+
25082518
string filter = string.Empty;
25092519

25102520
if(listVF.Count > 0)
@@ -2646,8 +2656,6 @@ void GenerateAvisynthScript()
26462656
script.AppendLine(Filters.Reverse.ToString());
26472657
if (Filters.Fade != null)
26482658
script.AppendLine(Filters.Fade.ToString());
2649-
if (Filters.Rotate != null)
2650-
script.AppendLine(Filters.Rotate.ToString());
26512659
if (Filters.DelayAudio != null)
26522660
script.AppendLine(Filters.DelayAudio.ToString());
26532661
if (Filters.CropBarsFilter != null)

NewUpdate/3.39.0.zip

28.7 MB
Binary file not shown.

NewUpdate/latest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.38.0
1+
3.39.0

0 commit comments

Comments
 (0)