Пример #1
0
        IVideoWriterItem HandleVideoEncoder(StartCmdOptions StartOptions, out IVideoWriterProvider VideoWriterKind)
        {
            var ffmpegExists           = FFmpegService.FFmpegExists;
            var sharpAviWriterProvider = ServiceProvider.Get <SharpAviWriterProvider>();

            // FFmpeg
            if (ffmpegExists && Regex.IsMatch(StartOptions.Encoder, @"^ffmpeg:\d+$"))
            {
                var index = int.Parse(StartOptions.Encoder.Substring(7));

                var ffmpegWriterProvider = ServiceProvider.Get <FFmpegWriterProvider>();
                var writers = ffmpegWriterProvider.ToArray();

                if (index < writers.Length)
                {
                    VideoWriterKind = ffmpegWriterProvider;

                    return(writers[index]);
                }
            }

            // SharpAvi
            else if (ServiceProvider.FileExists("SharpAvi.dll") && Regex.IsMatch(StartOptions.Encoder, @"^sharpavi:\d+$"))
            {
                var index = int.Parse(StartOptions.Encoder.Substring(9));

                var writers = sharpAviWriterProvider.ToArray();

                if (index < writers.Length)
                {
                    VideoWriterKind = sharpAviWriterProvider;

                    return(writers[index]);
                }
            }

            // Stream
            else if (ffmpegExists && Regex.IsMatch(StartOptions.Encoder, @"^stream:\S+$"))
            {
                var url = StartOptions.Encoder.Substring(7);
                _settings.FFmpeg.CustomStreamingUrl = url;

                VideoWriterKind = ServiceProvider.Get <StreamingWriterProvider>();

                return(StreamingWriterProvider.GetCustomStreamingCodec());
            }

            // Rolling
            else if (ffmpegExists && Regex.IsMatch(StartOptions.Encoder, @"^roll:\d+$"))
            {
                var duration = int.Parse(StartOptions.Encoder.Substring(5));

                VideoWriterKind = ServiceProvider.Get <FFmpegWriterProvider>();

                return(new FFmpegRollingWriterItem(duration));
            }

            VideoWriterKind = sharpAviWriterProvider;
            return(sharpAviWriterProvider.First());
        }
Пример #2
0
        void HandleVideoEncoder(StartCmdOptions StartOptions)
        {
            if (StartOptions.Encoder == null)
            {
                return;
            }

            // FFmpeg
            if (FFmpegService.FFmpegExists && Regex.IsMatch(StartOptions.Encoder, @"^ffmpeg:\d+$"))
            {
                var index = int.Parse(StartOptions.Encoder.Substring(7));

                _videoWritersViewModel.SelectedVideoWriterKind = ServiceProvider.Get <FFmpegWriterProvider>();

                if (index < _videoWritersViewModel.AvailableVideoWriters.Count)
                {
                    _videoWritersViewModel.SelectedVideoWriter = _videoWritersViewModel.AvailableVideoWriters[index];
                }
            }

            // SharpAvi
            else if (ServiceProvider.FileExists("SharpAvi.dll") && Regex.IsMatch(StartOptions.Encoder, @"^sharpavi:\d+$"))
            {
                var index = int.Parse(StartOptions.Encoder.Substring(9));

                _videoWritersViewModel.SelectedVideoWriterKind = ServiceProvider.Get <SharpAviWriterProvider>();

                if (index < _videoWritersViewModel.AvailableVideoWriters.Count)
                {
                    _videoWritersViewModel.SelectedVideoWriter = _videoWritersViewModel.AvailableVideoWriters[index];
                }
            }

            // Stream
            else if (FFmpegService.FFmpegExists && Regex.IsMatch(StartOptions.Encoder, @"^stream:\S+$"))
            {
                var url = StartOptions.Encoder.Substring(7);
                _settings.FFmpeg.CustomStreamingUrl = url;

                _videoWritersViewModel.SelectedVideoWriterKind = ServiceProvider.Get <StreamingWriterProvider>();

                _videoWritersViewModel.SelectedVideoWriter = StreamingWriterProvider.GetCustomStreamingCodec();
            }
        }