static void Main(string[] args) { var options = new PicToAsciiOptions() { FixedDimension = PicToAsciiOptions.Fix.Vertical, FixedSize = 54, SymbolAspectRatio = 7f / 12f, AsciiTable = PicToAsciiOptions.ASCIITABLE_SYMBOLIC_LIGHT }; pic2ascii = new PicToAscii(options); font = new Font("Lucida Console", 12, FontStyle.Regular, GraphicsUnit.Pixel); writer = new VideoFileWriter( ); writer.Open($"{MOV_PATH}~test.avi", width, height, 30, VideoCodec.MPEG4, 6000000); VideoFileSource videoSource = new VideoFileSource(MOVIESAMPLE_PATH); videoSource.NewFrame += VideoSource_NewFrame; videoSource.PlayingFinished += VideoSource_PlayingFinished; videoSource.Start(); Console.ReadLine(); if (videoSource.IsRunning) { videoSource.SignalToStop(); Console.ReadLine(); } }
public void SetPictureToAsciiSettings(int i_HightAscii, int i_WidthAscii, int i_AsciiChars, bool i_BlackToWhite) { PicToAscii.SetSettings(i_HightAscii, i_WidthAscii, i_AsciiChars, i_BlackToWhite); }
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(); }