public ThumbControl(IThumbsControlContainer thumbsControlContainer, FFmpegResult thumbResult, int width, int height) { Width = width; Height = height; InitializeComponent(); UpdateContainerAndResult(thumbsControlContainer, thumbResult); }
public void FFmpegDataConverted(FFmpegResult ffmpegResult) { if (_videoKeyframesWindow == null) { return; } _videoKeyframesWindow.AddThumb(ffmpegResult); }
public void FFmpegDataConverted(FFmpegResult ffmpegResult) { if (_previewWindow != null) { _previewWindow.UpdateResult(ffmpegResult); _activeFrameSourceNode = ffmpegResult.SourcePacket; } }
public void AskChangeDefaultCodecHeader(FFmpegResult ffmpegResult) { // Execute the messagebox in Thread context of the Form. // Otherwise the messagebox is not a child of the program. this.Invoke((MethodInvoker) delegate { _defaultCodecHeaderManager.AskChangeDefaultCodecHeader(ffmpegResult, _mainForm); }); }
public void UpdateContainerAndResult(IThumbsControlContainer thumbsControlContainer, FFmpegResult thumbResult) { _thumbsControlContainer = thumbsControlContainer; _thumbResult = thumbResult; if (thumbResult != null) { _bitmap = (thumbResult.Bitmap != null) ? ThumbUtil.ResizeBitmap(thumbResult.Bitmap, Width, Height) : ThumbUtil.GetErrorBitmap(); Invalidate(); } }
public void FFmpegDataConverted(FFmpegResult ffmpegResult) { if (_activeThumbIndex >= _ffmpegResults.Length) { // FIXME: [email protected] - Needs real fix: WHY does it report more than 5 thumbnails?? Console.WriteLine("WARNING: Dropping unexpected extra thumbnail!"); return; } UpdateThumbResult(_activeThumbIndex, ffmpegResult); _activeThumbIndex++; }
private void ReloadBitmap() { FFmpegResult result = CellFFmpegResult; if (_bitmap != null) { _bitmap.Dispose(); } if (result != null) { _bitmap = ThumbUtil.ResizeBitmap(result.Bitmap, ThumbUtil.ThumbWidth, ThumbUtil.ThumbHeight) ?? ThumbUtil.GetErrorBitmap(); } }
public void AddThumb(FFmpegResult ffmpegResult) { if (IsDisposed || thumbsContainer.IsDisposed) { return; } // Execute Add method in Thread context of the Form. this.Invoke((MethodInvoker) delegate { ThumbControl thumbControl = new ThumbControl(this, ffmpegResult); thumbsContainer.Controls.Add(thumbControl); UpdateProgress(); }); }
public void UpdateResult(FFmpegResult ffmpegResult) { if (IsDisposed) { return; } if (_ffmpegResult != null) { _ffmpegResult.Dispose(); } _ffmpegResult = ffmpegResult; if (_ffmpegResult != null) { Invoke((MethodInvoker)UpdateTitle); } Invalidate(); // Causes bitmap redraw (OnPaint). }
public void AskChangeDefaultCodecHeader(FFmpegResult ffmpegResult, IWin32Window windowOwner) { if (ffmpegResult.Bitmap == null && !IsWindowOpen() && !_backgroundFileScanner.IsBusy) { // Check if it is a key frame. When true we should be able to decode it. IResultNode resultNode = ffmpegResult.SourcePacket; if (resultNode != null && resultNode.IsKeyframe()) { if (DialogResult.Yes == MessageBox.Show( "Defraser couldn't detect the video headers of this frame. Do you want to use a reference header to decode this frame?", "Header Not Found.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { EditDefaultCodecHeader editDefaultCodecHeader = CreateEditDefaultCodecHeaderWindow(); editDefaultCodecHeader.SelectCodec(ffmpegResult.SourcePacket.DataFormat); editDefaultCodecHeader.ShowDialog(windowOwner); } } } }
private void resultsTree_CellClick(object sender, EventArgs e) { ThumbCellWidget cell = sender as ThumbCellWidget; if (cell != null) { ProjectKeyframeOverviewRow row = cell.Row.Item as ProjectKeyframeOverviewRow; if (row != null) { FFmpegResult result = cell.CellFFmpegResult; if (result != null) { if (result.Bitmap != null) { SelectPacketInTree(row.KeyframesSourceFragment, result.SourcePacket); } else { AskChangeDefaultCodecHeader(result); } } } } }
public static bool Combine(string audio, string video, string title, OperationLogger logger, out Exception exception, Action <int, object> reportProgress) { // Remove '_video' from video file to get a final filename. string error = string.Empty; string output = video.Replace("_video", string.Empty); FFmpegResult <bool> result = null; try { // Raise events on main thread reportProgress(-1, new Dictionary <string, object>() { { "ProgressText", "Combining..." } }); result = FFmpeg.Combine(video, audio, output, delegate(int percentage) { // Combine progress reportProgress(percentage, null); }, logger); // Save errors if combining failed if (!result.Value) { var sb = new StringBuilder(); sb.AppendLine(title); sb.AppendLine(string.Join( Environment.NewLine, result.Errors.Select(err => $" - {err}"))); error = sb.ToString(); } // Cleanup the separate audio and video files Helper.DeleteFiles(audio, video); } catch (Exception ex) { exception = ex; Common.SaveException(ex); return(false); } finally { // Raise events on main thread reportProgress(-1, new Dictionary <string, object>() { { "ProgressText", null } }); } exception = new Exception(error); return(result.Value); }
private void UpdateThumbResult(int thumbIndex, FFmpegResult result) { _ffmpegResults[thumbIndex] = result; UpdateRow(); }
public static void DrawBitmapRect(Graphics graphics, IBitmapThumbTarget bitmapThumbTarget, FFmpegResult ffmpegResult, int x, int y) { Color color; if (bitmapThumbTarget.HasMouseFocus) { color = ColorBitmapMouseOver; } else if (bitmapThumbTarget.IsSelected) { color = ColorBitmapSelected; } else if (ffmpegResult != null && ffmpegResult.IsUsingCustomHeaderSource()) { color = ColorBitmapUsingHeaderSource; } else { color = ColorBitmapDefault; } var pen = new Pen(color); graphics.DrawRectangle(pen, x + 1, y + 1, bitmapThumbTarget.Width - 3, bitmapThumbTarget.Height - 3); graphics.DrawRectangle(pen, x, y, bitmapThumbTarget.Width - 1, bitmapThumbTarget.Height - 1); pen.Dispose(); }
public static void DrawBitmapRect(Graphics graphics, IBitmapThumbTarget bitmapThumbTarget, FFmpegResult ffmpegResult) { DrawBitmapRect(graphics, bitmapThumbTarget, ffmpegResult, 0, 0); }
private bool Combine() { string audio = _downloader.Files[0].Path; string video = _downloader.Files[1].Path; // Remove '_video' from video file to get a final filename. string output = video.Replace("_video", string.Empty); FFmpegResult <bool> result = null; try { // Raise events on main thread this.ReportProgress(-1, new Dictionary <string, object>() { { nameof(ProgressText), "Combining..." } }); if (_ffmpegLogger == null) { _ffmpegLogger = OperationLogger.Create(OperationLogger.FFmpegDLogFile); } if (_ffmpeg == null) { _ffmpeg = new FFmpegProcess(_ffmpegLogger); } result = _ffmpeg.Combine(video, audio, output, delegate(int percentage) { // Combine progress this.ReportProgress(percentage, null); }); // Save errors if combining failed if (!result.Value) { var sb = new StringBuilder(); sb.AppendLine(this.Title); foreach (string error in result.Errors) { sb.AppendLine($" - {error}"); } this.ErrorsInternal.Add(sb.ToString()); } // Cleanup the separate audio and video files Helper.DeleteFiles(audio, video); } catch (Exception ex) { Common.SaveException(ex); return(false); } finally { // Raise events on main thread this.ReportProgress(-1, new Dictionary <string, object>() { { nameof(ProgressText), null } }); } return(result.Value); }
public ThumbControl(IThumbsControlContainer thumbsControlContainer, FFmpegResult thumbResult) : this(thumbsControlContainer, thumbResult, ThumbUtil.ThumbWidth, ThumbUtil.ThumbHeight) { InitializeComponent(); }