ZZMpeg 1.0.2

There is a newer version of this package available.
See the version list below for details.
Install-Package ZZMpeg -Version 1.0.2
dotnet add package ZZMpeg --version 1.0.2
<PackageReference Include="ZZMpeg" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZZMpeg --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZZMpeg, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ZZMpeg as a Cake Addin
#addin nuget:?package=ZZMpeg&version=1.0.2

// Install ZZMpeg as a Cake Tool
#tool nuget:?package=ZZMpeg&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ZZMpeg - highlevel wrapper for FFMpeg libraries (not ffmpeg binary) for WPF. Basic usage:

  1. Before using any methods you must call FFMpeg.Initialize()
  2. Call FFMpeg.ExtractVideoFrame to get preview image from video
  3. Call FFMpeg.ConvertMediaFile to asynchronously convert video to other format

Example converting video:

    public enum ConvertionState
    {
        Idle,
        Converting,
        Cancelling,
        Cancelled,
        Error,
        Done
    }

    public class ConvertOperation: INotifyPropertyChanged
    {
        #region INPC implementation

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void NotifyPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        private string path;
        private string format;
        private CancellationTokenSource cTokenSource;
        private ConvertionState state;

        public string Name => Path.GetFileName(path);
        public BindableProgress<double> Progress { get; private set; }

        public ConvertionState State
        {
            get => state;
            set
            {
                state = value;
                NotifyPropertyChanged("State");
            }
        }

        public ConvertOperation(string filePath, string destFormat)
        {
            path = filePath;
            format = destFormat;
            Progress = new BindableProgress<double>();
            cTokenSource = new CancellationTokenSource();
            State = ConvertionState.Idle;
        }

        public async Task Start()
        {
            State = ConvertionState.Converting;
            string dir = Path.GetDirectoryName(path);
            string outPath = Path.Combine(dir, $"converted.{format}");

            try
            {
                EncoderParameters parameters = new EncoderParameters();
                FFMpeg.EncoderParametersInit(ref parameters);
                parameters.VideoEncoder = VideoCodec.VP8.StringValue();
                parameters.AudioEncoder = AudioCodec.VORBIS.StringValue();
                await FFMpeg.ConvertMediaFile(path, outPath, parameters, Progress, cTokenSource.Token);
                State = ConvertionState.Done;
            }
            catch(TaskCanceledException)
            {
                State = ConvertionState.Cancelled;
            }
            catch(Exception ex)
            {
                State = ConvertionState.Error;
                Console.WriteLine($"Error converting file: {ex.Message}");
                MessageBox.Show($"Error converting file: {ex.Message}");
            }
        }

        public void Cancel()
        {
            State = ConvertionState.Cancelling;
            cTokenSource.Cancel();
        }
    }

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 499 9/26/2018
1.0.3 712 2/1/2018
1.0.2 542 12/14/2017