Esempio n. 1
0
        private void selectAudioFile(string file)
        {
            FileSize f = FileSize.Of2(file) ?? FileSize.Empty;

            size.CertainValue = f;

            AudioType aud2Type = VideoUtil.guessAudioType(file);

            if (audio1Type.Items.Contains(aud2Type))
            {
                audio1Type.SelectedItem = aud2Type;
            }

            MediaInfo info;

            try
            {
                info = new MediaInfo(file);
                MediaInfoWrapper.AudioTrack atrack = info.Audio[0];
                if (atrack.CodecString == "DTS")
                {
                    audio1Bitrate.Value = (Convert.ToInt32(atrack.BitRate) / 1000);
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when trying to get Media info for file " + file + "\r\n" + i.Message, "Error parsing mediainfo data", MessageBoxButtons.OK);
            }
        }
Esempio n. 2
0
        /// gets information about a video source using MediaInfo
        /// </summary>
        /// <param name="infoFile">the info file to be analyzed</param>
        /// <param name="audioTracks">the audio tracks found</param>
        /// <param name="maxHorizontalResolution">the width of the video</param>
        public void getSourceMediaInfo(string fileName, out List <AudioTrackInfo> audioTracks, out int maxHorizontalResolution)
        {
            MediaInfo info;

            audioTracks             = new List <AudioTrackInfo>();
            maxHorizontalResolution = 5000;
            try
            {
                info = new MediaInfo(fileName);
                maxHorizontalResolution = Int32.Parse(info.Video[0].Width);
                for (int counter = 0; counter < info.Audio.Count; counter++)
                {
                    MediaInfoWrapper.AudioTrack atrack = info.Audio[counter];
                    AudioTrackInfo ati = new AudioTrackInfo();
                    // DGIndex expects audio index not ID for TS
                    ati.ContainerType = info.General[0].Format;
                    ati.Index         = counter;
                    if (info.General[0].Format == "CDXA/MPEG-PS")
                    {
                        // MediaInfo doesn't give TrackID for VCD, specs indicate only MP1L2 is supported
                        ati.TrackID = (0xC0 + counter);
                    }
                    else if (atrack.ID != "0")
                    {
                        ati.TrackID = Int32.Parse(atrack.ID);
                    }
                    else
                    {
                        // MediaInfo failed to get ID try guessing based on codec
                        switch (atrack.Codec.Substring(0, 3))
                        {
                        case "AC3": ati.TrackID = (0x80 + counter); break;

                        case "PCM": ati.TrackID = (0xA0 + counter); break;

                        case "MPA": ati.TrackID = (0xC0 + counter); break;

                        case "DTS": ati.TrackID = (0x88 + counter); break;
                        }
                    }
                    ati.Type         = atrack.CodecString;
                    ati.NbChannels   = atrack.ChannelsString;
                    ati.SamplingRate = atrack.SamplingRateString;
                    ati.TrackInfo    = new TrackInfo(atrack.LanguageString, null);
                    audioTracks.Add(ati);
                    if (info.General[0].Format == "MPEG-TS")
                    {
                        break;  // DGIndex only supports first audio stream with TS files
                    }
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when trying to get Media info for file " + fileName + "\r\n" + i.Message, "Error parsing mediainfo data", MessageBoxButtons.OK);
                audioTracks.Clear();
            }
        }
Esempio n. 3
0
        /// gets ID from audio stream using MediaInfo
        /// </summary>
        /// <param name="infoFile">the file to be analyzed</param>
        /// <param name="count">the counter</param>
        /// <returns>the audio track ID found</returns>
        public static int getIDFromAudioStream(string fileName, int count)
        {
            MediaInfo info;
            int       TrackID = 0;

            try
            {
                info = new MediaInfo(fileName);
                if (info.AudioCount >= 0)
                {
                    MediaInfoWrapper.AudioTrack atrack = info.Audio[count];
                    TrackID = Int32.Parse(atrack.ID);
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when trying to get Media info for file " + fileName + "\r\n" + i.Message, "Error parsing mediainfo data", MessageBoxButtons.OK);
            }
            return(TrackID);
        }