private async Task ConsumeVideoSamples() { await foreach (var videoSample in VideoQueue.GetEvents()) { if (inferredResolution == null) { // DesktopCapture may enqueue null samples intentionally to stop encoding if (videoSample == null) { throw new EncodingException("Failed to infer video input resolution."); } var description = videoSample.Surface.Description; var inferredWidth = (uint)description.Width; var inferredHeight = (uint)description.Height; inferredResolution = new Tuple <uint, uint>(inferredWidth, inferredHeight); onResolutionInferred.Set(); } sampleProcessed.WaitOne(); nextSample = videoSample; nextSampleReady.Set(); } // Stop encoding by sending null sample sampleProcessed.WaitOne(); nextSample = null; nextSampleReady.Set(); }
public DownloadViewModel(IMessageBox messageBox, IMediator mediator, SettingsManager settingsManager) { _messageBox = messageBox; _mediator = mediator; _settingsManager = settingsManager; _mediator.Register(this); UIEnabled = true; SelectedQuality = QualityList.FirstOrDefault(q => q.Id == _settingsManager.Settings.MaxQuality) ?? QualityList[0]; TargetPath = _settingsManager.Settings.TargetPath; AddCommand = new DelegateCommand(ExecuteAddCommand); TargetCommand = new DelegateCommand(ExecuteTargetCommand); GoCommand = new DelegateCommand(ExecuteGoCommand); StopCommand = new DelegateCommand(ExecuteStopCommand); ImportCommand = new DelegateCommand(ExecuteImportCommand); Queue = new VideoQueue(); Queue.TotalProgressChanged += TotalProgressChanged; Queue.QueueStateChanged += QueueStateChanged; Queue.VideoFinished += VideoFinished; FinishedVideos = new ObservableCollection<Video>(); }
public ActionResult DeleteConfirmed(int id) { VideoQueue videoQueue = db.VideoQueues.Find(id); db.VideoQueues.Remove(videoQueue); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(VideoQueue videoQueue) { if (ModelState.IsValid) { db.Entry(videoQueue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(videoQueue)); }
private void btnDownload_Click(object sender, EventArgs e) { foreach (string line in linkTextBox.Lines) { int apdIndex = line.IndexOf("apd="); if (apdIndex == -1) { continue; } try { /* * hhttps://apclassroom.collegeboard.org/8/home?apd=qyu6avch2l */ string key = line.Substring(line.IndexOf("apd=") + 4); // download https://fast.wistia.net/embed/iframe/**?videoFoam=true string remoteUri = $"https://fast.wistia.net/embed/iframe/{key}?videoFoam=true"; // Create a new WebClient instance. WebClient wc = new WebClient(); string result = wc.DownloadString(remoteUri); // remote url looks like this in result: https://embed-ssl.wistia.com/deliveries/66f732c9532bfac7eccc82115ad024a8.bin Match m = Regex.Match(result, @"https://embed-ssl.wistia.com/deliveries/([a-z0-9]+\.bin)"); Match mt = Regex.Match(result, "<title>(.*?)</title>"); if (m.Groups.Count == 2) { string video = m.Value; string videoFileName = MakeValidFileName(mt.Groups[1].Value); string sourceFile = $"C:\\Users\\mike\\Desktop\\AP Lessons\\{videoFileName}"; string destFile = sourceFile + ".mp4"; VideoQueue.Enqueue(new VideoQueueItem { VideoURL = video, VideoFileName = videoFileName, Title = mt.Groups[1].Value, DestinationFile = destFile }); } } catch (Exception ex) { } } }
public ActionResult DeleteVideoQue(int id) { VideoQueue vq = db.VideoQueues.Find(id); if (vq != null) { db.Entry(vq).State = EntityState.Deleted; db.SaveChanges(); return(Json(new { Success = true })); } return(Json(new { Error = "Error Video Que Can Not Be Null" })); }
public ActionResult Create(VideoQueue videoQueue) { if (ModelState.IsValid) { videoQueue.CreateDate = DateTime.Now; db.VideoQueues.Add(videoQueue); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(videoQueue)); }
public VideoQueue GetVideoQ(int id) { var client = new RestClient(APIPath); client.AddDefaultHeader("api-key", ApiKey); var request = new RestRequest("getvideoq/" + id, Method.GET); var response = client.Execute(request); VideoQueue vq = JsonConvert.DeserializeObject <VideoQueue>(response.Content); return(vq); }
// GET: VideoQueues/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VideoQueue videoQueue = db.VideoQueues.Find(id); if (videoQueue == null) { return(HttpNotFound()); } return(View(videoQueue)); }
public VideoQueue GetVideoQ(string machineName) { var client = new RestClient(APIPath); client.AddDefaultHeader("api-key", ApiKey); var request = new RestRequest("getvideoq", Method.POST); request.AddParameter("machineName", machineName); var response = client.Execute(request); VideoQueue vq = JsonConvert.DeserializeObject <VideoQueue>(response.Content); return(vq); }
public ActionResult UpdateVideoQueStatus(int id, VideoQueueStatus status) { VideoQueue vq = db.VideoQueues.Find(id); if (vq != null) { vq.VideoStatus = status; db.Entry(vq).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { return(Json(new { Error = "Error no video Q found" })); } return(Json(new { Success = true })); }
public ActionResult GetRenderData(string machineName) { var testQs = db.VideoQueues.ToList(); VideoQueue vq = db.VideoQueues.Where(q => q.VMName == machineName && q.VideoStatus == VideoQueueStatus.UploadedToAzureRenderFarm).FirstOrDefault(); RenderViewModel rvm = new RenderViewModel(); if (vq == null) { rvm.FoundVideoToRender = false; return(Json(rvm)); } Service service = db.Services.Where(s => s.Id == vq.VideoId).FirstOrDefault(); //If any of these conditions are null the database does not contain enough info to render the video if (service == null || service.Video == null || !service.Video.Stop.HasValue || !service.Video.Start.HasValue) { return(Json(rvm)); } rvm.FirstName = service.FirstName; rvm.LastName = service.LastName; rvm.FuneralHomeName = service.FuneralHome.Name; rvm.Start = (int)service.Video.Start.Value.TotalSeconds; rvm.Duration = (int)service.Video.Stop.Value.TotalSeconds; rvm.RawFileNames = vq.BlobPath; rvm.ConvertedFileName = service.Video.ConvertedFilePath; rvm.VideoQueId = vq.Id; rvm.ResourceGroupName = vq.ResourceGroupName; rvm.ServiceId = service.Id; rvm.ServiceDate = service.ServiceDate; rvm.VideoQueType = vq.VideoQueType; //If the video is uploaded to azure farm, its ready to be rendered. All other status mean it's either rendering or not ready. if (vq.VideoStatus == VideoQueueStatus.UploadedToAzureRenderFarm) { rvm.FoundVideoToRender = true; } else { rvm.FoundVideoToRender = false; } return(Json(rvm)); }
private void DownloaderTimer_Tick(object sender, EventArgs e) { if (VideoQueue.Count > 0 && DownloadsInProgress < MaxDownloads) { VideoQueueItem video = VideoQueue.Dequeue(); if (CompletedDownloads.ContainsKey(video.VideoURL)) { return; } CompletedDownloads.Add(video.VideoURL, video); DownloadsInProgress++; /* * Thread thread = new Thread(() => { * WebClient client = new WebClient(); * client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); * client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); * client.DownloadFileAsync(new Uri(video.VideoURL), video.DestinationFile); * }); * thread.Start(); */ this.BeginInvoke((MethodInvoker) delegate { DownloadControl dc = new DownloadControl(video); dc.OnCompleted += () => { DownloadsInProgress--; downloadPanel.Controls.Remove(dc); }; downloadPanel.Controls.Add(dc); }); } }
public static async Task <bool> AssigningVideosToQueue(int id, string fileNames, VideoQueType type) { //int VMsAvailable = 4; //creating local context to avoid threading issues using (ApplicationDbContext context = new ApplicationDbContext()) { Service serv = context.Services.Find(id); VideoQueue q = new VideoQueue(); q.VideoId = id; q.BlobPath = fileNames; q.CreateDate = DateTime.Now; q.VideoQueType = type; q.VideoStatus = VideoQueueStatus.UploadingToAzureRenderFarm; //Use free server located in Wahpeton to Render videos if avaliable //Look into purchasing a render server for the house //var wahpRenderQ = context.VideoQueues.Where(x => x.VMName == "WIN-8GJ4I6440BF").FirstOrDefault(); //if (wahpRenderQ == null) //{ // q.VMName = "WIN-8GJ4I6440BF"; // q.VideoStatus = VideoQueueStatus.UploadingToAzureRenderFarm; // context.VideoQueues.Add(q); // context.SaveChanges(); //} //else //{ string timeStamp = DateTime.Now.ToString("hhmm"); string PrefixName = serv.Id + "-" + serv.FuneralHome.Name; PrefixName = Regex.Replace(PrefixName, "[^A-Za-z0-9-_]", ""); var groupName = PrefixName + "-RenderGroup"; groupName = Regex.Replace(groupName, "[^A-Za-z0-9-_]", "") + "-" + timeStamp; var vmName = serv.Id + "vm"; q.VMName = vmName; q.VideoStatus = VideoQueueStatus.Created; q.ResourceGroupName = groupName; context.VideoQueues.Add(q); context.SaveChanges(); VMmanager man = new VMmanager(); man.CreateAndDeployRenderVM(serv, groupName, vmName); // } q.VideoStatus = VideoQueueStatus.UploadingToAzureRenderFarm; context.Entry(q).State = EntityState.Modified; context.SaveChanges(); //LOCAL RENDER CODE //q.VMName = "MSI"; //q.VideoStatus = VideoQueueStatus.UploadingToAzureRenderFarm; //q.VideoQueType = type; //context.VideoQueues.Add(q); //context.SaveChanges(); //Turn on azure VM //var StartAzureVMResult = await TurnOnAzureVM(q.AssignedVM.ToString()).ConfigureAwait(false); string[] videoFiles = fileNames.Split(','); //Upload files to Azure bool UploadFilesResult = true; if (type == VideoQueType.FullNoSlate || type == VideoQueType.FullWithSlate) { UploadFilesResult = await UploadFilesToAzure(videoFiles, "videos-in-queue").ConfigureAwait(false); } //Signal Render Machine everything is done if (UploadFilesResult) { q.VideoStatus = VideoQueueStatus.UploadedToAzureRenderFarm; } else { q.VideoStatus = VideoQueueStatus.Error; context.Entry(q).State = EntityState.Modified; Error.ReportError(ErrorSeverity.Severe, "AzureRender", "AssignVideosToQue", "105"); } context.SaveChanges(); Task.Yield(); return(false); } }
public ActionResult GetResourceGroupName(string machineName) { VideoQueue vq = db.VideoQueues.Where(q => q.VMName == machineName).FirstOrDefault(); return(Json(new { ResourceGroupName = vq.ResourceGroupName })); }