Update README.md

Former-commit-id: eba1dac0b9
This commit is contained in:
Malte Rosenbjerg 2021-03-15 18:49:20 +01:00 committed by GitHub
parent 6602c87022
commit 16d2c8a6ff

View file

@ -22,11 +22,11 @@ A .NET Standard FFMpeg/FFProbe wrapper for easily integrating media analysis and
FFProbe is used to gather media information: FFProbe is used to gather media information:
```csharp ```csharp
var mediaInfo = FFProbe.Analyse(inputFile); var mediaInfo = FFProbe.Analyse(inputPath);
``` ```
or or
```csharp ```csharp
var mediaInfo = await FFProbe.AnalyseAsync(inputFile); var mediaInfo = await FFProbe.AnalyseAsync(inputPath);
``` ```
@ -43,20 +43,19 @@ FFMpegArguments
.WithConstantRateFactor(21) .WithConstantRateFactor(21)
.WithAudioCodec(AudioCodec.Aac) .WithAudioCodec(AudioCodec.Aac)
.WithVariableBitrate(4) .WithVariableBitrate(4)
.WithFastStart() .WithVideoFilters(filterOptions => filterOptions
.Scale(VideoSize.Hd)) .Scale(VideoSize.Hd))
.WithFastStart())
.ProcessSynchronously(); .ProcessSynchronously();
``` ```
Easily capture screens from your videos: Easily capture screens from your videos:
```csharp ```csharp
var mediaFileAnalysis = FFProbe.Analyse(inputPath);
// process the snapshot in-memory and use the Bitmap directly // process the snapshot in-memory and use the Bitmap directly
var bitmap = FFMpeg.Snapshot(mediaFileAnalysis, new Size(200, 400), TimeSpan.FromMinutes(1)); var bitmap = FFMpeg.Snapshot(inputPath, new Size(200, 400), TimeSpan.FromMinutes(1));
// or persists the image on the drive // or persists the image on the drive
FFMpeg.Snapshot(mediaFileAnalysis, outputPath, new Size(200, 400), TimeSpan.FromMinutes(1)) FFMpeg.Snapshot(inputPath, outputPath, new Size(200, 400), TimeSpan.FromMinutes(1));
``` ```
Convert to and/or from streams Convert to and/or from streams
@ -89,25 +88,25 @@ FFMpeg.JoinImageSequence(@"..\joined_video.mp4", frameRate: 1,
Mute videos: Mute videos:
```csharp ```csharp
FFMpeg.Mute(inputFilePath, outputFilePath); FFMpeg.Mute(inputPath, outputPath);
``` ```
Save audio track from video: Save audio track from video:
```csharp ```csharp
FFMpeg.ExtractAudio(inputVideoFilePath, outputAudioFilePath); FFMpeg.ExtractAudio(inputPath, outputPath);
``` ```
Add or replace audio track on video: Add or replace audio track on video:
```csharp ```csharp
FFMpeg.ReplaceAudio(inputVideoFilePath, inputAudioFilePath, outputVideoFilePath); FFMpeg.ReplaceAudio(inputPath, inputAudioPath, outputPath);
``` ```
Add poster image to audio file (good for youtube videos): Add poster image to audio file (good for youtube videos):
```csharp ```csharp
FFMpeg.PosterWithAudio(inputImageFilePath, inputAudioFilePath, outputVideoFilePath); FFMpeg.PosterWithAudio(inputPath, inputAudioPath, outputPath);
// or // or
var image = Image.FromFile(inputImageFile); var image = Image.FromFile(inputImagePath);
image.AddAudio(inputAudioFilePath, outputVideoFilePath); image.AddAudio(inputAudioPath, outputPath);
``` ```
Other available arguments could be found in `FFMpegCore.Arguments` namespace. Other available arguments could be found in `FFMpegCore.Arguments` namespace.
@ -135,10 +134,11 @@ var videoFramesSource = new RawVideoPipeSource(CreateFrames(64)) //pass IEnumera
{ {
FrameRate = 30 //set source frame rate FrameRate = 30 //set source frame rate
}; };
FFMpegArguments await FFMpegArguments
.FromPipeInput(videoFramesSource, <input_stream_options>) .FromPipeInput(videoFramesSource)
.OutputToFile("temporary.mp4", false, <output_options>) .OutputToFile(outputPath, false, options => options
.ProcessSynchronously(); .WithVideoCodec(VideoCodec.LibVpx))
.ProcessAsynchronously();
``` ```
if you want to use `System.Drawing.Bitmap` as `IVideoFrame`, there is a `BitmapVideoFrameWrapper` wrapper class. if you want to use `System.Drawing.Bitmap` as `IVideoFrame`, there is a `BitmapVideoFrameWrapper` wrapper class.
@ -179,13 +179,19 @@ If these folders are not defined, it will try to find the binaries in `/root/(ff
#### Option 1 #### Option 1
The default value (`\\FFMPEG\\bin`) can be overwritten via the `FFMpegOptions` class: The default value of an empty string (expecting ffmpeg to be found through PATH) can be overwritten via the `FFOptions` class:
```c# ```c#
public Startup() // setting global options
{ GlobalFFOptions.Configure(new FFOptions { BinaryFolder = "./bin", TemporaryFilesFolder = "/tmp" });
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = "./bin", TemporaryFilesFolder = "/tmp" }); // or
} GlobalFFOptions.Configure(options => options.BinaryFolder = "./bin");
// or individual, per-run options
await FFMpegArguments
.FromFileInput(inputPath)
.OutputToFile(outputPath)
.ProcessAsynchronously(true, new FFOptions { BinaryFolder = "./bin", TemporaryFilesFolder = "/tmp" });
``` ```
#### Option 2 #### Option 2