示例#1
0
        /// <summary>
        /// Configures the recording session for webcam only.
        /// </summary>
        /// <param name="frameRate"></param>
        /// <returns></returns>
        public static bool ConfigureWebcamOnly(uint frameRate)
        {
            Store.Data.Obs.WebcamScene.ClearItems();
            Store.Data.Obs.WebcamScene.Add(Store.Data.Webcam.Source);
            Store.Data.Obs.WebcamScene.Add(Store.Data.Audio.InputSource);
            Store.Data.Obs.Presentation.SetScene(Store.Data.Obs.WebcamScene);

            var obsVideoInfo = new GenerateObsVideoInfoParameters
            {
                BaseWidth    = Store.Data.Webcam.Source.Width,
                OutputWidth  = Store.Data.Webcam.Source.Width,
                BaseHeight   = Store.Data.Webcam.Source.Height,
                OutputHeight = Store.Data.Webcam.Source.Height,
                FrameRate    = GetFrameRate(frameRate)
            };

            obs_video_info ovi = ObsHelper.GenerateObsVideoInfoObject(obsVideoInfo);

            if (!Obs.ResetVideo(ovi))
            {
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Generates a new ObsVideoInfo object.
 /// </summary>
 /// <param name="obsVideoInfo"></param>
 /// <returns></returns>
 public static obs_video_info GenerateObsVideoInfoObject(GenerateObsVideoInfoParameters obsVideoInfo)
 {
     return(new obs_video_info
     {
         adapter = 0,
         base_width = obsVideoInfo.BaseWidth,
         base_height = obsVideoInfo.BaseHeight,
         output_width = obsVideoInfo.OutputWidth,
         output_height = obsVideoInfo.OutputHeight,
         fps_den = Constants.Video.FPS_DEN,
         fps_num = obsVideoInfo.FrameRate,
         graphics_module = "libobs-d3d11.dll",
         output_format = video_format.VIDEO_FORMAT_NV12,
         scale_type = obs_scale_type.OBS_SCALE_BICUBIC,
         colorspace = video_colorspace.VIDEO_CS_601,
         range = video_range_type.VIDEO_RANGE_PARTIAL,
         gpu_conversion = true,
     });
 }
示例#3
0
        /// <summary>
        /// Resets and updates the video settings for video output.
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static bool ResetVideoInfo(ResetVideoInfoParameters parameters)
        {
            if (Store.Data.Obs.Presentation != null)
            {
                if (Store.Data.Obs.Presentation.SelectedScene.GetName().ToLowerInvariant() != "main")
                {
                    Store.Data.Obs.Presentation.SetScene(0);
                }
            }

            Store.Data.Record.AppliedCrop = new obs_sceneitem_crop
            {
                left   = parameters.CropLeft,
                top    = parameters.CropTop,
                right  = parameters.CropRight,
                bottom = parameters.CropBottom
            };

            Store.Data.Record.ActiveScreen = ScreenHelper.GetScreen(parameters.ScreenX, parameters.ScreenY);

            //Set the proper display source
            if (Store.Data.Display.DisplaySource != null)
            {
                ObsData displaySettings = new ObsData();
                displaySettings.SetBool("capture_cursor", true);

                displaySettings.SetInt("monitor", ObsHelper.GetObsDisplayValueFromScreen(Store.Data.Display.DisplaySource, Store.Data.Record.ActiveScreen));

                Store.Data.Display.DisplaySource.Update(displaySettings);
                displaySettings.Dispose();
            }

            //Set the proper display bounds and crop
            if (Store.Data.Display.DisplayItem != null)
            {
                Store.Data.Display.DisplayItem.SetBounds(new Vector2(0, 0), ObsBoundsType.None, ObsAlignment.Top);
                Store.Data.Display.DisplayItem.SetCrop(Store.Data.Record.AppliedCrop);
            }

            WebcamService.CalculateItemPosition();

            var obsVideoInfo = new GenerateObsVideoInfoParameters
            {
                BaseWidth    = (uint)parameters.CanvasWidth,
                OutputWidth  = (uint)parameters.OutputWidth,
                BaseHeight   = (uint)parameters.CanvasHeight,
                OutputHeight = (uint)parameters.OutputHeight,
                FrameRate    = GetFrameRate(parameters.FrameRate)
            };

            obs_video_info ovi = ObsHelper.GenerateObsVideoInfoObject(obsVideoInfo);

            if (!Obs.ResetVideo(ovi))
            {
                return(false);
            }

            Store.Data.Record.CanvasHeight = parameters.CanvasHeight;
            Store.Data.Record.CanvasWidth  = parameters.CanvasWidth;

            return(true);
        }