private async Task GetMediaInfo(string previewFile, MediaEncoderSettings settings) {
using (MediaInfoReader InfoReader = new MediaInfoReader()) {
await InfoReader.LoadInfoAsync(previewFile);
settings.SourceWidth = InfoReader.Width;
settings.SourceHeight = InfoReader.Height;
settings.SourceAspectRatio = InfoReader.PixelAspectRatio ?? 1;
if (settings.SourceAspectRatio != 1) {
// Get aspect ratio from FFMPEG which is more accurate.
float? SAR = FfmpegBusiness.GetPixelAspectRatio(settings);
if (SAR.HasValue)
settings.SourceAspectRatio = SAR.Value;
}
// Fix last track of VCDs that is widescreen.
if (settings.SourceHeight == 288 && settings.SourceWidth == 352 && settings.SourceAspectRatio == 1.485f)
settings.SourceAspectRatio = 1.092f;
settings.SourceFrameRate = InfoReader.FrameRate;
if (settings.ConvertToAvi)
await InfoReader.LoadInfoAsync(Settings.NaturalGroundingFolder + settings.FileName);
settings.SourceAudioFormat = InfoReader.AudioFormat;
settings.SourceVideoFormat = InfoReader.VideoFormat;
settings.SourceColorMatrix = InfoReader.Height < 720 ? ColorMatrix.Rec601 : ColorMatrix.Rec709;
if (!settings.CanCopyAudio)
settings.EncodeFormat = VideoFormats.Mkv;
settings.SourceAudioBitrate = InfoReader.AudioBitRate;
settings.SourceBitDepth = InfoReader.BitDepth;
settings.Position = (InfoReader.Length ?? 0) / 2;
settings.CalculateSize();
}
}