This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CancellationTokenSource source = null; | |
| void Run() | |
| { | |
| if(source?.IsCancellationRequested != false)//true hoặc source null | |
| { | |
| source?.Dispose(); | |
| source = new CancellationTokenSource(); | |
| } | |
| Task.Run(() => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal static class Extensions | |
| { | |
| static unsafe string av_strerror(int error) | |
| { | |
| var bufferSize = 1024; | |
| var buffer = stackalloc byte[bufferSize]; | |
| ffmpeg.av_strerror(error, buffer, (ulong)bufferSize); | |
| var message = Marshal.PtrToStringAnsi((IntPtr)buffer); | |
| return message; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //https://github.com/tqk2811/FFmpegArgs | |
| FFmpegArg ffmpegArg = new FFmpegArg(); | |
| var colorInput = new FilterGraphInput(); | |
| colorInput.FilterGraph.ColorFilter().Size(new Size(width,height)).Color(Color.Transparent); | |
| var colorVideo = ffmpegArg.AddVideoInput(colorInput,1,0); | |
| var colorMap = colorVideo.ImageMaps.First(); | |
| List<ImageMap> maps = new List<ImageMap>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NV12ToRgbShader* shader = new NV12ToRgbShader(); | |
| if(shader->Init()) | |
| { | |
| AVFrame* src = ...; | |
| AVFrame* dst = ...; | |
| if(shader->Convert(src,dst)) | |
| { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Window x:Class="Yuv.YuvColorSpaceWindow" | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
| mc:Ignorable="d" | |
| Title="YuvColorSpace" Height="470" Width="450"> | |
| <Grid> | |
| <Rectangle > | |
| <Rectangle.Fill> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class DeepCopyExtension | |
| { | |
| public static T CloneByJson<T>(this T obj, JsonSerializerSettings? jsonSerializerSettings = null) | |
| { | |
| return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(obj, jsonSerializerSettings), jsonSerializerSettings)!; | |
| } | |
| public static object? CloneByJson(this object obj, Type type, JsonSerializerSettings? jsonSerializerSettings = null) | |
| { | |
| return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj, jsonSerializerSettings), type, jsonSerializerSettings)!; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Text; | |
| using System.Drawing; | |
| using System.Runtime.InteropServices; | |
| namespace Spazzarama.ScreenCapture | |
| { | |
| public static class Direct3DCapture | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WrapperStream : Stream | |
| { | |
| readonly HttpResponseMessage _httpResponseMessage; | |
| readonly Stream _stream; | |
| public WrapperStream(HttpResponseMessage httpResponseMessage, Stream stream) | |
| { | |
| this._httpResponseMessage = httpResponseMessage; | |
| this._stream = stream; | |
| } | |
| public override bool CanRead => _stream.CanRead; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try | |
| { | |
| VideoTextVM.RenderWorkStatus = RenderWorkStatus.Working; | |
| if (string.IsNullOrWhiteSpace(VideoOutputConfigure.SaveDir)) | |
| throw new InvalidOperationException("Chưa chọn thư mục đầu ra"); | |
| Directory.CreateDirectory(VideoTextVM.TmpDir); | |
| FFmpegArg ffmpegArg = new FFmpegArg().OverWriteOutput().VSync(VSyncMethod.cfr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ChromeDriverService? _service = null; | |
| public int? ChromeProcessId | |
| { | |
| get | |
| { | |
| ProcessHelper processHelper = new ProcessHelper((uint)_service!.ProcessId); | |
| foreach (var child in processHelper.ChildrensProcess) | |
| { | |
| ProcessHelper.Win32_Process? win32_Process = child.Query_Win32_Process(); | |
| if (win32_Process?.Name?.Contains("chrome", StringComparison.OrdinalIgnoreCase) == true) |