Beispiel #1
0
		private void encodeToolStripMenuItem_Click(object sender, EventArgs e)
		{
			try
			{
				if (data.SelectedRows.Count == 0)
				{
					if (data.SelectedCells.Count == 1)
					{
						clData cur = (clData)data.SelectedCells[0].OwningRow.DataBoundItem;
						cur.AskEncoding();
					}
				}
				else
				{
					for (int i = 0; i < data.SelectedRows.Count; i++)
					{
						clData cur = (clData)data.SelectedRows[i].DataBoundItem;
						cur.AskEncoding();
					}
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}




		}
Beispiel #2
0
		private void backWorkGetData_DoWork(object sender, DoWorkEventArgs e)
		{
			bool hadData = false;
			while (!isClosing)
			{
				try
				{
					if (LstGetInfo.Count > 0)
					{
						clData cur = LstGetInfo[0];
						LstGetInfo.RemoveAt(0);
						cur.updateInfo();
						isDirty = true;
						hadData = true;
						VideoTotalSize += cur.SizeMb;
						backWorkGetData.ReportProgress(0);
					}
					else
					{
						if (hadData)
						{
							hadData = false;
							backWorkGetData.ReportProgress(0);
						}

						System.Threading.Thread.Sleep(500);
					}
				}
				catch (Exception ex)
				{
					GenFunc.LogAdd(ex);
				}

			}
		}
Beispiel #3
0
		private void backWorkFindFiles_ProgressChanged(object sender, ProgressChangedEventArgs e)
		{
			try
			{
				switch (e.ProgressPercentage)
				{
					case 0:
						if (e.UserState.GetType().Name == "String")
						{
							MessageBox.Show(e.UserState.ToString());
							return;
						}
						break;
					case 1:
						lblScanStatus.Text = "Scanning: " + e.UserState.ToString();
						break;
					case 2:
						clData item = (clData)e.UserState;
						bindingData.Add(item);
						LstGetInfo.Add(item);
						lblVideoFound.Text = bindingData.Count.ToString();
						break;
					default:
						break;
				}


			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}

		}
Beispiel #4
0
		private void moveToWithStructureToolStripMenuItem_Click(object sender, EventArgs e)
		{
			try
			{
				FolderBrowserDialog dlg = new FolderBrowserDialog();
				dlg.SelectedPath = txtPath.Text;
				dlg.ShowNewFolderButton = true;
				if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
				{
					for (int i = 0; i < data.SelectedRows.Count; i++)
					{
						try
						{
							clData cur = (clData)data.SelectedRows[i].Tag;
							string movePath = dlg.SelectedPath + "\\" + cur.fileInfo.FullName.Substring(txtPath.Text.Length);
							Directory.CreateDirectory(FileFunc.GetDirOfFullName(movePath));
							cur.fileInfo.MoveTo(movePath);
						}
						catch (Exception ex)
						{
							MessageBox.Show(ex.Message);
						}
					}
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}
Beispiel #5
0
		private void getFilesInDir(clParam p, DirectoryInfo curDir)
		{
			try
			{
				if (backWorkFindFiles.CancellationPending)
					return;

				FileInfo[] files = curDir.GetFiles();
				for (int i = 0; i < files.Length; i++)
				{
					if (isGoodExtension(p, files[i]))
					{
						backWorkFindFiles.ReportProgress(2, new clData(files[i]));
					}
				}

				if (cntDirectory++ > 50)
				{
					cntDirectory = 0;
					backWorkFindFiles.ReportProgress(1, curDir.FullName.Substring(p.pathLength));
				}

				DirectoryInfo[] childDirectories = curDir.GetDirectories();
				for (int i = 0; i < childDirectories.Length; i++)
				{
					getFilesInDir(p, childDirectories[i]);
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}

		}
Beispiel #6
0
        internal bool updateInfo()
        {
            try
            {
                if (fileInfo == null || fileInfo.Exists == false || fileInfo.DirectoryName.Contains(@":\$RECYCLE.BIN\"))
                {
                    return(false);
                }

                DateTime start     = DateTime.Now;
                var      ffProbe   = new NReco.VideoInfo.FFProbe();
                var      videoInfo = ffProbe.GetMediaInfo(fileInfo.FullName);

                durationMs = videoInfo.Duration.TotalMilliseconds;
                Duration   = string.Format("{0}:{1}:{2}", videoInfo.Duration.Hours, videoInfo.Duration.Minutes, videoInfo.Duration.Seconds);
                if (Duration.StartsWith("0:"))
                {
                    Duration = Duration.Substring(2);
                }
                SizeByte = fileInfo.Length;
                SizeMb   = (int)(fileInfo.Length / (1024 * 1024.0));
                Bitrate  = Math.Round((SizeByte / 1024.0) / (durationMs / 1000.0));

                string formatVideo = "";
                string formatAudio = "";
                for (int i = 0; i < videoInfo.Streams.Length; i++)
                {
                    if (videoInfo.Streams[i].CodecType == "video")
                    {
                        formatVideo += videoInfo.Streams[i].CodecName + " ";
                    }
                    else
                    {
                        formatAudio += videoInfo.Streams[i].CodecName + " ";
                    }
                }
                Format = formatVideo + formatAudio.Trim();

                Status = EnEncoding.HasInfo;

                //GenFunc.LogAddInfo(this,"updateInfo", "Time: " + Math.Round((DateTime.Now - start).TotalMilliseconds) + " [ms]");
                return(true);
            }
            catch (Exception ex)
            {
                GenFunc.LogAdd(ex);
                Status = EnEncoding.Error;
            }
            return(false);
        }
Beispiel #7
0
 static void Main()
 {
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new frmMain());
     }
     catch (Exception ex)
     {
         GenFunc.LogAdd(ex);
         MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Beispiel #8
0
		private void playBackupToolStripMenuItem_Click(object sender, EventArgs e)
		{
			try
			{
				for (int i = 0; i < data.SelectedCells.Count; i++)
				{
					clData cur = (clData)data.SelectedCells[i].OwningRow.DataBoundItem;

					Process.Start(cur.pathBackup);
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}
Beispiel #9
0
		private bool isGoodExtension(clParam p, FileInfo fileInfo)
		{
			try
			{
				for (int i = 0; i < p.extensionArr.Length; i++)
				{
					if (fileInfo.Extension == p.extensionArr[i])
						return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
				return false;
			}
		}
Beispiel #10
0
        internal void EncodeVideo()
        {
            Status          = EnEncoding.Processing;
            frmMain.isDirty = true;
            string originalPath = fileInfo.FullName;
            string newName      = fileInfo.FullName.Replace(fileInfo.Extension, ".mp4");

            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(pathBackup));
            fileInfo.MoveTo(pathBackup);
            fileInfo = new System.IO.FileInfo(newName);
            try
            {
                var             ffMpeg = new FFMpegConverter();
                ConvertSettings c      = new ConvertSettings();
                //c.VideoCodec = "libx264";
                //c.CustomOutputArgs = "-crf 23";
                //ffMpeg.ConvertMedia(cur.fileInfo.FullName, null, newName + "23", "MP4", c);

                //c.CustomOutputArgs = "-crf 1";
                //ffMpeg.ConvertMedia(cur.fileInfo.FullName, null, newName + "1", "MP4", c);

                c.VideoCodec                 = "libx265";
                c.CustomOutputArgs           = "-crf 28";
                EncodingLog                  = new StringBuilder();
                ffMpeg.FFMpegProcessPriority = System.Diagnostics.ProcessPriorityClass.BelowNormal;
                ffMpeg.LogReceived          += FfMpeg_LogReceived;
                ffMpeg.ConvertMedia(fileInfo.FullName, null, newName, "MP4", c);
                string s = EncodingLog.ToString();

                updateInfo();
                Status = EnEncoding.Encoded;
            }
            catch (Exception ex)
            {
                GenFunc.LogAdd(ex);
                FileFunc.TryDelete(newName);
                fileInfo = new System.IO.FileInfo(pathBackup);
                fileInfo.MoveTo(originalPath);
                updateInfo();
                Status = EnEncoding.Error;
            }

            frmMain.isDirty = true;
        }
Beispiel #11
0
		private void backWorkFindFiles_DoWork(object sender, DoWorkEventArgs e)
		{
			try
			{
				clParam p = (clParam)e.Argument;
				DirectoryInfo curDir = new DirectoryInfo(p.path);
				if (!curDir.Exists)
				{
					backWorkFindFiles.ReportProgress(0, "Folder doen't exists");
					return;
				}

				getFilesInDir(p, curDir);
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}
Beispiel #12
0
		private void moveToToolStripMenuItem_Click(object sender, EventArgs e)
		{
			try
			{
				FolderBrowserDialog dlg = new FolderBrowserDialog();
				dlg.SelectedPath = txtPath.Text;
				dlg.ShowNewFolderButton = true;
				if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
				{
					for (int i = 0; i < data.SelectedRows.Count; i++)
					{
						clData cur = (clData)data.SelectedRows[i].Tag;
						cur.fileInfo.MoveTo(dlg.SelectedPath + "\\" + cur.fileInfo.Name);
					}
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}

		}
Beispiel #13
0
		private void txtPath_TextChanged(object sender, EventArgs e)
		{
			try
			{
				if (Directory.Exists(txtPath.Text))
				{
					txtPath.BackColor = Color.LightGreen;
					butStart.Enabled = true;
				}
				else
				{
					txtPath.BackColor = Color.Pink;
					butStart.Enabled = false;
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
				txtPath.BackColor = Color.Pink;
				butStart.Enabled = false;
			}
		}
Beispiel #14
0
		private void butStart_Click(object sender, EventArgs e)
		{
			try
			{
				if (!txtPath.Text.EndsWith("\\"))
				{
					txtPath.Text += "\\";
				}
				if (!txtBackFolder.Text.EndsWith("\\"))
				{
					txtBackFolder.Text += "\\";
				}

				if (butStart.Text == "Start")
				{
					bindingData.Clear();
					VideoTotalSize = 0;

					clParam p = new clParam();
					p.path = txtPath.Text;
					p.extension = txtExtension.Text;
					p.BackupPath = txtBackFolder.Text;
					clData.param = p;

					backWorkFindFiles.RunWorkerAsync(p);
					butStart.Text = "Cancel";
				}
				else
				{
					backWorkFindFiles.CancelAsync();
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}