/// <summary> /// Reset values for new file /// </summary> public static void Reset() { inputOriginalSize = null; inputDisplaySize = null; CropSize = null; OutputSize = null; crop = new Crop(); //padding = new Padding(); Deinterlace = false; fieldOrder = DefaultFieldOrder; rotate = 0; Flip = false; }
private void SetOutputInfo() { if (inputFile == null) { labelOutputInfoTitle.Visible = false; labelOutputInfo.Text = ""; return; } StringBuilder info = new StringBuilder(); // Video if (checkBoxConvertVideo.Checked) { if (VideoConfig.CodecList.ContainsKey(VideoConfig.Codec)) { info.Append($"{VideoConfig.CodecList[VideoConfig.Codec]}"); } else { info.Append($"{VideoConfig.Codec}"); } /*if (PictureConfig.Padding.X > 0 || PictureConfig.Padding.Y > 0) * { * PictureSize fullSize = new PictureSize(); * fullSize.Width = PictureConfig.OutputSize.Width + PictureConfig.Padding.X + PictureConfig.Padding.X; * fullSize.Height = PictureConfig.OutputSize.Height + PictureConfig.Padding.Y + PictureConfig.Padding.Y; * info.Append($", {fullSize.ToString()} ({PictureConfig.OutputSize.ToString()})"); * } * else * { * info.Append($", {PictureConfig.OutputSize.ToString()}"); * }*/ if (PictureConfig.Rotate == 90 || PictureConfig.Rotate == 270) { PictureSize size = new PictureSize { Width = PictureConfig.OutputSize.Height, Height = PictureConfig.OutputSize.Width }; info.Append($", {size.ToString()}"); } else { info.Append($", {PictureConfig.OutputSize.ToString()}"); } if (PictureConfig.Deinterlace) { info.Append(", деинт."); } if (PictureConfig.Rotate > 0) { if (PictureConfig.RotateList.ContainsKey(PictureConfig.Rotate)) { info.Append($", {PictureConfig.RotateList[PictureConfig.Rotate]}"); } else { info.Append($", {PictureConfig.Rotate}°"); } } if (PictureConfig.Flip) { info.Append($", отразить"); } if (PictureConfig.ColorFilter != "none") { info.Append($", {PictureConfig.ColorFilterList[PictureConfig.ColorFilter].ToLower()}"); } if (radioButtonCRF.Checked) { info.Append($", CRF {labelCRF.Text}"); } else { info.Append($", {numericUpDownBitrate.Value} кбит/с"); } double finalFrameRate = CalcFinalFrameRate(); if (finalFrameRate > 0) { info.Append($", {finalFrameRate} fps"); } } else { VideoStream vStream = inputFile.VideoStreams[0]; if (VideoConfig.CodecList.ContainsKey(vStream.CodecName)) { info.Append($"{VideoConfig.CodecList[vStream.CodecName]}"); } else { info.Append($"{vStream.CodecName}"); } info.Append($", без изменения"); } // Audio info.Append($"{Environment.NewLine}"); if (comboBoxAudioStreams.SelectedIndex < 1) { info.Append("нет"); } else { int index = ((ComboBoxIntItem)comboBoxAudioStreams.SelectedItem).Value; if (AudioConfig.CodecList.ContainsKey(AudioConfig.Codec)) { info.Append($"{AudioConfig.CodecList[AudioConfig.Codec]}"); } else { info.Append($"{AudioConfig.Codec}"); } int idx = 1; foreach (AudioStream aStream in inputFile.AudioStreams) { if (aStream.Index == index) { info.Append($", #{idx}"); break; } idx++; } if (!checkBoxConvertAudio.Checked) { info.Append($", без изменения"); } else { info.Append($", {AudioConfig.Bitrate} кбит/с"); if (AudioConfig.SampleRate > 0) { info.Append($", {AudioConfig.SampleRate} Гц"); } if (AudioConfig.Channels > 0) { if (AudioConfig.ChannelsList.ContainsKey(AudioConfig.Channels)) { info.Append($", каналы: {AudioConfig.ChannelsList[AudioConfig.Channels]}"); } } } } // Show labelOutputInfoTitle.Visible = true; labelOutputInfo.Text = info.ToString(); }
private static void CalcSize() { if (inputOriginalSize == null || inputDisplaySize == null) { return; } if (IsCropped()) { // init with oar sizes int newW = inputOriginalSize.Width - Crop.Left - Crop.Right; int newH = inputOriginalSize.Height - Crop.Top - Crop.Bottom; // correct oar -> dar if (IsUsingDAR()) { double diffW = (double)inputDisplaySize.Width / inputOriginalSize.Width; double diffH = (double)inputDisplaySize.Height / inputOriginalSize.Height; newW = (int)Math.Round(newW * diffW, 0); newH = (int)Math.Round(newH * diffH, 0); } //if (newW < MinWidth) // newW = MinWidth; //if (newH < MinHeight) // newH = MinHeight; CropSize = new PictureSize { Width = newW, Height = newH }; } else { int newW = inputDisplaySize.Width; int newH = inputDisplaySize.Height; //if (newW < MinWidth) // newW = MinWidth; //if (newH < MinHeight) // newH = MinHeight; CropSize = new PictureSize { Width = newW, Height = newH }; } if (OutputSize == null) { int newW = CropSize.Width; int newH = CropSize.Height; if (newW < MinWidth) { newW = MinWidth; } if (newH < MinHeight) { newH = MinHeight; } OutputSize = new PictureSize { Width = newW, Height = newH }; } }