예제 #1
0
 public BasicMediaInfo(BasicMediaInfo mediaInfo)
 {
     CodecName = mediaInfo.CodecName;
     CodecType = mediaInfo.CodecType;
     Bitrate   = mediaInfo.Bitrate;
     FrameRate = mediaInfo.FrameRate;
     Duration  = mediaInfo.Duration;
     Title     = mediaInfo.Title;
     Language  = mediaInfo.Language;
 }
예제 #2
0
        public BasicMediaFormatInfo(string filename)
        {
            string mediaInfo = Converter.GetMediaInfo(filename);

            Cll.JSON.Element info   = Cll.JSON.SyntacticAnalyzer.Read(mediaInfo);
            Cll.JSON.Object  format = (Cll.JSON.Object)info.Value.GetValue("format");

            FileName = ((Cll.JSON.String)format.GetValue("filename")).Value;
            Size     = Convert.ToInt64(((Cll.JSON.String)format.GetValue("size")).Value);
            Format   = ((Cll.JSON.String)format.GetValue("format_name")).Value;
            Duration = Convert.ToDouble(((Cll.JSON.String)format.GetValue("duration")).Value);
            Bitrate  = Convert.ToInt32(((Cll.JSON.String)format.GetValue("bit_rate")).Value);

            if (format.Contains("tags") && ((Cll.JSON.Object)format.GetValue("tags")).Contains("title"))
            {
                Title = ((Cll.JSON.String)format.GetValue("tags").GetValue("title")).Value;
            }
            else
            {
                Title = "";
            }

            int numStreams = Convert.ToInt32(((Cll.JSON.Number)info.Value.GetValue("format").GetValue("nb_streams")).Value);

            MediaInfo = new BasicMediaInfo[numStreams];

            for (int i = 0; i < MediaInfo.Length; i++)
            {
                Cll.JSON.Object streamInfo = (Cll.JSON.Object)info.Value.GetValue("streams").GetValue(i);
                string          codecType  = ((Cll.JSON.String)streamInfo.GetValue("codec_type")).Value;
                if (codecType == "video")
                {
                    MediaInfo[i] = new BasicVideoInfo(streamInfo);
                }
                else if (codecType == "audio")
                {
                    MediaInfo[i] = new BasicAudioInfo(streamInfo);
                }
                else if (codecType == "subtitle")
                {
                    MediaInfo[i] = new BasicSubtitleInfo(streamInfo);
                }
                else
                {
                    MediaInfo[i] = new BasicMediaInfo(streamInfo);
                }
            }
        }