private void RefreshSourcesAsync() { btnRefreshSources.Enabled = false; DirectShowDevices devices = null; TaskEx.Run(() => { using (FFmpegHelper ffmpeg = new FFmpegHelper(Options)) { devices = ffmpeg.GetDirectShowDevices(); } }, () => { cboVideoSource.Items.Clear(); cboVideoSource.Items.Add(FFmpegHelper.GDIgrab); cboAudioSource.Items.Clear(); cboAudioSource.Items.Add("None"); if (devices != null) { cboVideoSource.Items.AddRange(devices.VideoDevices.ToArray()); cboAudioSource.Items.AddRange(devices.AudioDevices.ToArray()); } cboVideoSource.Text = Options.FFmpeg.VideoSource; cboAudioSource.Text = Options.FFmpeg.AudioSource; btnRefreshSources.Enabled = true; }); }
public DirectShowDevices GetDirectShowDevices() { DirectShowDevices devices = new DirectShowDevices(); if (File.Exists(Options.FFmpeg.CLIPath)) { string arg = "-list_devices true -f dshow -i dummy"; Open(Options.FFmpeg.CLIPath, arg); string output = Output.ToString(); string[] lines = output.Lines(); bool isVideo = true; Regex regex = new Regex("\\[dshow @ \\w+\\] \"(.+)\"", RegexOptions.Compiled | RegexOptions.CultureInvariant); foreach (string line in lines) { if (line.EndsWith("] DirectShow video devices", StringComparison.InvariantCulture)) { isVideo = true; continue; } if (line.EndsWith("] DirectShow audio devices", StringComparison.InvariantCulture)) { isVideo = false; continue; } Match match = regex.Match(line); if (match.Success) { string value = match.Groups[1].Value; if (isVideo) { devices.VideoDevices.Add(value); } else { devices.AudioDevices.Add(value); } } } } return(devices); }
public DirectShowDevices GetDirectShowDevices() { DirectShowDevices devices = new DirectShowDevices(); if (File.Exists(Options.FFmpeg.CLIPath)) { string arg = "-list_devices true -f dshow -i dummy"; Open(Options.FFmpeg.CLIPath, arg); string output = Output.ToString(); string[] lines = output.Lines(); bool isVideo = true; Regex regex = new Regex("\\[dshow @ \\w+\\] \"(.+)\"", RegexOptions.Compiled | RegexOptions.CultureInvariant); foreach (string line in lines) { if (line.EndsWith("] DirectShow video devices", StringComparison.InvariantCulture)) { isVideo = true; continue; } else if (line.EndsWith("] DirectShow audio devices", StringComparison.InvariantCulture)) { isVideo = false; continue; } Match match = regex.Match(line); if (match.Success) { string value = match.Groups[1].Value; if (isVideo) { devices.VideoDevices.Add(value); } else { devices.AudioDevices.Add(value); } } } } return devices; }