-
Notifications
You must be signed in to change notification settings - Fork 0
FFmpeg Processors
Important
Consider streaming a file if the file type is supported.
These audio processors read 32-bit floats from FFmpeg's standard output.
Example
To stream live radio, pass the URL to the UseFFmpeg extension method on an AudioPlayer
using SecretLabNAudio.FFmpeg.Extensions;
// radio1.hu
audioPlayer.UseFFmpeg("https://icast.connectmedia.hu/5201/live.mp3");The above code is the same as:
using SecretLabNAudio.Core.Extensions;
using SecretLabNAudio.FFmpeg.Processors;
audioPlayer.Use(AsyncBufferedFFmpegAudioProcessor.CreatePlayerCompatible("https://icast.connectmedia.hu/5201/live.mp3"));This is the base class for processing FFmpeg output asynchronously. It cannot be inherited from user code.
The reader thread waits for 100 milliseconds before reading again if the buffer's sample count
is greater than or equal to SleepThresholdSamples
Reading from this provider will pad the output with silence until the first time the
underlying buffer has at least SleepThresholdSamples
The capacity can only be set in the constructor; it has a minimum value of 1920 samples.
The sleep threshold can be modified at any time. it defaults to 75% of the capacity.
Setting the Endless property to true will make the Read method pad the output with
silence if the buffer is empty, even if enough data has been buffered earlier.
This can be useful if the source sometimes hangs for a bit.
Tip
Use the HandleError or MapError extension method to deal with errors.
Call the StopBuffering method to stop the buffering thread.
After invocation, remaining data can still be read, but buffering cannot be restarted.
This method is invoked when Dispose is called.
Call the ClearBuffer method to discard data in the buffer. To make the processor
pad the output until enough data is read again, set the waitForRefill parameter to true
BufferingState transition
-
ResolvingStream(if stream-based) StartingFFmpegPreFillingBuffer-
Reading- back to step 3 if:-
ClearBufferis called -
Endlessistrueand not enough data is available
-
Ended
If the state is Reading or Ended, and no error has occurred, the underlying buffer's remaining data
can be extracted with the Read method. Otherwise, the provided buffer is cleared (padded with silence).
A simple subclass of AsyncFFmpegProcessorBase. It accepts a string input source (e.g. file path, URL).
FFmpeg is started with the specified arguments.
A subclass of AsyncFFmpegProcessorBase that reads from a managed Stream
A delegate is invoked to fetch the stream asynchronously.
If the delegate throws an exception, the AsyncException property will be set.
When the stream has been resolved, FFmpeg is started, and the stream is copied to FFmpeg's standard input.
If CopyToAsync throws before buffering is canceled, the AsyncException property will be set.
Important
This processor blocks the current thread until FFmpeg process is started, and when reading from the standard output.
A fully synchronous audio processor that starts FFmpeg in the constructor. When calling read, it blocks the calling thread until FFmpeg outputs data.
- π Home
- πΌ Digital Audio Basics
- π Examples
- π¦ Supported Formats
- β¬οΈ Migrating from v1
- π AudioPlayer
- πΎ Short Clips
- πΏ Streaming From Disk
- ποΈ Speaker Groups
- π Sample Providers
- β»οΈ Pooling
- π¨ SendEngines
- π§ Personalizing Speakers
- π Monitoring Output
- βοΈ AudioQueue
- πΆ Mixer
- ποΈοΈ ProcessorChain
- π§° Intro to FFmpeg
- π© Installation
- ποΈ FFmpegArguments
- πͺ Adding Short Clips
- π FFmpeg Audio Processors
- ποΈ Caches
Caution
v1 will be out of support soon.