예제 #1
0
        /// <summary>
        /// Read stream info
        /// </summary>
        /// <param name="mi"><see cref="MediaInfoContainer"/></param>
        /// <param name="vStream">Video stream</param>
        /// <param name="bluRayTarget"></param>
        /// <returns></returns>
        public static VideoInfo GetStreamInfo(MediaInfoContainer mi, VideoInfo vStream, bool bluRayTarget)
        {
            if (mi.Video.Count <= 0)
            {
                return(vStream);
            }

            float.TryParse(mi.Video[0].DisplayAspectRatio, NumberStyles.Number, CInfo,
                           out vStream.AspectRatio);
            vStream.Bitrate       = mi.Video[0].BitRate;
            vStream.Format        = mi.Video[0].Format;
            vStream.FormatProfile = mi.Video[0].FormatProfile;
            if (mi.Video[0].FrameRateEnumerator < vStream.FrameRateEnumerator * 2 || !bluRayTarget)
            {
                vStream.Fps                  = mi.Video[0].FrameRate;
                vStream.FrameCount           = mi.Video[0].FrameCount;
                vStream.FrameRateDenominator = mi.Video[0].FrameRateDenominator;
                vStream.FrameRateEnumerator  = mi.Video[0].FrameRateEnumerator;
            }
            vStream.Height     = mi.Video[0].Height;
            vStream.Width      = mi.Video[0].Width;
            vStream.Interlaced = mi.Video[0].ScanType != "Progressive";
            vStream.Length     = mi.Video[0].DurationTime.TimeOfDay.TotalSeconds;
            vStream.PicSize    = mi.Video[0].VideoSize;
            vStream.StreamSize = GenHelper.GetFileSize(vStream.TempFile);
            vStream.FrameMode  = mi.Video[0].FormatFrameMode;
            return(vStream);
        }
예제 #2
0
        /// <summary>
        /// Get Audio stream properties
        /// </summary>
        /// <param name="aStream"></param>
        /// <returns></returns>
        public static AudioInfo GetStreamInfo(AudioInfo aStream)
        {
            var mi = new MediaInfoContainer();

            try
            {
                mi = GenHelper.GetMediaInfo(aStream.TempFile);
            }
            catch (TimeoutException ex)
            {
                Log.Error(ex);
                mi = new MediaInfoContainer();
            }
            finally
            {
                if (mi.Audio.Count > 0)
                {
                    aStream.Bitrate       = mi.Audio[0].BitRate;
                    aStream.BitDepth      = mi.Audio[0].BitDepth;
                    aStream.ChannelCount  = mi.Audio[0].Channels;
                    aStream.SampleRate    = mi.Audio[0].SamplingRate;
                    aStream.Format        = mi.Audio[0].Format;
                    aStream.FormatProfile = mi.Audio[0].FormatProfile;
                    aStream.StreamSize    = GenHelper.GetFileSize(aStream.TempFile);
                    if (aStream.Format == "PCM")
                    {
                        aStream.Length = GetRuntimePcm(aStream);
                    }
                    else
                    {
                        aStream.Length = mi.Audio[0].Duration / 1000d; // convert from ms to seconds
                    }
                }
            }
            return(aStream);
        }