private void Broadcast_Click(object sender, EventArgs e) { EncoderDevice video = null; EncoderDevice audio = null; GetSelectedVideoAndAudioDevices(out video, out audio); StopJob(); if (video == null) { return; } _job = new LiveJob(); _deviceSource = _job.AddDeviceSource(video, audio); _job.ActivateSource(_deviceSource); // Finds and applys a smooth streaming preset _job.ApplyPreset(LivePresets.VC1256kDSL16x9); // Creates the publishing format for the job PullBroadcastPublishFormat format = new PullBroadcastPublishFormat(); format.BroadcastPort = 8080; format.MaximumNumberOfConnections = 2; // Adds the publishing format to the job _job.PublishFormats.Add(format); // Starts encoding _job.StartEncoding(); toolStripStatusLabel1.Text = "Broadcast started on localhost at port 8080, run WpfShowBroadcast.exe now to see it"; }
public PreviewVideo(EncoderDevice selectedVideo, EncoderDevice selectedAudio) { InitializeComponent(); SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; }
private void SetupJob() { // Sets the audio devices to the collection. Adds a null at the beginning for user to select no device AudioDevices = new ObservableCollection <EncoderDevice>(EncoderDevices.FindDevices(EncoderDeviceType.Audio)); AudioDevices.Insert(0, null); // Gets all the video devices and sets the screen source. EncoderDevice Video = null; Collection <EncoderDevice> videoSources = EncoderDevices.FindDevices(EncoderDeviceType.Video); foreach (EncoderDevice dev in videoSources) { if (dev.Name.Contains("Screen Capture Source")) { Video = dev; } } // Creats the source Source = Job.AddDeviceSource(Video, null); // Activates sources and sets preset to job Job.ActivateSource(Source); Job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3); }
public ConfigDatosLugar(Window config, EncoderDevice selectedVideo, EncoderDevice selectedAudio) { InitializeComponent(); Config = config; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; }
public ConfigDatosLugarViewModel( Window current, Window config, EncoderDevice selectedAudio, EncoderDevice selectedVideo) { CurrentWindow = current; ConfigWindow = config; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; GrabacionVideoCurrent = new Grabacion(); CargarCombos(); }
public ConfigDatosPersona(Window grabacionW, EncoderDevice selectedVideo, EncoderDevice selectedAudio, Grabacion grabacion) { InitializeComponent(); GrabacionWindow = grabacionW; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; SelectedGrabacion = grabacion; }
public GrabacionVideo(EncoderDevice selectedVideo, EncoderDevice selectedAudio, Grabacion grabacionSelected) { InitializeComponent(); SelectedGrabacion = grabacionSelected; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; WebcamCtrl.NombreVideo = SelectedGrabacion.Nombre + "_" + DateTime.Now.ToString("yyyy_dd_MM"); }
public ConfigDatosPersonaViewModel(Window grabacionW, Window current, EncoderDevice selectedAudio, EncoderDevice selectedVideo, Grabacion grabacion) { GrabacionW = grabacionW; SelectedGrabacion = grabacion; CurrentWindow = current; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; CargarDatosLugar(); SelectedGrabacion.Edad = ""; SelectedGrabacion.Nombre = ""; }
private void audioComboBox_SelectedIndexChanged(object sender, EventArgs e) { foreach (EncoderDevice aDevice in EncoderDevices.FindDevices(EncoderDeviceType.Audio)) { if (String.Compare(aDevice.Name, audioComboBox.Text) == 0) { audio = aDevice; break; } } audioComboBox.Enabled = false; mediaPlay(); }
EncoderDevice AudioDevices() { EncoderDevice foundDevice = null; Collection <EncoderDevice> audioDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); try { foundDevice = audioDevices.First(); } catch (Exception ex) { MessageBox.Show("Audio Device Not Found" + audioDevices[0].Name + ex.Message); } return(foundDevice); }
public PreviewVideoViewModel(Window current, EncoderDevice selectedAudio, EncoderDevice selectedVideo, Webcam cam) { SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; CurrentWindow = current; WebcamCtrl = cam; var pathMarcaAgua = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); pathMarcaAgua += "\\Content\\Images\\" + "MarcaDeAgua.jpg"; WebcamCtrl.ImagenMarcaAgua = pathMarcaAgua; CargarVideo(); }
//metoda zamieniająca nazwę urządzenia na postać EncoderDevice private EncoderDevice GetVideoDevice(string deviceName) { EncoderDevice video = null; foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if (String.Compare(edv.Name, deviceName) == 0) { video = edv; break; } } return(video); }
// this code to enable audio recording EncoderDevice AudioDevices() { EncoderDevice foundDevice = null; Collection <EncoderDevice> audioDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); try { // you can chose yor device here foundDevice = audioDevices.First(); } catch (Exception ex) { MessageBox.Show(" Cannot find prefered audio device using " + audioDevices[0].Name + ex.Message); } return(foundDevice); }
private void SetDeviceSources() {// locates the first video device with name = _videoSourceName and the first audio device found (required for class // constructor but not used in our project) // creates LiveJob and adds device sources. EncoderDevice videoDevice = null; EncoderDevice audioDevice = null; _deviceSource = null; videoDevice = EncoderDevices.FindDevices(EncoderDeviceType.Video).FirstOrDefault(vd => vd.Name == _videoSourceName); audioDevice = EncoderDevices.FindDevices(EncoderDeviceType.Audio).FirstOrDefault(); if (videoDevice != null && audioDevice != null) { _job = new LiveJob(); _deviceSource = _job.AddDeviceSource(videoDevice, audioDevice); } }
public StoryPlugin(IMessageDispatcher remote, IUIThreadDispatcher uiThreadDispatcher) { this._remote = remote; this._uiThreadDispatcher = uiThreadDispatcher; uiThreadDispatcher.BlockingInvoke(() => { story = new StoryPage(); pluginContainer = new Viewbox(); pluginContainer.Child = story; }); _remote.RegisterReceiveHandler("story.stopRecording", new MessageHandlerDelegateWrapper(m => endVideoCapture())); _remote.RegisterReceiveHandler("story.startRecording", new MessageHandlerDelegateWrapper(m => startVideoCapture(m))); _remote.RegisterReceiveHandler("story.saveRecording", new MessageHandlerDelegateWrapper(m => saveRecording(m))); foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { //Debug.WriteLine("found a video deviced named: " + edv.Name); videoDevice = edv; } foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Audio)) { //Debug.WriteLine("found a audio deviced named: " + edv.Name); if (edv.Name.ToLower().Contains("microphone")) { audioDevice = edv; } } story.SizeChanged += new System.Windows.SizeChangedEventHandler(story_SizeChanged); job = new LiveJob(); if (!System.IO.Directory.Exists("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\")) { System.IO.Directory.CreateDirectory("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\"); } fileOut = new FileArchivePublishFormat(); fileOut.OutputFileName = "C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\tempVideo.wmv"; System.Console.WriteLine(fileOut.OutputFileName); }
public SomethingJustHappenedCamera(EncoderDevice video, EncoderDevice audio, string path, TimeSpan clipLength) { this.path = path; this.ClipLength = clipLength; processingClick = false; segmentCount = 0; folder = EscapePath(DateTime.UtcNow.ToString()); this.path = Path.Combine(path, folder); if (!Directory.Exists(this.path)) { Directory.CreateDirectory(this.path); } camera = new CameraCapture(video, audio); //VideoTrimmer.ProcessorOutputEvent += VideoTrimmer_ProcessorOutputEvent; }
private void GetSelectedVideoAndAudioDevices(out EncoderDevice video, out EncoderDevice audio, string ID) { video = null; audio = null; if (string.IsNullOrEmpty(ID)) { MessageBox.Show("No Video and Audio capture devices have been selected.\nSelect an audio and video devices from the listboxes and try again.", "Warning"); return; } // Get the selected video device foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if (String.Compare(edv.DevicePath, ID) == 0) { video = edv; break; } } }
private void GetSelectedVideoAndAudioDevices(out EncoderDevice video, out EncoderDevice audio) { video = null; audio = null; lblVideoDeviceSelectedForPreview.Text = ""; lblAudioDeviceSelectedForPreview.Text = ""; if (lstVideoDevices.SelectedIndex < 0 || lstAudioDevices.SelectedIndex < 0) { MessageBox.Show("No Video and Audio capture devices have been selected.\nSelect an audio and video devices from the listboxes and try again.", "Warning"); return; } // Get the selected video device foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if (String.Compare(edv.Name, lstVideoDevices.SelectedItem.ToString()) == 0) { video = edv; lblVideoDeviceSelectedForPreview.Text = edv.Name; break; } } // Get the selected audio device foreach (EncoderDevice eda in EncoderDevices.FindDevices(EncoderDeviceType.Audio)) { if (String.Compare(eda.Name, lstAudioDevices.SelectedItem.ToString()) == 0) { audio = eda; lblAudioDeviceSelectedForPreview.Text = eda.Name; break; } } }
public GrabacionVideoViewModel(Window currentWindow, EncoderDevice selectedAudio, EncoderDevice selectedVideo, Webcam cam, Grabacion selectedGrabacion) { CurrentWindow = currentWindow; SelectedAudio = selectedAudio; SelectedVideo = selectedVideo; SelectedGrabacion = selectedGrabacion; WebcamCtrl = cam; InitializeVm(); Config = new ConfigWaterMark(); Config.VideoUrl = "C:\\Videos"; Config.NombreVideo = WebcamCtrl.NombreVideo.ToString(); CrearMarcaAgua(); CargarVideo(); // TextTimer = "30:00"; }
public TestCtrl() { VideoDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); foreach (EncoderDevice d in VideoDevices) { if (d.Name == "HD Pro Webcam C920" || d.Name == "Integrated Webcam") { Console.WriteLine("Webcam found"); logiHdPro = d; } Console.WriteLine("VIDEO DEVICE: " + d.Name); } if (logiHdPro == null) { Console.WriteLine("No recognized webcams available"); } this.DataContext = this; InitializeComponent(); }
public void SetDevice(EncoderDevice device) { WebcamControl.VideoDevice = device.Name; }
public CameraCapture(EncoderDevice video, EncoderDevice audio) { this.Video = video; this.Audio = audio; }
public SoundRecorder(EncoderDevice audioEncoder) { this.audioEncoder = audioEncoder; IsRecording = false; }
public void ResetControl() { try { // Maximize the main grid gridMain.Width = this.Width; gridMain.Height = this.Height; formsHost.Width = this.Width; formsHost.Height = this.Height - 100; // Add a win form panel to the grid pnlVideoPreview = new System.Windows.Forms.Panel(); pnlVideoPreview.Width = Convert.ToInt32(this.Width); pnlVideoPreview.Height = Convert.ToInt32(this.Height) - 100; pnlVideoPreview.Left = 0; pnlVideoPreview.Top = 0; // Add the panel formsHost.Child = pnlVideoPreview; // Get the webcam matching the specified name foreach (EncoderDevice cam in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if (cam.Name == dsCameraSource) { currentcam = cam; } } } catch { } }
private void videoComboBox_SelectedIndexChanged(object sender, EventArgs e) { foreach (EncoderDevice vDevice in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if (String.Compare(vDevice.Name, videoComboBox.Text) == 0) { video = vDevice; break; } } videoComboBox.Enabled = false; audioComboBox.Enabled = true; }
public Capture(EncoderDevice d) : this() { webcam.SelectedVideoDevice = d; }
//take the string of the device chosen (from the GUI) and return the audio/video devices we need private void convertStringToDevice(SettingsData theSettings) { foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { if(edv.Name == theSettings.vidDev) { videoDevice = edv; //break to stop looping break; } } foreach (EncoderDevice eda in EncoderDevices.FindDevices(EncoderDeviceType.Audio)) { if (eda.Name == theSettings.audioDev) { audioDevice = eda; //break to stop looping break; } } }
private void btnGrabar_Click(object sender, EventArgs e) { if (ID <= 0) { return; } btnGrabar.Enabled = false; btnDetener.Enabled = true; try { ListaDispositivos = new List <ObjVideo>(); foreach (var item in ugDispositivos.Rows) { item.Cells["Estado"].Value = "Grabando..."; ObjVideo dispositivo = new ObjVideo(); EncoderDevice video = null; EncoderDevice audio = null; GetSelectedVideoAndAudioDevices(out video, out audio, item.Cells["ID"].Value.ToString()); if (video == null) { return; } dispositivo.Job = new LiveJob(); if (!dispositivo.BStartedRecording) { if (video != null) { dispositivo.DeviceSource = dispositivo.Job.AddDeviceSource(video, audio); dispositivo.DeviceSource.PickBestVideoFormat(new Size(1280, 720), 1); SourceProperties sp = dispositivo.DeviceSource.SourcePropertiesSnapshot(); dispositivo.Job.OutputFormat.VideoProfile.Size = new Size(sp.Size.Width, sp.Size.Height); dispositivo.Job.ActivateSource(dispositivo.DeviceSource); } else { MessageBox.Show("No Video/Audio capture devices have been found.", "Warning"); } } if (dispositivo.BStartedRecording) { dispositivo.Job.StopEncoding(); dispositivo.BStartedRecording = false; video = null; audio = null; } else { FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); Random rnd = new Random(); dispositivo.FileName = "C:\\Video\\CAM{0:yyyyMMdd_hhmmss}-" + rnd.Next(10) + ".wmv"; fileOut.OutputFileName = String.Format(dispositivo.FileName, DateTime.Now); dispositivo.FileName = fileOut.OutputFileName; dispositivo.Job.PublishFormats.Add(fileOut); dispositivo.Job.StartEncoding(); dispositivo.BStartedRecording = true; } dispositivo.Id = item.Cells["ID"].Value.ToString(); ListaDispositivos.Add(dispositivo); } } catch (Exception ex) { btnDetener.Enabled = true; btnGrabar.Enabled = false; ListaDispositivos.Clear(); ListaDispositivos = null; this.SetMensaje(ex.Message, 5000, Color.Red, Color.White); } }
private void btnPreview_Click(object sender, EventArgs e) { EncoderDevice video = null; EncoderDevice audio = null; GetSelectedVideoAndAudioDevices(out video, out audio); StopJob(); if (video == null) { return; } // Starts new job for preview window _job = new LiveJob(); // Checks for a/v devices if (video != null && audio != null) { // Create a new device source. We use the first audio and video devices on the system _deviceSource = _job.AddDeviceSource(video, audio); // Is it required to show the configuration dialogs ? if (checkBoxShowConfigDialog.Checked) { // Yes // VFW video device ? if (lstVideoDevices.SelectedItem.ToString().EndsWith("(VFW)", StringComparison.OrdinalIgnoreCase)) { // Yes if (_deviceSource.IsDialogSupported(ConfigurationDialog.VfwFormatDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VfwFormatDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VfwSourceDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VfwSourceDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VfwDisplayDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VfwDisplayDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } } else { // No if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCapturePinDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCapturePinDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCaptureDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCaptureDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoCrossbarDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCrossbarDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoPreviewPinDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoPreviewPinDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } if (_deviceSource.IsDialogSupported(ConfigurationDialog.VideoSecondCrossbarDialog)) { _deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoSecondCrossbarDialog, (new HandleRef(panelVideoPreview, panelVideoPreview.Handle))); } } } else { // No // Setup the video resolution and frame rate of the video device // NOTE: Of course, the resolution and frame rate you specify must be supported by the device! // NOTE2: May be not all video devices support this call, and so it just doesn't work, as if you don't call it (no error is raised) // NOTE3: As a workaround, if the .PickBestVideoFormat method doesn't work, you could force the resolution in the // following instructions (called few lines belows): 'panelVideoPreview.Size=' and '_job.OutputFormat.VideoProfile.Size=' // to be the one you choosed (640, 480). //xyz _deviceSource.PickBestVideoFormat(new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height), 15); } // Get the properties of the device video SourceProperties sp = _deviceSource.SourcePropertiesSnapshot(); // Resize the preview panel to match the video device resolution set panelVideoPreview.Size = new Size(sp.Size.Width, sp.Size.Height); // Setup the output video resolution file as the preview _job.OutputFormat.VideoProfile.Size = new Size(sp.Size.Width, sp.Size.Height); // Display the video device properties set toolStripStatusLabel1.Text = sp.Size.Width.ToString() + "x" + sp.Size.Height.ToString() + " " + sp.FrameRate.ToString() + " fps"; // Sets preview window to winform panel hosted by xaml window _deviceSource.PreviewWindow = new PreviewWindow(new HandleRef(panelVideoPreview, panelVideoPreview.Handle)); // Make this source the active one _job.ActivateSource(_deviceSource); btnStartStopRecording.Enabled = true; btnGrabImage.Enabled = true; toolStripStatusLabel1.Text = "Preview activated"; } else { // Gives error message as no audio and/or video devices found MessageBox.Show("No Video/Audio capture devices have been found.", "Warning"); toolStripStatusLabel1.Text = "No Video/Audio capture devices have been found."; } }