Example #1
0
        /// <summary>
        /// Checks a file to see if it has one audio track
        /// </summary>
        /// <param name="file">the file to check</param>
        /// <returns>the result of the check</returns>
        private static bool checkAudioTrackCount(FileInfo file, testingSpecs targetSpecs)
        {
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            int audioCount;
            string sAudioCount = mediaInfo.Get(StreamKind.Audio, 0, "StreamCount");

            if (file.FullName.Contains(".mpg") || file.FullName.Contains(".mxf") ||
                file.Extension == ".m2v")
            {
                return true;
            }
            //MSW
            if (file.Name.Contains("Music&theSpokenWord"))
            {
                return true;
            }
            if (sAudioCount == "")
            {
                audioCount = 0;
            }
            else
            {
                audioCount = Int32.Parse(sAudioCount);
            }

            if (targetSpecs.audioTracks != -1)
            {
                if (targetSpecs.audioTracks == audioCount)
                {
                    mediaInfo.Close();
                    return true;
                }
                else
                {
                    
                    failFile(file, "has an incorrect audio track count (" + audioCount + ")", targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }

            if (audioCount == 1 || (audioCount == 0 && file.Name.Contains("-ase")))
            {
                mediaInfo.Close();
                return true;
            }

            string report = "has an incorrect audio track count (" + audioCount + ")";
            failFile(file, report, targetSpecs);
            mediaInfo.Close();
            return false;
        }
Example #2
0
        /// <summary>
        /// checks the aspect ratio to make sure it is correct
        /// </summary>
        /// <param name="file">file to be check</param>
        /// <returns>the result of the check</returns>
        private static bool checkAspectRatio(FileInfo file, testingSpecs targetSpecs)
        {
            if (!(file.Extension == ".ac3" || file.Extension == ".mp3"))
            {
                MediaInfo mediaInfo = new MediaInfo();
                mediaInfo.Open(file.FullName);
                //int aspectRatio;
                //TODO: get rid of this test try and make aspect ration a local variable
                try
                {
                    float aspectRatioFloat;
                    float.TryParse(mediaInfo.Get(StreamKind.Video, 0, "DisplayAspectRatio"), out aspectRatioFloat);
                    aspectRatio = (int)(aspectRatioFloat * 1000); //multiple by 1000 so the int doesn't cut of the decimal places
                }
                catch (Exception exception)
                {
                    logger.writeErrorLog("Could not parse aspect ratio for " + file.Name);
                    MessageBox.Show(exception.ToString());
                }

                if (targetSpecs.aspectRatio != "")
                {
                    if (!targetSpecs.aspectRatio.Contains(aspectRatio.ToString()))
                    {
                        failFile(file, "has an incorrect aspect ratio (" + aspectRatio + ")", targetSpecs);
                        mediaInfo.Close();
                        return false;
                    }
                    else
                    {
                        mediaInfo.Close();
                        return true;
                    }
                }
                if (aspectRatio == 1778 || aspectRatio == 1333 || aspectRatio == 1500 || aspectRatio == 1855 ||
                    aspectRatio == 1818 || aspectRatio == 2000)
                {
                    mediaInfo.Close();
                    return true;
                }

                string report = "has an incorrect aspect ratio (" + aspectRatio + ")";
                failFile(file, report, targetSpecs);
                mediaInfo.Close();
                return false;
            }
            else
            {
                return true;
            }
        }
Example #3
0
        /// <summary>
        /// Checks to see if a file has one video track
        /// </summary>
        /// <param name="file">file to check</param>
        /// <returns>result of the check</returns>
        private static bool checkVideoTrackCount(FileInfo file, testingSpecs targetSpecs)
        {
            // Using our xml!


            if (file.FullName.Contains(".ac3") || file.FullName.Contains(".aac") || file.FullName.Contains(".mp3"))
            {
                return true;
            }
            int videoCount;
            string report;
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);


            string sVideoCount = mediaInfo.Get(StreamKind.Video, 0, "StreamCount");

            if (sVideoCount == "")
            {
                videoCount = 0;

            }
            else
            {
                videoCount = Int32.Parse(mediaInfo.Get(StreamKind.Video, 0, "StreamCount"));
            }

            if (targetSpecs.videoTracks != -1)
            {
                if (videoCount == targetSpecs.videoTracks)
                {
                    mediaInfo.Close();
                    return true;
                }
                else
                {
                     report = "has an incorrect number of video tracks (" + videoCount + ")";
                     failFile(file, report, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }

            if (videoCount == 1 || (videoCount == 0 && file.Name.Contains(".mp3")))
            {
                mediaInfo.Close();
                return true;
            }

            report = "has an incorrect number of video tracks (" + videoCount + ")";
            failFile(file, report, targetSpecs);
            mediaInfo.Close();
            return false;
        }
Example #4
0
        /// <summary>
        /// Returns the frame rate of a file
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static int getFrameRate(FileInfo file)
        {
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            float frameRate;

            string tempFrameRate = mediaInfo.Get(StreamKind.Video, 0, "FrameRate"); //in case there is a null value
            if (tempFrameRate != "")
            {
                frameRate = float.Parse(tempFrameRate);
            }
            else
            {
                return -1;
            }

            int intFrameRate = (int)(frameRate * 1000);
            mediaInfo.Close();
            return intFrameRate;

           
        }
Example #5
0
        /// <summary>
        /// checks a file to make sure it is progressive
        /// </summary>
        /// <param name="file">file to check</param>
        /// <returns>result of the check</returns>
        private static bool checkScanType(FileInfo file, testingSpecs targetSpecs)
        {
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);

            string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");


            mediaInfo.Close();

            if (getFrameRate(file) != 23976)
            {
                if (scanType == "Interlaced")
                {
                    return true;
                }
            }

            //TODO: find a better way to handle Music and the Spoken Word
            if (scanType == "Progressive" || file.Name.Contains("300k") || scanType == "" || file.Name.Contains("Music&theSpokenWord") || (file.Name.Contains(".mpg") && scanType == "Interlaced"))
            {
                return true;
            }

            if (targetSpecs.scanType != "")
            {
                if (targetSpecs.scanType == scanType)
                {
                    mediaInfo.Close();
                    return true;
                }
                else
                {
                    failFile(file, "has an incorrect scan type (" + scanType + ")", targetSpecs);
                }
            }
            string report = "has an incorrect scan type (" + scanType + ")";
            failFile(file, report, targetSpecs);
            
            return false;
        }
Example #6
0
        /// <summary>
        /// checks to see if the framerate of a file is correct
        /// </summary>
        /// <param name="file">file to check</param>
        /// <returns>whether the file's framerate is correct</returns>
        private static bool checkFrameRate(FileInfo file, testingSpecs targetSpecs)
        {
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            float frameRate;

            string tempFrameRate = mediaInfo.Get(StreamKind.Video, 0, "FrameRate"); //in case there is a null value
            if (tempFrameRate != "")
            {
                frameRate = float.Parse(tempFrameRate);
            }
            else
            {
                return true;
            }

            int intFrameRate = (int)(frameRate * 1000);

            if (targetSpecs.frameRate != -1)
            {
                if (targetSpecs.frameRate == intFrameRate)
                {
                    mediaInfo.Close();
                    return true;
                }
                else
                {
                    
                    failFile(file, "has an incorrect frame rate (" + intFrameRate + ")", targetSpecs);
                    mediaInfo.Close();
                    return false;

                }
            }

            if (intFrameRate == 14984 ||
                intFrameRate == 29970 ||
                intFrameRate == 14985 ||
                intFrameRate == 14986 ||
                intFrameRate == 23976 ||
                intFrameRate == 15000 ||
                intFrameRate == 30000 ||
                intFrameRate == 25000 ||
                intFrameRate == 24000)
            {
                mediaInfo.Close();
                return true;
            }

            string report = "has an incorrect frame rate (" + intFrameRate + ")";
            failFile(file, report, targetSpecs);
            mediaInfo.Close();
            return false;
        }
Example #7
0
        /// <summary>
        /// checks to make sure the resolution is acceptable
        /// </summary>
        /// <param name="file">the file to be checked</param>
        /// <returns>the result of the check</returns>
        private static bool checkResolution(FileInfo file, testingSpecs targetSpecs)
        {

            if (file.FullName.Contains(".mp3") || file.FullName.Contains(".ac3") || file.FullName.Contains(".aac"))
            {
                return true;
            }
           
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            int width;
            int height;

            string sWidth = mediaInfo.Get(StreamKind.Video, 0, "Width");
            string sHeight = mediaInfo.Get(StreamKind.Video, 0, "Height");

            if (sWidth == "")
            {
                width = 0;
            }
            else
            {
                width = Int32.Parse(sWidth);
            }

            if (sHeight == "")
            {
                height = 0;
            }
            else
            {
                height = Int32.Parse(sHeight);
            }

            if (targetSpecs.width != -1)
            {
                if (targetSpecs.height != -1)
                {
                    if (targetSpecs.width == width && targetSpecs.height == height)
                    {
                        mediaInfo.Close();
                        return true;
                    }
                    else
                    {
                        string reports = "has an incorrect resolution (" + width + "x" + height + ")";
                        failFile(file, reports, targetSpecs);
                        mediaInfo.Close();
                        return false;                       
                    }
                }


            }

            //MSW crap
            if (file.Name.ToUpper().Contains("MUSIC&THESPOKENWORD"))
            {
                if (file.Name.ToUpper().Contains("PAL"))
                {
                    if (width == 720 && height == 576)
                    {
                        mediaInfo.Close();
                        return true;
                    }
                }
            }



            //common checks
            if ((width == 640 || width == 1920 || width == 720 || width == 1280 || 
                 width == 480 || width == 486 || width == 460 || width == 1440) &&
                (height == 360 || height == 1080 || height == 480 || height == 720 || 
                 height == 360 || height == 960 || height == 248 || height == 486))
            {
                mediaInfo.Close();
                return true;
            }

            string report = "has an incorrect resolution (" + width + "x" + height + ")";
            failFile(file, report, targetSpecs);
            mediaInfo.Close();
            return false;
        }
Example #8
0
        private static bool checkForLongFile(FileInfo file, testingSpecs targetSpecs)
        {
            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            string length = mediaInfo.Get(StreamKind.General, 0, "Duration");
            int duration;
            int.TryParse(length, out duration);

            if (duration != null)
            {
                double minutes = duration / 60000;

                if (minutes > 240)
                {
                    string report = "is over 4 hours long!";
                    failFile(file, report, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
               

            }
                mediaInfo.Close();
                return true;
        }
Example #9
0
        /// <summary>
        /// checks to see if the bitrates are correct (not too high, not too low)
        /// </summary>
        /// <param name="file">the file to examine</param>
        /// <returns>returns whether the file's bitrate is correct or not</returns>
        private static bool checkBitrate(FileInfo file, testingSpecs targetSpecs)
        {

            MediaInfo mediaInfo = new MediaInfo();
            mediaInfo.Open(file.FullName);
            
            int bitrate = 0;
            
            string sBitrate = mediaInfo.Get(StreamKind.Video, 0, "BitRate");
            if(sBitrate.Contains('/'))
            {
                int badCharacterBegins = 0;
                badCharacterBegins = sBitrate.IndexOf('/');
                sBitrate = sBitrate.Remove(badCharacterBegins);
            }

            try
            {
                if (sBitrate != null)
                {
                    Int32.TryParse(sBitrate, out bitrate);
                }
                else
                {
                    bitrate = 0;
                }
            }
            catch(Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            string badBitrateReport = "failed because the bitrate was wrong (" + (bitrate / 1000).ToString() + " Kbps)";


            if (targetSpecs.bitRate != -1)
            {
                if (bitrate >= targetSpecs.bitRate)
                {
                    mediaInfo.Close();
                    return true;
                }
                failFile(file, badBitrateReport, targetSpecs);
                mediaInfo.Close();
                return false;
            }

            if (file.Name.Contains("8000k"))
            {
                if (bitrate < 1000000 || bitrate > 9000000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            else if (file.Name.Contains("2500k"))
            {
                if (bitrate < 1000000 || bitrate > 3000000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            else if (file.Name.Contains("1800k"))
            {
                if (bitrate < 800000 || bitrate > 2000000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            else if (file.Name.Contains("1000k"))
            {
                if (bitrate < 500000 || bitrate > 1800000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            else if (file.Name.Contains("300k"))
            {
                if (bitrate < 100000 || bitrate > 7000000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            else if (file.Name.Contains("2500k"))
            {
                if (bitrate < 1800000 || bitrate > 3000000)
                {
                    failFile(file, badBitrateReport, targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }

            mediaInfo.Close();
            return true;
        }
Example #10
0
        /// <summary>
        /// Checks a file to make sure it's sample rate is acceptable
        /// </summary>
        /// <param name="file">the file to check</param>
        /// <returns>the result of the check</returns>
        private static bool checkAudioSampleRate(FileInfo file, testingSpecs targetSpecs)
        {
            MediaInfo mediaInfo = new MediaInfo();
            int audioSampleRate;
            mediaInfo.Open(file.FullName);
            try
            {
                 audioSampleRate = Int32.Parse(mediaInfo.Get(StreamKind.Audio, 0, "SamplingRate"));
            }
            catch(Exception e)
            {
                return true;
            }

            if (targetSpecs.AudioSampleRate != -1)
            {
                if (audioSampleRate == targetSpecs.AudioSampleRate)
                {
                    mediaInfo.Close();
                    return true;
                }
                else
                {
                    
                    failFile(file, "has an incorrect audio samples rate (" + audioSampleRate + ")", targetSpecs);
                    mediaInfo.Close();
                    return false;
                }
            }
            if (audioSampleRate == 44100 || audioSampleRate == 48000 || audioSampleRate == 22050)
            {
                mediaInfo.Close();
                return true;
            }

            string report = "has an incorrect audio samples rate (" + audioSampleRate + ")";
            failFile(file, report, targetSpecs);
            mediaInfo.Close();
            return false;
        }