示例#1
0
        private void view_AboutVideCompressor(object sender, EventArgs e)
        {
            VideoCompressor compressor = this.view.VideoCompressor as VideoCompressor;

            if (compressor != null)
            {
                compressor.About(this.view.Handle);
            }
        }
示例#2
0
        private void view_ConfigureVideoCompressor(object sender, EventArgs e)
        {
            VideoCompressor compressor = this.view.VideoCompressor as VideoCompressor;

            if (compressor != null)
            {
                compressor.Configure(this.view.Handle);
            }
        }
        static void Main()
        {
            var video = new Video();

            video.Title = "movie";
            var videoCompressor = new VideoCompressor();

            //Subscription
            videoCompressor.VideoCompressed += VideoCompressor_VideoCompressed;

            videoCompressor.CompressVideo(video);
        }
        public async Task CompressVideo(string srcPath, string destPath, int bitrateMode = 10)
        {
            await Task.Delay(10);

            try
            {
                //Get the video metadata
                var mediaMetadataRetriever = new MediaMetadataRetriever();
                mediaMetadataRetriever.SetDataSource(srcPath);
                string bitrateData = mediaMetadataRetriever.ExtractMetadata(Android.Media.MetadataKey.Bitrate);
                string videoHeight = mediaMetadataRetriever.ExtractMetadata(Android.Media.MetadataKey.VideoHeight);
                string videoWidth  = mediaMetadataRetriever.ExtractMetadata(Android.Media.MetadataKey.VideoWidth);

                //Define default quality compress
                var videoQuality = VideoQuality.High;

                bitrateMode = bitrateMode == 10 ? bitrateMode10 : bitrateMode2;

                if (!string.IsNullOrEmpty(bitrateData))
                {
                    int bitrate = 0;
                    int.TryParse(bitrateData, out bitrate);
                    bitrate /= 1024;

                    if (bitrate > bitrateMode2)
                    {
                        float reduce = (float)bitrate / (float)bitrateMode2;
                        if (reduce > 6)
                        {
                            videoQuality = VideoQuality.Low;
                        }
                        else if (reduce > 3)
                        {
                            videoQuality = VideoQuality.Medium;
                        }
                    }
                }

                var listener = new CompressionListener();
                listener.ProgressPercent += Percent;
                listener.Fail            += Fail;
                listener.Success         += (sender, e) =>
                {
                    Success(this, true);
                };

                VideoCompressor.Start(srcPath, destPath, listener, videoQuality, false, false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
示例#5
0
        public TgaSequenceConverter()
        {
            _tgaLoader = new TargaImageLoader();
            _tga       = new TargaImage();
            _bmp       = new BitmapImage();
            _converter = new TgaToBmpConverter();

            _frameRate          = 30;
            _frameBlendingIndex = 0;
            _frameProcessIndex  = 0;
            _deleteOnClose      = false;
            _compressor         = null;
        }
示例#6
0
        private void view_Load(object sender, EventArgs e)
        {
            // TODO: Display screen bit depth (16, 24 and 32 is currently supported)
            // Read config
            Configuration config = this.view.Configuration;

            if (config == null)
            {
                return;
            }
            // Get list of sound devices
            SoundDevice[] soundDevices = SoundProvider.GetDevices();
            this.view.SoundDevices = soundDevices;
            string soundDeviceId = config.Sound.DeviceId;

            if (!string.IsNullOrEmpty(soundDeviceId))
            {
                foreach (var soundDevice in soundDevices)
                {
                    if (soundDevice.Id.Equals(soundDeviceId))
                    {
                        this.view.SoundDevice = soundDevice;
                        break;
                    }
                }
            }
            // Get list of video compressors
            var compressors = new List <VideoCompressor>(VideoCompressor.GetAll());

            compressors.Add(VideoCompressor.None);
            this.view.VideoCompressors = compressors.ToArray();
            string compressorFCC = this.view.Configuration.Video.Compressor;

            // Find video compressor using it's ffc handler string
            if (!string.IsNullOrEmpty(compressorFCC))
            {
                foreach (var compressor in compressors)
                {
                    uint fccHandler = VideoCompressor.FccHandlerFromString(compressorFCC);
                    if (compressor.FccHandler == fccHandler)
                    {
                        this.view.VideoCompressor = compressor;
                        break;
                    }
                }
            }
        }
        private void UpdateCompressorSettings()
        {
            if (((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor == null)
            {
                lblCurrentSettings.Text += string.Format(CultureInfo.CurrentCulture, "\r\n\r\n" +
                                                         Strings.CompressorDisabled2, TAB);
            }
            else
            {
                VideoCompressor            vcomp = ((IVideoCaptureGraph)vc.CaptureGraph).VideoCompressor;
                VideoCompressorQualityInfo vcqi  = vcomp.QualityInfo;

                lblCurrentSettings.Text += string.Format(CultureInfo.CurrentCulture, "\r\n\r\n" +
                                                         Strings.CompressorStatus, TAB, vcomp.FriendlyName,
                                                         MediaType.SubType.GuidToString(vcqi.MediaSubType), vcqi.BitRate / 1000, KeyFrameRateString);
            }
        }
示例#8
0
        /// <summary>
        /// Adds a video compressor if needed by checking the registry
        /// </summary>
        public void AddVideoCompressor()
        {
            if (RegVideoCompressorEnabled)
            {
                // Add compressor to the graph and dump its features
                vcg.AddCompressor(VideoCompressor.DefaultFilterInfo());
                Log(vcg.VideoCompressor.Dump());

                if (RegCustomCompression)
                {
                    RestoreVideoCompressorSettings();
                }
                else
                {
                    DefaultVideoCompressorSettings();
                }
            }
        }
示例#9
0
        private void view_CompressorChanged(object sender, EventArgs e)
        {
            VideoCompressor comressor = this.view.VideoCompressor;

            if (comressor != null)
            {
                this.view.VideoCompressorQualitySupport = comressor.SupportsQuality;
                if (this.view.VideoQuality <= 0)
                {
                    this.view.VideoQuality = (int)comressor.Quality / 100;
                }
            }
            else
            {
                this.view.VideoCompressorQualitySupport = false;
                this.view.VideoQuality = 0;
            }
        }
        // CF2 (with some changes for network)
        private void cklbCameras_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked)
            {
                UncheckAllDevices();

                // Create the graph for the device
                vcg = new VideoCaptureGraph((FilterInfo)cklbCameras.SelectedItem);

                // Add a compressor and configure it
                vcg.AddCompressor(VideoCompressor.DefaultFilterInfo());
                vcg.VideoCompressor.QualityInfo = VideoCompressor.DefaultQualityInfo;

                // Add network filter
                vcg.RenderNetwork(rtpSender);

                // Send data to network
                vcg.Run();
            }
            else // Unchecked
            {
                DisposeDevice();
            }
        }
示例#11
0
 public CompressedAviFileWriter(string path, int frameRate, VideoCompressor compressor, bool audio)
     : base(path, frameRate, FourCC.dc00, compressor.Info.FccHandler, 0, compressor.OutputFormat, audio)
 {
     _compressor = compressor;
 }
示例#12
0
        private static AviFileWriter InternalCreate(string path, int frameRate, BitmapInfo videoFormat, bool audio, VideoCompressor compressor)
        {
            if (compressor == null)
            {
                return(new UncompressedAviFileWriter(path, frameRate, videoFormat, audio));
            }

            compressor.Begin(videoFormat);

            try
            {
                return(new CompressedAviFileWriter(path, frameRate, compressor, audio));
            }
            catch (Exception)
            {
                compressor.End();
                throw;
            }
        }
示例#13
0
        /// <exception cref="System.ArgumentNullException">path is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">frameRate is not positive.</exception>
        /// <exception cref="System.ArgumentException">width of videoFormat is not positive or is larger than <see cref="MaxWidth"/>. -or- height of videoFormat is not positive or is larger than <see cref="MaxHeight"/>. -or- path is a zero-length string, contains only white space, contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.</exception>
        /// <exception cref="System.IO.IOException">An I/O error occurred.</exception>
        /// <exception cref="System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
        /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
        /// <exception cref="System.NotSupportedException">path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.</exception>
        /// <exception cref="System.InvalidOperationException">Video compressor is already compressing.</exception>
        /// <exception cref="AviRecorder.Video.Compression.VideoCompressorException">An error occured while accessing the internal video compressor.</exception>
        public static AviFileWriter Create(string path, int frameRate, BitmapInfo videoFormat, bool audio, VideoCompressor compressor)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (frameRate < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(frameRate));
            }
            if (videoFormat == null)
            {
                throw new ArgumentNullException(nameof(videoFormat));
            }

            var width = videoFormat.Width;

            if (width < 1 || width > MaxWidth)
            {
                throw new ArgumentException("The width of the video format is out of range.", nameof(videoFormat));
            }

            var height = Math.Abs(videoFormat.Height);

            if (height < 1 || height > MaxHeight)
            {
                throw new ArgumentException("The height of the video format is out of range.", nameof(videoFormat));
            }

            return(InternalCreate(path, frameRate, videoFormat, audio, compressor));
        }
示例#14
0
        /// <exception cref="System.ArgumentNullException">path is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">width is not positive or is larger than <see cref="MaxWidth"/>. -or- height is not positive or is larger than <see cref="MaxHeight"/>. -or- frameRate is not positive.</exception>
        /// <exception cref="System.ArgumentException">path is a zero-length string, contains only white space, contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.</exception>
        /// <exception cref="System.IO.IOException">An I/O error occurred.</exception>
        /// <exception cref="System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
        /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
        /// <exception cref="System.NotSupportedException">path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.</exception>
        /// <exception cref="System.InvalidOperationException">Video compressor is already compressing.</exception>
        /// <exception cref="AviRecorder.Video.Compression.VideoCompressorException">An error occured while accessing the internal video compressor.</exception>
        public static AviFileWriter Create(string path, int width, int height, int frameRate, bool audio, VideoCompressor compressor)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (width < 1 || width > MaxHeight)
            {
                throw new ArgumentOutOfRangeException(nameof(width));
            }
            if (height < 1 || height > MaxHeight)
            {
                throw new ArgumentOutOfRangeException(nameof(height));
            }
            if (frameRate < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(frameRate));
            }

            return(InternalCreate(path, frameRate, BitmapInfo.CreateRgb24(width, height), audio, compressor));
        }