private void UpdateCropSizeInfo() { if (inputFile == null) { labelCropSize.Text = ""; return; } if (PictureConfig.IsCropped()) { labelCropSize.Text = $"{PictureConfig.InputDisplaySize.ToString()} → {PictureConfig.CropSize.ToString()}"; } else { labelCropSize.Text = ""; } }
/// <summary> /// Create content for "vf" argument /// </summary> /// <param name="subtitlesPath"></param> /// <returns></returns> private string GetVideoFilters(string subtitlesPath) { List <string> filters = new List <string>(); // https://ffmpeg.org/ffmpeg-filters.html#yadif-1 if (PictureConfig.Deinterlace) { filters.Add($"yadif=parity={PictureConfig.FieldOrder}"); } // https://ffmpeg.org/ffmpeg-filters.html#crop if (PictureConfig.IsCropped()) { // using oar int cropW = PictureConfig.InputOriginalSize.Width - PictureConfig.Crop.Left - PictureConfig.Crop.Right; int cropH = PictureConfig.InputOriginalSize.Height - PictureConfig.Crop.Top - PictureConfig.Crop.Bottom; filters.Add($"crop={cropW}:{cropH}:{PictureConfig.Crop.Left}:{PictureConfig.Crop.Top}"); } // https://ffmpeg.org/ffmpeg-filters.html#scale-1 if (PictureConfig.OutputSize.Width != PictureConfig.CropSize.Width || PictureConfig.OutputSize.Height != PictureConfig.CropSize.Height) { // https://www.ffmpeg.org/ffmpeg-scaler.html#sws_005fflags filters.Add($"scale={PictureConfig.OutputSize.Width}x{PictureConfig.OutputSize.Height}:flags={PictureConfig.Interpolation}"); } else if (PictureConfig.IsUsingDAR()) { // force scale for not square pixels filters.Add($"scale={PictureConfig.CropSize.Width}x{PictureConfig.CropSize.Height}:flags={PictureConfig.Interpolation}"); } // https://ffmpeg.org/ffmpeg-filters.html#pad-1 /*if (PictureConfig.Padding.X > 0 || PictureConfig.Padding.Y > 0) * { * filters.Add($"pad={PictureConfig.SelectedSize.Width}:{PictureConfig.SelectedSize.Height}:{PictureConfig.Padding.X}:{PictureConfig.Padding.Y}"); * }*/ // https://ffmpeg.org/ffmpeg-filters.html#transpose if (PictureConfig.Rotate == 180) { filters.Add("transpose=2,transpose=2"); } else if (PictureConfig.Rotate == 90) { filters.Add("transpose=1"); } else if (PictureConfig.Rotate == 270) { filters.Add("transpose=2"); } // https://ffmpeg.org/ffmpeg-filters.html#hflip if (PictureConfig.Flip) { filters.Add("hflip"); } // Set subtitles // https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo if (!string.IsNullOrWhiteSpace(subtitlesPath) && File.Exists(subtitlesPath)) { // https://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping filters.Add($"subtitles={subtitlesPath.Replace("\\", "\\\\\\\\").Replace("'", "\\\\\\'").Replace(":", "\\\\:").Replace(",", "\\,")}"); } // force sar 1:1 // https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar filters.Add("setsar=sar=1/1"); // color filter // https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer if (PictureConfig.ColorChannelMixerList.ContainsKey(PictureConfig.ColorFilter)) { filters.Add($"colorchannelmixer={PictureConfig.ColorChannelMixerList[PictureConfig.ColorFilter]}"); } return(string.Join(",", filters)); }