예제 #1
0
 public bool SupportsVideoCodec(VideoCodec codec)
 {
     if (supportsAnyInputtableVideoCodec)
     {
         return(true);
     }
     return(GetSupportedVideoCodecs().Contains(codec));
 }
예제 #2
0
/*		/// <summary>
 *              /// gets the predefined output size given the index of the dropdown
 *              /// </summary>
 *              /// <param name="index">the index which is currently selected in the size selection dropdown</param>
 *              /// <returns>the size in kilobytes</returns>
 *              public static int getOutputSizeKBs(int index)
 *              {
 *                      if (index == 0) // 1/4 CD
 *                              return 179200;
 *                      if (index == 1) // 1/2 CD
 *                              return 358400;
 *                      if (index == 2) // 1 CD
 *                              return 716800;
 *                      if (index == 3) // 2 CDs
 *                              return 1433600;
 *                      if (index == 4) // 3 CDs
 *                              return 2150400;
 *                      if (index == 5) // 1/3 DVD
 *                              return 1501184;
 *                      if (index == 6) // 1/4 DVD
 *                              return 1126400;
 *                      if (index == 7) // 1/5 DVD
 *                              return 901120;
 *                      if (index == 8) // 1 DVD
 *                              return 4586496;
 *          if (index == 9) //1 DVD-9
 *              return 8333760;
 *                      return 716800;
 *              }
 *              /// <summary>
 *              /// gets all the predefined output sizes
 *              /// </summary>
 *              /// <returns>an array of strings</returns>
 *              public static string[] getPredefinedOutputSizes()
 *              {
 *                      string[] values = {"1/4 CD", "1/2 CD", "1 CD", "2 CD", "3 CD", "1/3 DVD-R", "1/4 DVD-R", "1/5 DVD-R", "DVD-5", "DVD-9"};
 *                      return values;
 *              }*/
        #endregion

        public static long CalculateFileSizeKB(VideoCodec vCodec, bool p, ContainerType containerType, AudioBitrateCalculationStream[] audioStreams, int bitrate, ulong nbOfFrames, double framerate, out int vidSize)
        {
            BitrateCalculator c = new BitrateCalculator(vCodec, p, containerType, audioStreams, nbOfFrames, framerate);
            FileSize          a, b;

            c.getFileAndVideoSize((ulong)bitrate).get(out a, out b);
            vidSize = (int)b.KB;
            return((long)a.KB);
        }
예제 #3
0
        public static int CalculateBitrateKBits(VideoCodec vCodec, bool p, ContainerType containerType, AudioBitrateCalculationStream[] audioStreams, ulong muxedSizeBytes, ulong numberOfFrames, double framerate, out ulong videoSizeKBs)
        {
            BitrateCalculator c = new BitrateCalculator(vCodec, p, containerType, audioStreams, numberOfFrames, framerate);
            FileSize          b;
            ulong             a;

            c.getBitrateAndVideoSize(new FileSize(Unit.B, muxedSizeBytes)).get(out a, out b);
            videoSizeKBs = b.KB;
            return((int)a);
        }
예제 #4
0
        private static VideoType getVideoType(VideoCodec codec, ContainerType cft, string filename)
        {
            string extension = Path.GetExtension(filename).ToLower();

            foreach (VideoType t in ContainerManager.VideoTypes.Values)
            {
                if (t.ContainerType == cft && Array.IndexOf <VideoCodec>(t.SupportedCodecs, codec) >= 0 && "." + t.Extension == extension)
                {
                    return(t);
                }
            }
            return(null);
        }
예제 #5
0
        // FileSize desiredSize,
        // out FileSize targetVideoSize
        public BitrateCalculator(VideoCodec codec, bool useBframes, ContainerType container,
                                 AudioBitrateCalculationStream[] audioStreams, ulong nbOfFrames, double framerate)
        {
            nbOfSeconds = (decimal)nbOfFrames / (decimal)framerate;

            VideoOverhead = getVideoOverhead(container, useBframes, nbOfFrames, nbOfSeconds);

            AudioOverhead = FileSize.Empty;
            AudioSize     = FileSize.Empty;
            foreach (AudioBitrateCalculationStream s in audioStreams)
            {
                AudioSize     += s.Size ?? FileSize.Empty;
                AudioOverhead += getAudioOverhead(container, s.AType, nbOfSeconds, nbOfFrames);
            }
        }
예제 #6
0
 public int CalculateBitrateKBits(VideoCodec codec, bool useBframes, ContainerType container, AudioStream[] audioStreams, long desiredOutputSizeBytes, int nbOfFrames, double framerate, out long videoSizeKB)
 {
     if (container == ContainerType.MP4)
     {
         return(calculateMP4VideoBitrate(audioStreams, desiredOutputSizeBytes, nbOfFrames, useBframes, framerate, out videoSizeKB));
     }
     if (container == ContainerType.AVI)
     {
         return(calculateAVIBitrate(audioStreams, desiredOutputSizeBytes, nbOfFrames, framerate, out videoSizeKB));
     }
     if (container == ContainerType.MKV)
     {
         return(calculateMKVVideoBitrate(audioStreams, desiredOutputSizeBytes, nbOfFrames, framerate, useBframes, out videoSizeKB));
     }
     videoSizeKB = 0;
     return(0);
 }
예제 #7
0
        private VideoType getVideoType(VideoCodec codec, ContainerType cft)
        {
            ContainerType type = null;

            if (cft != null)
            {
                type = cft;
            }
            foreach (VideoType t in ContainerManager.VideoTypes.Values)
            {
                if (t.ContainerType == type && Array.IndexOf <VideoCodec>(t.SupportedCodecs, codec) >= 0)
                {
                    return(t);
                }
            }
            return(null);
        }
예제 #8
0
        public long CalculateFileSizeKB(VideoCodec codec, bool useBframes, ContainerType container, AudioStream[] audioStreams, int desiredBitrate, int nbOfFrames, double framerate, out int rawVideoSize)
        {
            if (container == ContainerType.MP4)
            {
                return(calculateMP4Size(audioStreams, desiredBitrate, nbOfFrames, useBframes, framerate, out rawVideoSize));
            }
            if (container == ContainerType.AVI)
            {
                return(calculateAVISize(audioStreams, desiredBitrate, nbOfFrames, framerate, out rawVideoSize));
            }
            if (container == ContainerType.MKV)
            {
                return(calculateMKVSize(audioStreams, desiredBitrate, nbOfFrames, framerate, useBframes, out rawVideoSize));
            }

            rawVideoSize = 0;
            return(0);
        }
예제 #9
0
 public VideoType(string name, string filterName, string extension, ContainerType containerType, VideoCodec supportedCodec)
     : this(name, filterName, extension, containerType, new VideoCodec[] { supportedCodec })
 {
 }
예제 #10
0
 public VideoEncoderType(string id, VideoCodec codec)
 {
     this.id    = id;
     this.codec = codec;
 }
예제 #11
0
        public MediaInfoFile(string file)
        {
            this.file = file;
            MediaInfo info = new MediaInfo(file);

            hasVideo = (info.Video.Count > 0);
            if (hasVideo)
            {
                VideoTrack track = info.Video[0];
                width      = easyParseInt(track.Width);
                height     = easyParseInt(track.Height);
                frameCount = easyParseInt(track.FrameCount);
                fps        = easyParseDouble(track.FrameRate);
                vCodec     = getVideoCodec(track.Codec);
#warning should parse DAR properly, as commented below
                darX = width;
                darY = height;
//                darX = easyParseInt(track.AspectRatio.Substring()
            }
            aCodecs       = new AudioCodec[info.Audio.Count];
            aBitrateModes = new BitrateManagementMode[info.Audio.Count];
            int i = 0;
            foreach (AudioTrack track in info.Audio)
            {
                aCodecs[i] = getAudioCodec(track.Codec);
                if (track.BitRateMode == "VBR")
                {
                    aBitrateModes[i] = BitrateManagementMode.VBR;
                }
                else
                {
                    aBitrateModes[i] = BitrateManagementMode.CBR;
                }
            }
            if (info.General.Count < 1)
            {
                cType = null;
            }
            else
            {
                cType = getContainerType(info.General[0].Format, info.General[0].FormatString);
            }

            if (hasVideo)
            {
                vType = getVideoType(vCodec, cType);
            }
            else
            {
                vType = null;
            }

            if (aCodecs.Length == 1)
            {
                aType = getAudioType(aCodecs[0], cType);
            }
            else
            {
                aType = null;
            }
        }
예제 #12
0
 public VideoType(string name, string filterName, string extension, ContainerType containerType, VideoCodec[] supportedCodecs)
     : base(name, filterName, extension, containerType)
 {
     this.supportedCodecs = supportedCodecs;
 }
예제 #13
0
 public VideoType(string name, string filterName, string extension, ContainerType containerType, VideoCodec supportedCodec)
     : this(name, filterName, extension, containerType, new VideoCodec[] { supportedCodec })
 {
 }
예제 #14
0
 public VideoEncoderType(string id, VideoCodec codec)
 {
     this.id = id;
     this.codec = codec;
 }
예제 #15
0
        public MediaInfoFile(string file)
        {
            this.file = file;
            MediaInfo info = new MediaInfo(file);

            bool hasVideo = (info.Video.Count > 0);

            aCodecs       = new AudioCodec[info.Audio.Count];
            aBitrateModes = new BitrateManagementMode[info.Audio.Count];
            int i = 0;

            foreach (MediaInfoWrapper.AudioTrack track in info.Audio)
            {
                aCodecs[i] = getAudioCodec(track.Codec);
                if (track.BitRateMode == "VBR")
                {
                    aBitrateModes[i] = BitrateManagementMode.VBR;
                }
                else
                {
                    aBitrateModes[i] = BitrateManagementMode.CBR;
                }
            }
            if (info.General.Count < 1)
            {
                cType = null;
            }
            else
            {
                cType = getContainerType(info.General[0].Format, info.General[0].FormatString);
            }

            if (aCodecs.Length == 1)
            {
                aType = getAudioType(aCodecs[0], cType, file);
            }
            else
            {
                aType = null;
            }

            if (hasVideo)
            {
                MediaInfoWrapper.VideoTrack track = info.Video[0];
                checked
                {
                    ulong  width      = (ulong)easyParseInt(track.Width);
                    ulong  height     = (ulong)easyParseInt(track.Height);
                    ulong  frameCount = (ulong)easyParseInt(track.FrameCount);
                    double fps        = (easyParseDouble(track.FrameRate) ?? 25.0);
                    vCodec = getVideoCodec(track.Codec);
                    vType  = getVideoType(vCodec, cType, file);
                    Dar dar = new Dar((decimal?)easyParseDouble(track.AspectRatio), width, height);
                    this.info = new MediaFileInfo(hasVideo, width, height, dar, frameCount, fps, aCodecs.Length > 0);
                }
            }
            else
            {
                this.info = new MediaFileInfo(false, 0, 0, Dar.A1x1, 0, 0, aCodecs.Length > 0);
            }
        }