From 9e785bc087f9426eca1e5277928258bf885b3589 Mon Sep 17 00:00:00 2001 From: Max Bagryantsev Date: Mon, 27 Apr 2020 20:16:08 +0300 Subject: [PATCH] Update README.md Former-commit-id: ca89dfcddd65e0aa993ec09a81d4e5dd5c732e51 --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 6fddd05..d5d7462 100644 --- a/README.md +++ b/README.md @@ -381,6 +381,42 @@ public class OverrideArgument : Argument } } ``` +### Input piping +With input piping it is possible to write video frames directly from program memory without saving them to jpeg or png and then passing path to input of ffmpeg. This feature also allows us to convert video on-the-fly while frames are beeing generated/created/processed. + +`IPipeSource` interface is used as source of data. It could be represented as encoded video stream or raw frames stream. Currently `IPipeSource` interface has single implementation, `RawVideoPipeSource` that is used for raw stream encoding. + +For example: + +Method that is generate bitmap frames: +```csharp +IEnumerable CreateFrames(int count) +{ + for(int i = 0; i < count; i++) + { + yield return GetNextFrame(); //method of generating new frames + } +} +``` +Then create `ArgumentsContainer` with `InputPipeArgument` +```csharp +var videoFramesSource = new RawVideoPipeSource(CreateFrames(64)) //pass IEnumerable or IEnumerator to constructor of RawVideoPipeSource +{ + FrameRate = 30 //set source frame rate +}; +var container = new ArgumentsContainer +{ + new InputPipeArgument(videoFramesSource), + ... //Other encoding arguments + new OutputArgument("temporary.mp4") +}; + +var ffmpeg = new FFMpeg(); +var result = ffmpeg.Convert(arguments); +``` + +if you want to use `System.Drawing.Bitmap` as `IVideoFrame`, there is `BitmapVideoFrameWrapper` wrapper class. + ## Contributors