• Documentation
  • Api
  • Xabe.FFmpeg
  • IConversion
Show / Hide Table of Contents
  • System
    • TimeExtensions
  • Xabe.FFmpeg
    • AudioCodec
    • AudioStream
    • BitstreamFilter
    • Conversion
    • ConversionPreset
    • ConversionQueue
    • ConversionQueue.ConversionQueueEventHandler
    • FFmpeg
    • Flag
    • Format
    • HardwareAccelerator
    • Hash
    • IAudioStream
    • IConversion
    • IConversionResult
    • IFilterConfiguration
    • IInputBuilder
    • IMediaInfo
    • InputBuilder
    • IProbe
    • IStream
    • ISubtitleStream
    • IVideoStream
    • MediaInfo
    • ParameterPosition
    • PixelFormat
    • Position
    • Probe
    • RotateDegrees
    • StreamType
    • SubtitleStream
    • VideoCodec
    • VideoSize
    • VideoStream
  • Xabe.FFmpeg.Downloader
    • FFmpegDownloader
    • FFmpegVersion
    • IFFMpegDownloaderBase
  • Xabe.FFmpeg.Events
    • ConversionProgressEventArgs
    • ConversionProgressEventHandler
  • Xabe.FFmpeg.Exceptions
    • ConversionException
    • FFmpegNoSuitableOutputFormatFoundException
    • FFmpegNotFoundException
    • HardwareAcceleratorNotFoundException
    • InvalidBitstreamFilterException
    • InvalidInputException
    • UnknownDecoderException

Interface IConversion

Allows to prepare and start IConversion.

Namespace: Xabe.FFmpeg
Assembly: Xabe.FFmpeg.dll
Syntax
public interface IConversion

Properties

FFmpegProcessId

FFmpeg process id

Declaration
int? FFmpegProcessId { get; }
Property Value
Type Description
System.Nullable<System.Int32>

OutputFilePath

Output file path

Declaration
string OutputFilePath { get; }
Property Value
Type Description
System.String

Methods

AddParameter(String, ParameterPosition)

Add additional parameters for the conversion (They must be well formed)

Declaration
IConversion AddParameter(string parameter, ParameterPosition parameterPosition = ParameterPosition.PostInput)
Parameters
Type Name Description
System.String parameter

Parameter to set

ParameterPosition parameterPosition

Position of parameter

Returns
Type Description
IConversion

IConversion object

AddStream(IEnumerable<IStream>)

Add streams to output file

Declaration
IConversion AddStream(IEnumerable<IStream> streams)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IStream> streams

Streams to add

Returns
Type Description
IConversion

IConversion object

AddStream<T>(T[])

Add streams to output file

Declaration
IConversion AddStream<T>(params T[] streams)

    where T : IStream
Parameters
Type Name Description
T[] streams

Streams to add

Returns
Type Description
IConversion

IConversion object

Type Parameters
Name Description
T

Build()

Build FFmpeg arguments

Declaration
string Build()
Returns
Type Description
System.String

Arguments

BuildVideoFromImages(IEnumerable<String>)

Builds a video from a directory containing one or more sequentially named images

Declaration
IConversion BuildVideoFromImages(IEnumerable<string> imageFiles)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> imageFiles

List of Image Files to Build into a Video

Returns
Type Description
IConversion

IConversion object

BuildVideoFromImages(Int32, Func<String, String>)

Builds a video from a directory containing one or more sequentially named images

Declaration
IConversion BuildVideoFromImages(int startNumber, Func<string, string> buildInputFileName)
Parameters
Type Name Description
System.Int32 startNumber

The number of the image to start building video from

System.Func<System.String, System.String> buildInputFileName

Delegate Function to build up custom filename when inputting multiple files

Returns
Type Description
IConversion

IConversion object

Clear()

Clear saved parameters

Declaration
void Clear()

ExtractEveryNthFrame(Int32, Func<String, String>)

Extracts Every frameNo frame of the input video and outputs as a png image

Declaration
IConversion ExtractEveryNthFrame(int frameNo, Func<string, string> buildOutputFileName)
Parameters
Type Name Description
System.Int32 frameNo

The frame interval to extract

System.Func<System.String, System.String> buildOutputFileName

Delegate Function to build up custom filename when outputting multiple files

Returns
Type Description
IConversion

ExtractNthFrame(Int32, Func<String, String>)

Extracts the frameNo'th frame of the input video and outputs as a png image

Declaration
IConversion ExtractNthFrame(int frameNo, Func<string, string> buildOutputFileName)
Parameters
Type Name Description
System.Int32 frameNo

The frame to extract

System.Func<System.String, System.String> buildOutputFileName

Delegate Function to build up custom filename when outputting multiple files

Returns
Type Description
IConversion

GetScreenCapture(Double)

Captures the entire display for length seconds at the specified framerate

Declaration
IConversion GetScreenCapture(double frameRate)
Parameters
Type Name Description
System.Double frameRate

The framrate at which to capture the display

Returns
Type Description
IConversion

IConversion object

SetAudioBitrate(Int64)

Sets The bitrate of the audio streams to the supplied value in bytes

Declaration
IConversion SetAudioBitrate(long bitrate)
Parameters
Type Name Description
System.Int64 bitrate

The required Bitrate Value

Returns
Type Description
IConversion

IConversion object

SetFrameRate(Double)

Builds the -framerate option for the output of this conversion

Declaration
IConversion SetFrameRate(double frameRate)
Parameters
Type Name Description
System.Double frameRate

The desired framerate of the output

Returns
Type Description
IConversion

IConversion object

SetHashFormat(String)

Set the hash format of IConversion.

Declaration
IConversion SetHashFormat(string format)
Parameters
Type Name Description
System.String format

The required hash format

Returns
Type Description
IConversion

IConversion object

SetHashFormat(Hash)

Set the hash format of IConversion.

Declaration
IConversion SetHashFormat(Hash format)
Parameters
Type Name Description
Hash format

The required hash format

Returns
Type Description
IConversion

IConversion object

SetInputFormat(String)

Sets the format for the input file using the -f option before the input file name

Declaration
IConversion SetInputFormat(string inputFormat)
Parameters
Type Name Description
System.String inputFormat

The input format to set

Returns
Type Description
IConversion

IConversion object

SetInputFormat(Format)

Sets the format for the input file using the -f option before the input file name

Declaration
IConversion SetInputFormat(Format inputFormat)
Parameters
Type Name Description
Format inputFormat

The input format to set

Returns
Type Description
IConversion

IConversion object

SetInputFrameRate(Double)

Builds the -framerate option for the input of this conversion

Declaration
IConversion SetInputFrameRate(double frameRate)
Parameters
Type Name Description
System.Double frameRate

the desired framerate of the input in bytes

Returns
Type Description
IConversion

IConversion object

SetInputTime(Nullable<TimeSpan>)

Sets input capture length (-t input argument) Typically used with the GetScreenCapture Function to stop capturing after a time interval

Declaration
IConversion SetInputTime(TimeSpan? seek)
Parameters
Type Name Description
System.Nullable<System.TimeSpan> seek

Output Length

Returns
Type Description
IConversion

IConversion

SetOutput(String)

Set output path

Declaration
IConversion SetOutput(string outputPath)
Parameters
Type Name Description
System.String outputPath

Output media file

Returns
Type Description
IConversion

IConversion object

SetOutputFormat(String)

Sets the format for the output file using the -f option before the output file name

Declaration
IConversion SetOutputFormat(string outputFormat)
Parameters
Type Name Description
System.String outputFormat

The output format to set

Returns
Type Description
IConversion

IConversion object

SetOutputFormat(Format)

Sets the format for the output file using the -f option before the output file name

Declaration
IConversion SetOutputFormat(Format outputFormat)
Parameters
Type Name Description
Format outputFormat

The output format to set

Returns
Type Description
IConversion

IConversion object

SetOutputTime(Nullable<TimeSpan>)

Sets output file length (-t output argument)

Declaration
IConversion SetOutputTime(TimeSpan? seek)
Parameters
Type Name Description
System.Nullable<System.TimeSpan> seek

Output Length

Returns
Type Description
IConversion

IConversion

SetOverwriteOutput(Boolean)

Set overwrite output file parameter

Declaration
IConversion SetOverwriteOutput(bool overwrite)
Parameters
Type Name Description
System.Boolean overwrite

Should be output file overwritten or not. If not overwrite and file exists conversion will throw ConversionException

Returns
Type Description
IConversion

IConversion object

SetPixelFormat(String)

Sets the pixel format for the output file using the -pix_fmt option before the output file name

Declaration
IConversion SetPixelFormat(string pixelFormat)
Parameters
Type Name Description
System.String pixelFormat

The output pixel format to set

Returns
Type Description
IConversion

IConversion object

SetPixelFormat(PixelFormat)

Sets the pixel format for the output file using the -pix_fmt option before the output file name

Declaration
IConversion SetPixelFormat(PixelFormat pixelFormat)
Parameters
Type Name Description
PixelFormat pixelFormat

The output pixel format to set

Returns
Type Description
IConversion

IConversion object

SetPreset(ConversionPreset)

Set preset of IConversion. Slower speed equals better compression and quality.

Declaration
IConversion SetPreset(ConversionPreset preset)
Parameters
Type Name Description
ConversionPreset preset

Preset

Returns
Type Description
IConversion

IConversion object

SetPriority(Nullable<ProcessPriorityClass>)

Set priority of ffmpeg process

Declaration
IConversion SetPriority(ProcessPriorityClass? priority)
Parameters
Type Name Description
System.Nullable<System.Diagnostics.ProcessPriorityClass> priority

FFmpeg process priority

Returns
Type Description
IConversion

SetSeek(Nullable<TimeSpan>)

Seeks in output file to position. (-ss argument)

Declaration
IConversion SetSeek(TimeSpan? seek)
Parameters
Type Name Description
System.Nullable<System.TimeSpan> seek

Position

Returns
Type Description
IConversion

IConversion

SetVideoBitrate(Int64)

Sets The bitrate of the video streams to the supplied value in bytes

Declaration
IConversion SetVideoBitrate(long bitrate)
Parameters
Type Name Description
System.Int64 bitrate

The required Bitrate Value

Returns
Type Description
IConversion

IConversion object

Start()

Start conversion

Declaration
Task<IConversionResult> Start()
Returns
Type Description
System.Threading.Tasks.Task<IConversionResult>

Conversion result

Exceptions
Type Condition
ConversionException

Occurs when FFmpeg process return error.

System.ArgumentException

Occurs when no FFmpeg executables were found.

System.InvalidOperationException
System.ObjectDisposedException

Start(String)

Start an FFmpeg process with specified arguments

Declaration
Task<IConversionResult> Start(string parameters)
Parameters
Type Name Description
System.String parameters

FFmpeg parameters eg. "-i sample.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000"

Returns
Type Description
System.Threading.Tasks.Task<IConversionResult>

Conversion result

Exceptions
Type Condition
ConversionException

Occurs when FFmpeg process return error.

System.ArgumentException

Occurs when no FFmpeg executables were found.

System.InvalidOperationException
System.ObjectDisposedException

Start(String, CancellationToken)

Start an FFmpeg process with specified arguments

Declaration
Task<IConversionResult> Start(string parameters, CancellationToken cancellationToken)
Parameters
Type Name Description
System.String parameters

FFmpeg parameters eg. "-i sample.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000"

System.Threading.CancellationToken cancellationToken

Cancellation token

Returns
Type Description
System.Threading.Tasks.Task<IConversionResult>

Conversion result

Exceptions
Type Condition
ConversionException

Occurs when FFmpeg process return error.

System.ArgumentException

Occurs when no FFmpeg executables were found.

System.InvalidOperationException
System.ObjectDisposedException
System.Threading.Tasks.TaskCanceledException

Occurs when task was cancalled.

Start(CancellationToken)

Start conversion

Declaration
Task<IConversionResult> Start(CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.CancellationToken cancellationToken

Cancellation token

Returns
Type Description
System.Threading.Tasks.Task<IConversionResult>

Conversion result

Exceptions
Type Condition
ConversionException

Occurs when FFmpeg process return error.

System.ArgumentException

Occurs when no FFmpeg executables were found.

System.InvalidOperationException
System.ObjectDisposedException
System.Threading.Tasks.TaskCanceledException

Occurs when task was cancalled.

UseHardwareAcceleration(String, String, String, Int32)

Use hardware acceleration. This option set -threads to 1 for compatibility reasons. This should be use with proper codec (e.g. -c:v h264_nvenc or h264_cuvid)

Declaration
IConversion UseHardwareAcceleration(string hardwareAccelerator, string decoder, string encoder, int device = 0)
Parameters
Type Name Description
System.String hardwareAccelerator

Hardware accelerator. List of all accelerators available for your system - "ffmpeg -hwaccels"

System.String decoder

Codec using to decode input video.

System.String encoder

Codec using to encode output video.

System.Int32 device

Number of device (0 = default video card) if more than one video card.

Returns
Type Description
IConversion

IConversion object

UseHardwareAcceleration(HardwareAccelerator, VideoCodec, VideoCodec, Int32)

Use hardware acceleration. This option set -threads to 1 for compatibility reasons. This should be use with proper codec (e.g. -c:v h264_nvenc or h264_cuvid)

Declaration
IConversion UseHardwareAcceleration(HardwareAccelerator hardwareAccelerator, VideoCodec decoder, VideoCodec encoder, int device = 0)
Parameters
Type Name Description
HardwareAccelerator hardwareAccelerator

Hardware accelerator. List of all accelerators available for your system - "ffmpeg -hwaccels"

VideoCodec decoder

Codec using to decode input video.

VideoCodec encoder

Codec using to encode output video.

System.Int32 device

Number of device (0 = default video card) if more than one video card.

Returns
Type Description
IConversion

IConversion object

UseMultiThread(Boolean)

Defines if converter should use all CPU cores

Declaration
IConversion UseMultiThread(bool multiThread)
Parameters
Type Name Description
System.Boolean multiThread

Use multiThreads

Returns
Type Description
IConversion

IConversion object

UseMultiThread(Int32)

Defines thread count used by converter

Declaration
IConversion UseMultiThread(int threadCount)
Parameters
Type Name Description
System.Int32 threadCount

Number of used threads

Returns
Type Description
IConversion

IConversion object

UseShortest(Boolean)

Finish encoding when the shortest input stream ends. (-shortest)

Declaration
IConversion UseShortest(bool useShortest)
Parameters
Type Name Description
System.Boolean useShortest
Returns
Type Description
IConversion

IConversion object

Events

OnDataReceived

Fires when FFmpeg process print sonething

Declaration
event DataReceivedEventHandler OnDataReceived
Event Type
Type Description
System.Diagnostics.DataReceivedEventHandler

OnProgress

Fires when FFmpeg progress changes

Declaration
event ConversionProgressEventHandler OnProgress
Event Type
Type Description
ConversionProgressEventHandler
In This Article
  • Properties
    • FFmpegProcessId
    • OutputFilePath
  • Methods
    • AddParameter(String, ParameterPosition)
    • AddStream(IEnumerable<IStream>)
    • AddStream<T>(T[])
    • Build()
    • BuildVideoFromImages(IEnumerable<String>)
    • BuildVideoFromImages(Int32, Func<String, String>)
    • Clear()
    • ExtractEveryNthFrame(Int32, Func<String, String>)
    • ExtractNthFrame(Int32, Func<String, String>)
    • GetScreenCapture(Double)
    • SetAudioBitrate(Int64)
    • SetFrameRate(Double)
    • SetHashFormat(String)
    • SetHashFormat(Hash)
    • SetInputFormat(String)
    • SetInputFormat(Format)
    • SetInputFrameRate(Double)
    • SetInputTime(Nullable<TimeSpan>)
    • SetOutput(String)
    • SetOutputFormat(String)
    • SetOutputFormat(Format)
    • SetOutputTime(Nullable<TimeSpan>)
    • SetOverwriteOutput(Boolean)
    • SetPixelFormat(String)
    • SetPixelFormat(PixelFormat)
    • SetPreset(ConversionPreset)
    • SetPriority(Nullable<ProcessPriorityClass>)
    • SetSeek(Nullable<TimeSpan>)
    • SetVideoBitrate(Int64)
    • Start()
    • Start(String)
    • Start(String, CancellationToken)
    • Start(CancellationToken)
    • UseHardwareAcceleration(String, String, String, Int32)
    • UseHardwareAcceleration(HardwareAccelerator, VideoCodec, VideoCodec, Int32)
    • UseMultiThread(Boolean)
    • UseMultiThread(Int32)
    • UseShortest(Boolean)
  • Events
    • OnDataReceived
    • OnProgress
Back to top Xabe