private static void VideoSource_NewFrame(object sender, NewFrameEventArgs eventArgs) { var tapes = pic2ascii.Convert(eventArgs.Frame); Bitmap result = ProcessTapes(tapes); writer.WriteVideoFrame(result); Console.Write("."); }
static async Task Main(string[] args) { FFmpeg.SetExecutablesPath(FFMPEG_PATH); IConversion conv; IMediaInfo info = await FFmpeg.GetMediaInfo(MOVIESAMPLE_PATH); IVideoStream videoStream = info.VideoStreams .First() ?.SetCodec(VideoCodec.png); int everyFrame = 1; ////////////////////////////////////////////////// conv = FFmpeg.Conversions.New() .AddStream(videoStream) .ExtractEveryNthFrame(everyFrame, x => DEST_PATH + x + ".png"); conv.OnProgress += (s, a) => { Console.SetCursorPosition(0, Console.CursorTop); Console.Write($"{a.Percent}%"); }; await conv.Start(); ////////////////////////////////////////////////// var options = new PicToAsciiOptions() { FixedDimension = PicToAsciiOptions.Fix.Vertical, FixedSize = 50, SymbolAspectRatio = 11f / 18f, AsciiTable = PicToAsciiOptions.ASCIITABLE_SYMBOLIC_LIGHT }; var pic2ascii = new PicToAscii(options); var font = SystemFonts.CreateFont("Lucida Console", 18); Parallel.ForEach(ImageSamples, filename => { IReadOnlyList <ColorTape> colorTapes; try { using Stream stream = File.OpenRead(filename); colorTapes = pic2ascii.Convert(stream); } catch { return; } string fname = new FileInfo(filename).Name; Console.WriteLine(fname); ProcessTapes(colorTapes, fname, font); }); /////////////////////////////////////////////// List <string> files = Directory.EnumerateFiles(RESULT_PATH).ToList(); conv = FFmpeg.Conversions.New() //.SetInputFrameRate((int)videoStream.Framerate / everyFrame) .BuildVideoFromImages(files) .SetFrameRate(videoStream.Framerate) .SetOutputFormat(Format.mp4) .SetOutput($"{MOV_PATH}~{Environment.TickCount}.mp4"); conv.OnProgress += (s, a) => { Console.SetCursorPosition(0, Console.CursorTop); Console.Write($"{a.Percent}%"); }; await conv.Start(); }