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 void Start(int x, int y, int width, int height) { // Set capture rectangle Source.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties() { Left = x, Top = y, Width = width, Height = height, }; // Set output file name to custom name based on timestamp string fileName = string.Format("capture_{0}.wmv", DateTime.Now); // Remove invalid characters fileName = fileName.Replace('/', '-'); fileName = fileName.Replace(':', '-'); // Clear any previous outputs Job.PublishFormats.Clear(); // Add publish format and start encode Job.PublishFormats.Add(new FileArchivePublishFormat() { OutputFileName = string.Format("{0}{1}", OutputDirectory, fileName) }); Job.StartEncoding(); }
public void StartRecording(string path, string name) { job = new LiveJob(); dvs = job.AddDeviceSource(Video, Audio); job.ActivateSource(dvs); WindowsMediaOutputFormat outputFormat = new WindowsMediaOutputFormat(); AdvancedVC1VideoProfile profile = new AdvancedVC1VideoProfile(); profile.Bitrate = new ConstantBitrate(1280, false); profile.Size = new System.Drawing.Size(640, 360); WmaAudioProfile audioProfile = new WmaAudioProfile(); outputFormat.AudioProfile = audioProfile; outputFormat.VideoProfile = profile; job.OutputFormat = outputFormat; CurrentVideoPath = Path.Combine(path, name); FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); fileOut.OutputFileName = CurrentVideoPath; job.PublishFormats.Add(fileOut); job.StartEncoding(); IsRecording = true; }
private void btnStartStopRecording_Click(object sender, EventArgs e) { // Is it Recoring ? if (_bStartedRecording) { // Yes // Stops encoding _job.StopEncoding(); btnStartStopRecording.Text = "Start Recording"; toolStripStatusLabel1.Text = ""; _bStartedRecording = false; } else { // Sets up publishing format for file archival type FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); // Sets file path and name fileOut.OutputFileName = String.Format("C:\\WebCam{0:yyyyMMdd_hhmmss}.wmv", DateTime.Now); // Adds the format to the job. You can add additional formats as well such as // Publishing streams or broadcasting from a port _job.PublishFormats.Add(fileOut); // Start encoding _job.StartEncoding(); btnStartStopRecording.Text = "Stop Recording"; toolStripStatusLabel1.Text = fileOut.OutputFileName; _bStartedRecording = true; } }
public void GetVideo() { var listVideoDevices = new List <EncoderDevice>(); var listAudioDevices = new List <EncoderDevice>(); foreach (var edv in EncoderDevices.FindDevices(EncoderDeviceType.Video)) { listVideoDevices.Add(edv); } foreach (var edv in EncoderDevices.FindDevices(EncoderDeviceType.Audio)) { listAudioDevices.Add(edv); } var job = new LiveJob(); var deviceSource = job.AddDeviceSource(listVideoDevices[0], listAudioDevices[0]); job.ActivateSource(deviceSource); job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3); PullBroadcastPublishFormat format = new PullBroadcastPublishFormat(); format.BroadcastPort = 5001; format.MaximumNumberOfConnections = 1; job.PublishFormats.Add(format); job.StartEncoding(); }
private void startVideoCapture(JObject m) { liveSource = job.AddDeviceSource(videoDevice, audioDevice); while (!story.videoPreview.IsHandleCreated) { Thread.Sleep(100); } if (liveSource.PreviewWindow == null) { story.videoPreview.Invoke((MethodInvoker) delegate { story.videoPreview = new System.Windows.Forms.Panel(); story.videoPreview.Height = int.Parse(story.Height.ToString()); story.videoPreview.Width = int.Parse(story.Width.ToString()); story.FormHost.Child = story.videoPreview; liveSource.PreviewWindow = new PreviewWindow(new HandleRef(story.videoPreview, story.videoPreview.Handle)); //job.OutputPreviewWindow = new PreviewWindow(new HandleRef(story.videoPreview, story.videoPreview.Handle)); //liveSource.PreviewWindow.SetSize(new System.Drawing.Size((int)story.videoPreview.Width, (int)story.videoPreview.Height)); }); } job.ActivateSource(liveSource); if (File.Exists("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\tempVideo.wmv")) { File.Delete("C:\\Dropbox\\" + System.Windows.Forms.SystemInformation.ComputerName + "\\videos\\tempVideo.wmv"); } job.PublishFormats.Add(fileOut); job.StartEncoding(); }
public string StartRecording(string path, string name) { job = new LiveJob(); dvs = job.AddDeviceSource(null, audioEncoder); job.ActivateSource(dvs); WindowsMediaOutputFormat outputFormat = new WindowsMediaOutputFormat() { AudioProfile = new WmaAudioProfile() }; job.OutputFormat = outputFormat; string currentRecordingPath = Path.Combine(path, name); FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); fileOut.OutputFileName = currentRecordingPath; job.PublishFormats.Add(fileOut); job.StartEncoding(); IsRecording = true; return currentRecordingPath; }
private string VideoCapture(Collection <EncoderDevice> Vdevices) { // Starts new job for preview window LiveJob _job = new LiveJob(); // Create a new device source. We use the first audio and video devices on the system LiveDeviceSource _deviceSource = _job.AddDeviceSource(Vdevices[0], null); // Make this source the active one _job.ActivateSource(_deviceSource); FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); // Sets file path and name string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); string output = String.Format(@"{0}\Constellation{1:yyyyMMdd_hhmmss}", path, DateTime.Now); fileOut.OutputFileName = string.Format("{0}.wmv", output); // Adds the format to the job. You can add additional formats // as well such as Publishing streams or broadcasting from a port _job.PublishFormats.Add(fileOut); // Starts encoding _job.StartEncoding(); Thread.Sleep(3000); _job.StopEncoding(); _job.RemoveDeviceSource(_deviceSource); return(output); }
public void StartCapture() { if (!IsCapturing) { job = new LiveJob(); dvs = job.AddDeviceSource(SelectedVideoDevice, SelectedAudioDevice); job.ActivateSource(dvs); job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3); double epoch = GetUnixEpoch(DateTime.UtcNow); string timestamp = epoch.ToString(); VideoFileName = string.Format(VIDEO_FILE, timestamp); FileArchivePublishFormat fileOut = new FileArchivePublishFormat(); fileOut.OutputFileName = Path.Combine(FileLocationUtility.GetVideoFolderLoctation(), VideoFileName); job.PublishFormats.Add(fileOut); job.StartEncoding(); started = DateTime.UtcNow; IsCapturing = true; } }