From 5b5f4c2dfcf4f76af6d06bf6bfe31554e3ca85da Mon Sep 17 00:00:00 2001 From: itwangxiang Date: Mon, 20 Dec 2021 11:31:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IdeaVideoAI/Config.cs | 1 + IdeaVideoAI/Form1.Designer.cs | 119 ++++++++++++++++++++------------- IdeaVideoAI/Form1.cs | 22 +++++- IdeaVideoAI/IdeaVideoAI.csproj | 2 + README.md | 11 +-- 5 files changed, 95 insertions(+), 60 deletions(-) diff --git a/IdeaVideoAI/Config.cs b/IdeaVideoAI/Config.cs index a8d795e..73a93f7 100644 --- a/IdeaVideoAI/Config.cs +++ b/IdeaVideoAI/Config.cs @@ -31,6 +31,7 @@ public class Config public int tab3MaxStartTime; public string tab3FontPictureFile; public int tab3OutTime; + public bool tab3PictureSharpen; //背景视频 public List tab3BgVideoFiles; diff --git a/IdeaVideoAI/Form1.Designer.cs b/IdeaVideoAI/Form1.Designer.cs index da9b5a2..af226e4 100644 --- a/IdeaVideoAI/Form1.Designer.cs +++ b/IdeaVideoAI/Form1.Designer.cs @@ -33,6 +33,7 @@ private void InitializeComponent() this.openVideoFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.安装FfmpegToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.更新ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.listView1 = new System.Windows.Forms.ListView(); this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); @@ -94,6 +95,9 @@ private void InitializeComponent() this.nUDContrastV1 = new System.Windows.Forms.NumericUpDown(); this.btnTab2Repeat = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.cbTab3PictureSharpen = new System.Windows.Forms.CheckBox(); + this.nUDTab3OutTime = new System.Windows.Forms.NumericUpDown(); + this.label10 = new System.Windows.Forms.Label(); this.labTab3AddFontPicture = new System.Windows.Forms.Label(); this.btnTab3AddFontPicture = new System.Windows.Forms.Button(); this.nUDTab3VideoMaxStartTime = new System.Windows.Forms.NumericUpDown(); @@ -103,8 +107,6 @@ private void InitializeComponent() this.btnTab3Exec = new System.Windows.Forms.Button(); this.labTab3BackgroundCount = new System.Windows.Forms.Label(); this.btnTab3BackgroundVideo = new System.Windows.Forms.Button(); - this.nUDTab3OutTime = new System.Windows.Forms.NumericUpDown(); - this.label10 = new System.Windows.Forms.Label(); this.menuStrip1.SuspendLayout(); this.panel1.SuspendLayout(); this.panel3.SuspendLayout(); @@ -131,10 +133,10 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.nUDContrastV2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDContrastV1)).BeginInit(); this.tabPage3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nUDTab3OutTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3VideoMaxStartTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3VideoMinStartTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3ExecCount)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nUDTab3OutTime)).BeginInit(); this.SuspendLayout(); // // menuStrip1 @@ -160,13 +162,14 @@ private void InitializeComponent() // this.openVideoFileToolStripMenuItem.Name = "openVideoFileToolStripMenuItem"; this.openVideoFileToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.openVideoFileToolStripMenuItem.Text = "打开视频"; + this.openVideoFileToolStripMenuItem.Text = "打开文件"; this.openVideoFileToolStripMenuItem.Click += new System.EventHandler(this.openVideoFileToolStripMenuItem_Click); // // 帮助ToolStripMenuItem // this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.安装FfmpegToolStripMenuItem}); + this.安装FfmpegToolStripMenuItem, + this.更新ToolStripMenuItem}); this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(45, 20); this.帮助ToolStripMenuItem.Text = "帮助"; @@ -178,6 +181,13 @@ private void InitializeComponent() this.安装FfmpegToolStripMenuItem.Text = "安装 ffmpeg"; this.安装FfmpegToolStripMenuItem.Click += new System.EventHandler(this.安装FfmpegToolStripMenuItem_Click); // + // 更新ToolStripMenuItem + // + this.更新ToolStripMenuItem.Name = "更新ToolStripMenuItem"; + this.更新ToolStripMenuItem.Size = new System.Drawing.Size(142, 22); + this.更新ToolStripMenuItem.Text = "更新"; + this.更新ToolStripMenuItem.Click += new System.EventHandler(this.更新ToolStripMenuItem_Click); + // // listView1 // this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -448,7 +458,7 @@ private void InitializeComponent() 0, 0}); this.nUPRepeatCount.Name = "nUPRepeatCount"; - this.nUPRepeatCount.Size = new System.Drawing.Size(890, 23); + this.nUPRepeatCount.Size = new System.Drawing.Size(892, 23); this.nUPRepeatCount.TabIndex = 104; this.nUPRepeatCount.Value = new decimal(new int[] { 1, @@ -1101,6 +1111,7 @@ private void InitializeComponent() // // tabPage3 // + this.tabPage3.Controls.Add(this.cbTab3PictureSharpen); this.tabPage3.Controls.Add(this.nUDTab3OutTime); this.tabPage3.Controls.Add(this.label10); this.tabPage3.Controls.Add(this.labTab3AddFontPicture); @@ -1120,18 +1131,56 @@ private void InitializeComponent() this.tabPage3.Text = "加图"; this.tabPage3.UseVisualStyleBackColor = true; // + // cbTab3PictureSharpen + // + this.cbTab3PictureSharpen.AutoSize = true; + this.cbTab3PictureSharpen.Checked = true; + this.cbTab3PictureSharpen.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbTab3PictureSharpen.Location = new System.Drawing.Point(6, 106); + this.cbTab3PictureSharpen.Name = "cbTab3PictureSharpen"; + this.cbTab3PictureSharpen.Size = new System.Drawing.Size(78, 19); + this.cbTab3PictureSharpen.TabIndex = 100; + this.cbTab3PictureSharpen.Text = "图片锐化"; + this.cbTab3PictureSharpen.UseVisualStyleBackColor = true; + // + // nUDTab3OutTime + // + this.nUDTab3OutTime.Location = new System.Drawing.Point(138, 69); + this.nUDTab3OutTime.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nUDTab3OutTime.Name = "nUDTab3OutTime"; + this.nUDTab3OutTime.Size = new System.Drawing.Size(34, 23); + this.nUDTab3OutTime.TabIndex = 99; + this.nUDTab3OutTime.Value = new decimal(new int[] { + 8, + 0, + 0, + 0}); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(6, 73); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(129, 15); + this.label10.TabIndex = 98; + this.label10.Text = "输出视频时长:(s)"; + // // labTab3AddFontPicture // this.labTab3AddFontPicture.AutoSize = true; this.labTab3AddFontPicture.Location = new System.Drawing.Point(138, 39); this.labTab3AddFontPicture.Name = "labTab3AddFontPicture"; - this.labTab3AddFontPicture.Size = new System.Drawing.Size(111, 15); + this.labTab3AddFontPicture.Size = new System.Drawing.Size(13, 15); this.labTab3AddFontPicture.TabIndex = 97; - this.labTab3AddFontPicture.Text = "请选择宣传语图片"; + this.labTab3AddFontPicture.Text = "0"; // // btnTab3AddFontPicture // - this.btnTab3AddFontPicture.Location = new System.Drawing.Point(3, 35); + this.btnTab3AddFontPicture.Location = new System.Drawing.Point(6, 35); this.btnTab3AddFontPicture.Name = "btnTab3AddFontPicture"; this.btnTab3AddFontPicture.Size = new System.Drawing.Size(127, 23); this.btnTab3AddFontPicture.TabIndex = 96; @@ -1141,9 +1190,9 @@ private void InitializeComponent() // // nUDTab3VideoMaxStartTime // - this.nUDTab3VideoMaxStartTime.Location = new System.Drawing.Point(356, 6); + this.nUDTab3VideoMaxStartTime.Location = new System.Drawing.Point(341, 6); this.nUDTab3VideoMaxStartTime.Name = "nUDTab3VideoMaxStartTime"; - this.nUDTab3VideoMaxStartTime.Size = new System.Drawing.Size(120, 23); + this.nUDTab3VideoMaxStartTime.Size = new System.Drawing.Size(40, 23); this.nUDTab3VideoMaxStartTime.TabIndex = 95; this.nUDTab3VideoMaxStartTime.Value = new decimal(new int[] { 10, @@ -1153,19 +1202,19 @@ private void InitializeComponent() // // nUDTab3VideoMinStartTime // - this.nUDTab3VideoMinStartTime.Location = new System.Drawing.Point(219, 6); + this.nUDTab3VideoMinStartTime.Location = new System.Drawing.Point(296, 6); this.nUDTab3VideoMinStartTime.Name = "nUDTab3VideoMinStartTime"; - this.nUDTab3VideoMinStartTime.Size = new System.Drawing.Size(120, 23); + this.nUDTab3VideoMinStartTime.Size = new System.Drawing.Size(39, 23); this.nUDTab3VideoMinStartTime.TabIndex = 94; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(138, 10); + this.label9.Location = new System.Drawing.Point(189, 10); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(75, 15); + this.label9.Size = new System.Drawing.Size(101, 15); this.label9.TabIndex = 93; - this.label9.Text = "随机开始:(s)"; + this.label9.Text = "随机开始时间:(s)"; // // nUDTab3ExecCount // @@ -1197,15 +1246,15 @@ private void InitializeComponent() // labTab3BackgroundCount // this.labTab3BackgroundCount.AutoSize = true; - this.labTab3BackgroundCount.Location = new System.Drawing.Point(482, 10); + this.labTab3BackgroundCount.Location = new System.Drawing.Point(138, 10); this.labTab3BackgroundCount.Name = "labTab3BackgroundCount"; - this.labTab3BackgroundCount.Size = new System.Drawing.Size(124, 15); + this.labTab3BackgroundCount.Size = new System.Drawing.Size(13, 15); this.labTab3BackgroundCount.TabIndex = 90; - this.labTab3BackgroundCount.Text = "请选择多个背景视频"; + this.labTab3BackgroundCount.Text = "0"; // // btnTab3BackgroundVideo // - this.btnTab3BackgroundVideo.Location = new System.Drawing.Point(3, 6); + this.btnTab3BackgroundVideo.Location = new System.Drawing.Point(6, 6); this.btnTab3BackgroundVideo.Name = "btnTab3BackgroundVideo"; this.btnTab3BackgroundVideo.Size = new System.Drawing.Size(127, 23); this.btnTab3BackgroundVideo.TabIndex = 89; @@ -1213,32 +1262,6 @@ private void InitializeComponent() this.btnTab3BackgroundVideo.UseVisualStyleBackColor = true; this.btnTab3BackgroundVideo.Click += new System.EventHandler(this.btnTab3BackgroundVideo_Click); // - // nUPTab3OutTime - // - this.nUDTab3OutTime.Location = new System.Drawing.Point(138, 69); - this.nUDTab3OutTime.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.nUDTab3OutTime.Name = "nUPTab3OutTime"; - this.nUDTab3OutTime.Size = new System.Drawing.Size(120, 23); - this.nUDTab3OutTime.TabIndex = 99; - this.nUDTab3OutTime.Value = new decimal(new int[] { - 8, - 0, - 0, - 0}); - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(6, 73); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(129, 15); - this.label10.TabIndex = 98; - this.label10.Text = "输出视频时长:(s)"; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -1282,10 +1305,10 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.nUDContrastV1)).EndInit(); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nUDTab3OutTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3VideoMaxStartTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3VideoMinStartTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDTab3ExecCount)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nUDTab3OutTime)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1371,5 +1394,7 @@ private void InitializeComponent() private Button btnTab3AddFontPicture; private NumericUpDown nUDTab3OutTime; private Label label10; + private CheckBox cbTab3PictureSharpen; + private ToolStripMenuItem 更新ToolStripMenuItem; } } \ No newline at end of file diff --git a/IdeaVideoAI/Form1.cs b/IdeaVideoAI/Form1.cs index 0548e1f..17e9896 100644 --- a/IdeaVideoAI/Form1.cs +++ b/IdeaVideoAI/Form1.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Diagnostics; using System.Reflection; using Xabe.FFmpeg; using Xabe.FFmpeg.Downloader; @@ -1019,6 +1020,7 @@ private void btnTab3Exec_Click(object sender, EventArgs e) Config.Instance.tab3MinStartTime = (int)nUDTab3VideoMinStartTime.Value; Config.Instance.tab3MaxStartTime = (int)nUDTab3VideoMaxStartTime.Value; Config.Instance.tab3OutTime = (int)nUDTab3OutTime.Value; + Config.Instance.tab3PictureSharpen = cbTab3PictureSharpen.Checked; for (int i = 0; i < pictureDatas.Count; i++) @@ -1038,18 +1040,23 @@ private void btnTab3Exec_Click(object sender, EventArgs e) int yRandom = Utils.nextRandomRange(0, 100); - var ffmpegFormat = " -y {0} -filter_complex \"{1}\" -map [audio] -map [video] \"{2}\" "; + var ffmpegFormat = " -y {0} -filter_complex \"{1}\" \"{2}\" "; var tempInput = string.Format(" -ss {0} -t {1} -i \"{2}\" -i \"{3}\" ", ss, Config.Instance.tab3OutTime, videoFile, imageFile); - var tempFilter = "[0:a]acopy[audio];[0:v]copy[video];[1:v][video]scale2ref=w=iw/10*8:h=ow/main_a[over][video]"; + var tempFilter = "[1:v][0:v]scale2ref=w=iw/10*8:h=ow/main_a[over][video]"; var tempOut = Path.Join(item.outDir, j + 1 + "__" + item.fileName + Path.GetExtension(videoFile)); + if (Config.Instance.tab3PictureSharpen) + { + tempFilter += ";[over]unsharp=3:3:5[over]"; + } + if (!string.IsNullOrEmpty(fontFile)) { tempInput += string.Format(" -i {0} ", fontFile); tempFilter += ";[2:v][over]scale2ref=w=iw:h=ow/main_a[font][over];[over][font]vstack[over]"; } - tempFilter += string.Format(";[video][over]overlay=x=W*{0}/1000:y=H/16+H/16*{1}/100[video]", xRandom, yRandom); + tempFilter += string.Format(";[video][over]overlay=x=W*{0}/1000:y=H/16+H/16*{1}/100", xRandom, yRandom); //" -y -ss {0} -i \"{1}\" -i \"{2}\" -i \"{3}\" -filter_complex \"[0:a]acopy[audio];[1:v][0:v]scale2ref=w=iw/10*8:h=ow/main_a[pic][video];[2:v][pic]scale2ref=w=iw:h=ow/main_a[font][pic];[pic][font]vstack[over];[video][pic]overlay=x=W*{4}/1000:y=H/16+H/16*{5}/100[video]\" -map [audio] -map [video] \"{6}\" " var cmd = String.Format(ffmpegFormat, tempInput, tempFilter, tempOut); @@ -1080,6 +1087,15 @@ private void btnTab3AddFontPicture_Click(object sender, EventArgs e) labTab3AddFontPicture.Text = fd.FileName; } } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "https://github.com/itwangxiang/IdeaVideoAI/releases", + UseShellExecute = true + }); + } } } \ No newline at end of file diff --git a/IdeaVideoAI/IdeaVideoAI.csproj b/IdeaVideoAI/IdeaVideoAI.csproj index 683123c..3f66bd8 100644 --- a/IdeaVideoAI/IdeaVideoAI.csproj +++ b/IdeaVideoAI/IdeaVideoAI.csproj @@ -6,6 +6,8 @@ enable true enable + False + diff --git a/README.md b/README.md index 0b501da..2e53e4e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,2 @@ # IdeaVideoAI - -## 一个有想法的视频处理工具,追求 AI 效果 - -[![GitHub release](https://img.shields.io/github/v/release/itwangxiang/IdeaVideoAI.svg)](https://github.com/itwangxiang/IdeaVideoAI/releases) ![Total Downloads](https://img.shields.io/github/downloads/itwangxiang/IdeaVideoAI/total.svg) ![Support Platforms](https://camo.githubusercontent.com/2b46c1151d9febe8de2b889e3867c235163737d1855f90b3b3b3edcd8b878b8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d77696e646f77732d6c6967687467726579) - -## 特性 - -- 支持人工标注水印后批量去水印 -- 支持随机修改视频属性,以达到去重效果 -- 支持图片与背景视频随机合成多个视频 +视频去水印神器