private void AddStreamInfo(TrackEntrySection trackEntry, StreamType type, int index) { ClusterSection.TrackInfo trackInfo = null; try { trackInfo = MFI.Segment.Cluster.Tracks[(int)trackEntry.TrackNumber.Value].TrackInfo; } catch(Exception) { } Add(type, index, EntryKey.Index, () => index.ToString(), null); Add(type, index, EntryKey.TrackNumber, () => trackEntry.TrackNumber.Value.ToString(), null); Add(type, index, EntryKey.Size, () => trackInfo.TrackSize.ToString(), "byte"); Add(type, index, EntryKey.Bitrate, () => trackInfo.AverageBitrate.HasValue ? trackInfo.AverageBitrate.Value.ToString("0", CultureInfo.InvariantCulture) : null, "bit/s"); Add(type, index, EntryKey.Duration, () => trackInfo.TrackLength.TotalSeconds.ToString(CultureInfo.InvariantCulture), "s"); Add(type, index, EntryKey.Title, () => trackEntry.Name, null); Add(type, index, EntryKey.Language, () => trackEntry.Language, null); Add(type, index, EntryKey.CodecName, () => trackEntry.CodecName, null); Add(type, index, EntryKey.CodecId, () => trackEntry.CodecId, null); if(trackEntry.GetBitMapInfoHeader().HasValue && string.Equals(trackEntry.CodecId, "V_MS/VFW/FOURCC")) { var header = trackEntry.GetBitMapInfoHeader().Value; Add(type, index, EntryKey.FourCC, () => header.FourCC, null); //Add(type, index, EntryKey.ColorBitDepth, () => header.biBitCount.ToString(), null); } Add(type, index, EntryKey.TwoCC, () => string.Equals(trackEntry.CodecId, "A_MS/ACM") && trackEntry.GetWaveFormatEx().HasValue ? trackEntry.GetWaveFormatEx().Value.TwoCC : null, null); Add(type, index, EntryKey.Id, () => trackEntry.TrackUId.ToString(), null); switch(type) { case StreamType.Video: Add(type, index, EntryKey.FrameCount, () => trackInfo.LaceCount.ToString(), null); Add(type, index, EntryKey.FrameRate, () => (trackEntry.DefaultDuration.HasValue ? 1000000000d / trackEntry.DefaultDuration.Value : 0).ToString("0.000", CultureInfo.InvariantCulture), "fps"); //if(trackInfo.MinLaceRate + 2 < trackInfo.MaxLaceRate) { if(trackInfo.AverageLaceRate.HasValue) Add(type, index, EntryKey.VFR, () => trackInfo.AverageLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); if(trackInfo.MinLaceRate.HasValue) Add(type, index, EntryKey.MinFrameRate, () => trackInfo.MinLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); if(trackInfo.MaxLaceRate.HasValue) Add(type, index, EntryKey.MaxFrameRate, () => trackInfo.MaxLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); //} Add(type, index, EntryKey.Width, () => trackEntry.Video.PixelWidth.ToString(), "px"); Add(type, index, EntryKey.Height, () => trackEntry.Video.PixelHeight.ToString(), "px"); Add(type, index, EntryKey.DAR, () => (trackEntry.Video.DisplayWidth / (double)trackEntry.Video.DisplayHeight).ToString("0.000", CultureInfo.InvariantCulture), null); //Add(type, index, EntryKey.ColorSpace, () => Encoding.ASCII.GetString(trackEntry.Video.ColorSpace), null); break; case StreamType.Audio: Add(type, index, EntryKey.SampleCount, () => ((int)(trackInfo.TrackLength.TotalSeconds * trackEntry.Audio.SamplingFrequency)).ToString(), null); Add(type, index, EntryKey.SamplingRate, () => trackEntry.Audio.SamplingFrequency.ToString(CultureInfo.InvariantCulture), null); Add(type, index, EntryKey.ChannelCount, () => trackEntry.Audio.ChannelCount.ToString(), null); break; case StreamType.Text: break; } }
private void AddStreamInfo(TrackEntrySection trackEntry, StreamType type, int index) { ClusterSection.TrackInfo trackInfo = null; try { trackInfo = MFI.Segment.Cluster.Tracks[(int)trackEntry.TrackNumber.Value].TrackInfo; } catch (Exception) { } Add(type, index, EntryKey.Index, () => index.ToString(), null); Add(type, index, EntryKey.TrackNumber, () => trackEntry.TrackNumber.Value.ToString(), null); Add(type, index, EntryKey.Size, () => trackInfo.TrackSize.ToString(), "byte"); Add(type, index, EntryKey.Bitrate, () => trackInfo.AverageBitrate.HasValue ? trackInfo.AverageBitrate.Value.ToString("0", CultureInfo.InvariantCulture) : null, "bit/s"); Add(type, index, EntryKey.Duration, () => trackInfo.TrackLength.TotalSeconds.ToString(CultureInfo.InvariantCulture), "s"); Add(type, index, EntryKey.Title, () => trackEntry.Name, null); Add(type, index, EntryKey.Language, () => trackEntry.Language, null); Add(type, index, EntryKey.CodecName, () => trackEntry.CodecName, null); Add(type, index, EntryKey.CodecId, () => trackEntry.CodecId, null); if (trackEntry.GetBitMapInfoHeader().HasValue&& string.Equals(trackEntry.CodecId, "V_MS/VFW/FOURCC")) { var header = trackEntry.GetBitMapInfoHeader().Value; Add(type, index, EntryKey.FourCC, () => header.FourCC, null); //Add(type, index, EntryKey.ColorBitDepth, () => header.biBitCount.ToString(), null); } Add(type, index, EntryKey.TwoCC, () => string.Equals(trackEntry.CodecId, "A_MS/ACM") && trackEntry.GetWaveFormatEx().HasValue ? trackEntry.GetWaveFormatEx().Value.TwoCC : null, null); Add(type, index, EntryKey.Id, () => trackEntry.TrackUId.ToString(), null); switch (type) { case StreamType.Video: Add(type, index, EntryKey.FrameCount, () => trackInfo.LaceCount.ToString(), null); Add(type, index, EntryKey.FrameRate, () => (trackEntry.DefaultDuration.HasValue ? 1000000000d / trackEntry.DefaultDuration.Value : 0).ToString("0.000", CultureInfo.InvariantCulture), "fps"); //if(trackInfo.MinLaceRate + 2 < trackInfo.MaxLaceRate) { if (trackInfo.AverageLaceRate.HasValue) { Add(type, index, EntryKey.VFR, () => trackInfo.AverageLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); } if (trackInfo.MinLaceRate.HasValue) { Add(type, index, EntryKey.MinFrameRate, () => trackInfo.MinLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); } if (trackInfo.MaxLaceRate.HasValue) { Add(type, index, EntryKey.MaxFrameRate, () => trackInfo.MaxLaceRate.Value.ToString("0.000", CultureInfo.InvariantCulture), "fps"); } //} Add(type, index, EntryKey.Width, () => trackEntry.Video.PixelWidth.ToString(), "px"); Add(type, index, EntryKey.Height, () => trackEntry.Video.PixelHeight.ToString(), "px"); Add(type, index, EntryKey.DAR, () => (trackEntry.Video.DisplayWidth / (double)trackEntry.Video.DisplayHeight).ToString("0.000", CultureInfo.InvariantCulture), null); //Add(type, index, EntryKey.ColorSpace, () => Encoding.ASCII.GetString(trackEntry.Video.ColorSpace), null); break; case StreamType.Audio: Add(type, index, EntryKey.SampleCount, () => ((int)(trackInfo.TrackLength.TotalSeconds * trackEntry.Audio.SamplingFrequency)).ToString(), null); Add(type, index, EntryKey.SamplingRate, () => trackEntry.Audio.SamplingFrequency.ToString(CultureInfo.InvariantCulture), null); Add(type, index, EntryKey.ChannelCount, () => trackEntry.Audio.ChannelCount.ToString(), null); break; case StreamType.Text: break; } }