public FlvContainerSettings(IAudioSettings audio, IVideoSettings video, IWatermarkSettings watermark)
		{
			FileNameExtension = "flv";
			Audio = audio;

			//These are the only 2 supported audio codecs by flv
			//Flash 9 is required for AAC support
			if (!(Audio.CodecName == "libmp3lame" || Audio.CodecName == "libvo_aacenc"))
			{
				Audio.CodecName = "libmp3lame";
			}

			//Only the following frequencies are supported by flv when using mp3
			if (Audio.CodecName == "libmp3lame")
			{
				if (!(Audio.Frequency == 11025 || Audio.Frequency == 22050 || Audio.Frequency == 44100))
				{
					Audio.Frequency = 22050;
				}
			}

			Video = video;
			Watermark = watermark;

			AllowedMetaData = new List<string>();
		}
		public Mp4ContainerSettings(IAudioSettings audio, IVideoSettings video, IWatermarkSettings watermark)
		{
			FileNameExtension = "mp4";
			Audio = audio;
			Video = video;
			Watermark = watermark;
			AllowedMetaData = new List<string>
			               	{
			               		"Title",
								"Artist",
								"AlbumArtist",
			               		"Album",
			               		"Grouping",
			               		"Composer",
			               		"Year",
								"Track",
			               		"Comment",
								"Genre",
								"Copyright",
								"Description",
								"Synopsis",
								"Show",
								"EpisodeId",
								"Network",
								"Lyrics",
			               	};
		}
Example #3
0
        public VideoService(IVideoSettings settings)
        {
            _VideoChannels = new List <VideoChannel>();
            _VideoChannels.AddRange(settings.VideoChannels);

            SelectedVideoChannel = _VideoChannels.First();

            Volume = 50;
        }
		public OggContainerSettings(IAudioSettings audio, IVideoSettings video, IWatermarkSettings watermark)
		{
			FileNameExtension = "ogv";
			Audio = audio;
			Audio.CodecName = "libvorbis"; //This is the only supported audio codec for the ogg container
			Video = video;
			Watermark = watermark;
			AllowedMetaData = new List<string>();
		}
Example #5
0
        private void GeneratePreview()
        {
            IVideoSettings videoSettings = ModelResolver.Resolve <IVideoSettings>();

            videoSettings.FileName       = SelectedMouse.VideoFileName;
            videoSettings.ThresholdValue = BinaryThreshold;
            videoSettings.Roi            = ROI;
            Image <Gray, Byte>          binaryBackground;
            IEnumerable <IBoundaryBase> boundaries;

            videoSettings.GeneratePreview(Video, out binaryBackground, out boundaries);
            BinaryBackground = binaryBackground;
            VideoSettings    = videoSettings;
            PreviewGenerated = true;
        }
		public WebmContainerSettings(IAudioSettings audio, IVideoSettings video, IWatermarkSettings watermark)
		{
			FileNameExtension = "webm";
			Audio = audio;
			Audio.CodecName = "libvorbis"; //This is the only supported audio codec for the webm container
			Video = video;
			Watermark = watermark;

			AllowedMetaData = new List<string>
			               	{
			               		"Title",
								"Description",
								"Langauge",
			               	};
		}
Example #7
0
        // Sets up the options to show on the page
        private void CreateVideoSettingItems()
        {
            IVideoSettings videoSettings = _settingsManager.Settings.Video;

            // Add the resolution options

            _resolutionsItem = new MenuItem {
                Name = StringResources.Resolution
            };
            foreach (Vector2 resolution in _settingsManager.GetSupportedResolutions())
            {
                _resolutionsItem.Options.Add(new MenuItemOption
                {
                    Text  = string.Format("{0}x{1}", resolution.X, resolution.Y),
                    Value = resolution
                });
            }
            _resolutionsItem.SelectedValue = videoSettings.Resolution;
            Items.Add(_resolutionsItem);

            // Add the VSync option

            _vSyncItem = new MenuItem {
                Name = StringResources.VSync
            };
            _vSyncItem.Options.Add(new MenuItemOption {
                Text = StringResources.On, Value = true
            });
            _vSyncItem.Options.Add(new MenuItemOption {
                Text = StringResources.Off, Value = false
            });
            _vSyncItem.SelectedValue = videoSettings.VSync;
            Items.Add(_vSyncItem);

            // Add the full screen option

            _fullScreenItem = new MenuItem();
            _fullScreenItem.Options.Add(new MenuItemOption {
                Text = StringResources.FullScreen, Value = true
            });
            _fullScreenItem.Options.Add(new MenuItemOption {
                Text = StringResources.Windowed, Value = false
            });
            _fullScreenItem.SelectedValue = videoSettings.FullScreen;
            Items.Add(_fullScreenItem);
        }
		public AviContainerSettings(IAudioSettings audio, IVideoSettings video, IWatermarkSettings watermark)
		{
			FileNameExtension = "avi";
			Audio = audio;
			Video = video;
			Watermark = watermark;

			AllowedMetaData = new List<string>()
			               	{
			               		"Title",
			               		"Artist", 
			               		"Copyright", 
			               		"Comment", 
			               		"Album", 
			               		"Genre", 
			               		"Track",
			               	};
		}
		private static StringBuilder GetOptions(IVideoSettings settings)
		{
			var videoOptions = new Dictionary<string, string>()
			                   	{
			                   		{"-codec:v", settings.CodecName}
			                   	};

			if (settings.Width > 0 || settings.Height > 0)
			{
				videoOptions.Add("-s", string.Format("{0}x{1}", settings.Width, settings.Height));
			}

			if (settings.BitRate > 0)
			{
				videoOptions.Add("-b:v", settings.BitRate.ToString());
			}
			if (settings.MaxBitRate > 0)
			{
				videoOptions.Add("-maxrate", settings.MaxBitRate.ToString());
			}
			if (settings.BufferSize > 0)
			{
				videoOptions.Add("-bufsize", settings.BufferSize.ToString());
			}
			if (settings.FrameRate > 0)
			{
				videoOptions.Add("-r", settings.FrameRate.ToString());
			}
			if (settings.KeyframeInterval > 0)
			{
				videoOptions.Add("-g", settings.KeyframeInterval.ToString());
			}
			if (settings.MinKeyframeInterval > 0)
			{
				videoOptions.Add("-keyint_min", settings.MinKeyframeInterval.ToString());
			}

			var value = videoOptions.Select(x=>x.Key + " " + x.Value).Aggregate(new StringBuilder(), (x, y) => x.Append(" " + y));

			return value;
		}
Example #10
0
        private void ReRunVideo(string fileName)
        {
            ProgressView      view      = new ProgressView();
            ProgressViewModel viewModel = new ProgressViewModel();

            view.DataContext         = viewModel;
            viewModel.CancelPressed += (sender, args) =>
            {
                CancelReRun();
            };

            viewModel.WindowAboutToClose += (sender, args) =>
            {
                if (RbskVideo != null)
                {
                    RbskVideo.Paused = true;
                }
            };

            viewModel.WindowClosingCancelled += (sender, args) =>
            {
                if (RbskVideo != null)
                {
                    RbskVideo.Paused = false;
                }
            };

            CancelTask = false;

            Task.Factory.StartNew(() =>
            {
                IMouseDataResult result = Model.Results[SelectedVideo.Model];
                try
                {
                    IVideoSettings videoSettings = ModelResolver.Resolve <IVideoSettings>();
                    using (IRBSKVideo rbskVideo = ModelResolver.Resolve <IRBSKVideo>())
                        using (IVideo video = ModelResolver.Resolve <IVideo>())
                        {
                            RbskVideo = rbskVideo;
                            video.SetVideo(fileName);
                            if (video.FrameCount < 100)
                            {
                                result.VideoOutcome = SingleFileResult.FrameCountTooLow;
                                result.Message      = "Exception: " + SelectedVideo.VideoFileName + " - Frame count too low";
                                //allResults.TryAdd(file, result);
                                viewModel.ProgressValue = 1;
                                //continue;
                                return;
                            }

                            videoSettings.FileName       = SelectedVideo.VideoFileName;
                            videoSettings.ThresholdValue = BinaryThreshold;


                            video.SetFrame(0);
                            Image <Gray, Byte> binaryBackground;
                            IEnumerable <IBoundaryBase> boundaries;
                            videoSettings.GeneratePreview(video, out binaryBackground, out boundaries);
                            result.Boundaries = boundaries.ToArray();

                            rbskVideo.GapDistance    = GapDistance;
                            rbskVideo.ThresholdValue = BinaryThreshold;

                            rbskVideo.Video           = video;
                            rbskVideo.BackgroundImage = binaryBackground;

                            rbskVideo.ProgressUpdates += (s, e) =>
                            {
                                double progress = e.Progress;
                                if (progress >= 1)
                                {
                                    progress = 0.999;
                                }
                                Application.Current.Dispatcher.Invoke(() =>
                                {
                                    viewModel.ProgressValue = progress;
                                });
                            };

                            rbskVideo.Process();
                            RbskVideo = null;
                            //if (Stop)
                            //{
                            //    state.Stop();
                            //    return;
                            //}
                            if (CancelTask)
                            {
                                return;
                            }
                            result.Results = rbskVideo.HeadPoints;
                            result.GenerateResults();
                            result.VideoOutcome = SingleFileResult.Ok;
                            //allResults.TryAdd(SelectedVideo, result);
                        }

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        result.ResetFrames();
                        Results[SelectedVideo.Model] = result;
                        CurrentResult = result;
                        SliderValueChanged();
                        SaveCommand.RaiseCanExecuteChangedNotification();
                        viewModel.ProgressValue = 1;
                        SelectedVideoChanged();
                    });
                }
                catch (Exception e)
                {
                    result.VideoOutcome = SingleFileResult.Error;
                    result.Message      = "Exception: " + SelectedVideo.VideoFileName + " - " + e.Message;
                    //allResults.TryAdd(SelectedVideo, result);
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        viewModel.ProgressValue = 1;
                    });
                    RbskVideo = null;
                }
            });

            view.ShowDialog();
        }
Example #11
0
        public void RunFiles(string outputLocation)
        {
            if (!string.IsNullOrWhiteSpace(outputLocation))
            {
                if (!outputLocation.EndsWith("\\"))
                {
                    outputLocation += "\\";
                }
            }

            Rbsk = new ConcurrentBag <IRBSKVideo2>();
            ConcurrentDictionary <ISingleFile, IMouseDataExtendedResult> allResults = new ConcurrentDictionary <ISingleFile, IMouseDataExtendedResult>();
            List <ISingleFile> files = VideoFiles;

            foreach (var file in files)
            {
                IMouseDataExtendedResult result = ModelResolver.Resolve <IMouseDataExtendedResult>();
                result.Name = file.VideoFileName;
                result.Type = Type;

                ISaveArtFile save = ModelResolver.Resolve <ISaveArtFile>();
                string       artFile;
                string       videoFile = file.VideoFileName;
                if (string.IsNullOrWhiteSpace(outputLocation))
                {
                    string extension = Path.GetExtension(videoFile);
                    artFile = videoFile.Replace(extension, ".arwt");
                }
                else
                {
                    string fileName = Path.GetFileNameWithoutExtension(videoFile);
                    fileName += ".arwt";
                    artFile   = outputLocation + fileName;
                }

                ArtFile = artFile;

                if (File.Exists(artFile))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(TrackedVideoWithSettingsXml));
                    TrackedVideoWithSettingsXml trackedVideoXml;

                    try
                    {
                        using (StreamReader reader = new StreamReader(artFile))
                        {
                            trackedVideoXml = (TrackedVideoWithSettingsXml)serializer.Deserialize(reader);
                        }
                    }
                    catch (Exception)
                    {
                        using (StreamReader reader = new StreamReader(artFile))
                        {
                            XmlSerializer serializer2 = new XmlSerializer(typeof(TrackedVideoXml));
                            trackedVideoXml = new TrackedVideoWithSettingsXml((TrackedVideoXml)serializer2.Deserialize(reader));
                        }
                    }

                    ITrackedVideo trackedVideo = trackedVideoXml.GetData();

                    result.Boundaries        = trackedVideo.Boundries;
                    result.VideoOutcome      = trackedVideo.Result;
                    result.GapDistance       = trackedVideo.GapDistance;
                    result.WhiskerSettings   = trackedVideo.WhiskerSettings;
                    result.ThresholdValue    = trackedVideo.ThresholdValue;
                    result.ThresholdValue2   = trackedVideo.ThresholdValue2;
                    result.StartFrame        = trackedVideo.StartFrame;
                    result.EndFrame          = trackedVideo.EndFrame;
                    result.SmoothMotion      = trackedVideo.SmoothMotion;
                    result.FrameRate         = trackedVideo.FrameRate;
                    result.UnitsToMilimeters = trackedVideo.UnitsToMilimeters;
                    result.SmoothFactor      = 0.68;
                    result.GenerateResults(artFile);
                    result.PelvicArea  = trackedVideo.PelvicArea1;
                    result.PelvicArea2 = trackedVideo.PelvicArea2;
                    result.PelvicArea3 = trackedVideo.PelvicArea3;
                    result.PelvicArea4 = trackedVideo.PelvicArea4;
                    result.Results     = trackedVideo.Results;
                    result.GenerateResults();
                    result.DataLoadComplete();

                    allResults.TryAdd(file, result);

                    UpdateProgress(file, 1);
                    continue;
                }

                try
                {
                    IVideoSettings videoSettings = ModelResolver.Resolve <IVideoSettings>();
                    using (IRBSKVideo2 rbskVideo = ModelResolver.Resolve <IRBSKVideo2>())
                        using (IVideo video = ModelResolver.Resolve <IVideo>())
                        {
                            Rbsk.Add(rbskVideo);
                            video.SetVideo(file.VideoFileName);
                            if (video.FrameCount <= 100)
                            {
                                result.VideoOutcome = SingleFileResult.FrameCountTooLow;
                                result.Message      = "Exception: " + file.VideoFileName + " - Frame count too low";
                                allResults.TryAdd(file, result);
                                UpdateProgress(file, 1);
                                save.SaveFile(artFile, videoFile, result);
                                continue;
                            }

                            result.FrameRate = video.FrameRate;
                            video.SetFrame(0);

                            videoSettings.FileName       = file.VideoFileName;
                            videoSettings.ThresholdValue = ThresholdValue;
                            videoSettings.Roi            = ROI;
                            Image <Gray, Byte>          binaryBackground;
                            IEnumerable <IBoundaryBase> boundaries;
                            videoSettings.GeneratePreview(video, out binaryBackground, out boundaries);
                            result.Boundaries = boundaries.ToArray();

                            rbskVideo.Video            = video;
                            rbskVideo.GapDistance      = GapDistance;
                            rbskVideo.BackgroundImage  = binaryBackground;
                            rbskVideo.ThresholdValue   = ThresholdValue;
                            rbskVideo.ThresholdValue2  = ThresholdValue2;
                            rbskVideo.Roi              = ROI;
                            rbskVideo.WhiskerSettings  = WhiskerSettings;
                            rbskVideo.FindWhiskers     = true;
                            rbskVideo.ProgressUpdates += (s, e) => UpdateProgress(file, e.Progress);
                            rbskVideo.Process();

                            if (Stop)
                            {
                                return;
                            }

                            result.GapDistance            = rbskVideo.GapDistance;
                            result.WhiskerSettings        = rbskVideo.WhiskerSettings;
                            result.MinInteractionDistance = 15;
                            result.ThresholdValue         = rbskVideo.ThresholdValue;
                            result.ThresholdValue2        = rbskVideo.ThresholdValue2;
                            result.WhiskerSettings        = WhiskerSettings;
                            result.Results = rbskVideo.HeadPoints;
                            result.ResetFrames();
                            //result.FrameRate = FrameRate;
                            result.SmoothMotion = SmoothMotion;
                            result.GenerateResults();
                            result.VideoOutcome = SingleFileResult.Ok;
                            result.DataLoadComplete();
                            allResults.TryAdd(file, result);

                            save.SaveFile(artFile, videoFile, result);
                        }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.Message);
                    result.VideoOutcome = SingleFileResult.Error;
                    result.Message      = "Exception: " + file.VideoFileName + " - " + e.Message + " - " + e.StackTrace;
                    result.DataLoadComplete();
                    allResults.TryAdd(file, result);
                    UpdateProgress(file, 1);
                    save.SaveFile(artFile, videoFile, result);
                }

                if (Cancel)
                {
                    break;
                }

                if (Stop)
                {
                    return;
                }
            }

            if (Stop)
            {
                return;
            }

            Application.Current.Dispatcher.Invoke(() =>
            {
                try
                {
                    Results = allResults.ToDictionary(x => x.Key, x => x.Value);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error in single mouse viewmodel!!! " + e.InnerException);
                }
            });
        }
Example #12
0
 public VideoController(IVideoSettings conf, IVideoService videoService)
 {
     config            = conf;
     this.videoService = videoService;
 }