UWP_ZZMpeg 1.0.1

FFMpeg transcoding wrapper for UWP(x86)

Install-Package UWP_ZZMpeg -Version 1.0.1
dotnet add package UWP_ZZMpeg --version 1.0.1
<PackageReference Include="UWP_ZZMpeg" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UWP_ZZMpeg --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

UWP_ZZMpeg- highlevel wrapper for FFMpeg libraries (not ffmpeg binary) for UWP(x86 only).
Basic usage:

  1. Create an object FFMpeg
  2. Call FFMpeg.ExtractVideoFrame to get preview image from video
  3. Call FFMpeg.ConvertMediaFile to asynchronously convert video to other format
  4. Call FFMpeg.AssembleMediaFiles to asynchronously concat multiple input files into single output. They are concatinated in the same order they are specified in inputFiles array
  5. Call FFMpeg.SplitMediaFile to asynchronously split source media file into specified number of lesser files of equal duartion
  6. Call FFmpeg.SplitMediaFileWithTS to asynchronously split source media file into several lesser files based on specified timestamps array
  7. Call FFMpeg.ExtractMediaInfo to get media info from file

Example converting video:

public class ConvertOperation : INotifyPropertyChanged{ 

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

 #region INPC implementation

    public event PropertyChangedEventHandler PropertyChanged;
    protected void SetMyProperty([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

    }

    #endregion
    
    private bool _isEnableInterface = true;
    private string path;
    private string outFolderPath;
    private string format;
    private CancelTaskToken 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;
            SetMyProperty();
        }
    }

  public bool IsEnableInterface
    {
        get
        {
            return _isEnableInterface;
        }
        set
        {
            if (value != _isEnableInterface)
            {
                _isEnableInterface = value;
               
                SetMyProperty();
            }
        }
    }

    public ConvertOperation(string filePath, string outFolderPath,string destFormat)
    {

        path = filePath;
        this.outFolderPath = outFolderPath;
        format = destFormat;
        Progress = new BindableProgress<double>();
        cTokenSource = new CancelTaskToken();
        State = ConvertionState.Idle;
    }

  protected async Task LockInterface(Func<Task> p)
    {
        bool value = IsEnableInterface;
        IsEnableInterface = false;
        try
        {
            await p.Invoke();
        }
        catch (Exception ex)
        {
        }
        IsEnableInterface = value;
    }
   

    public async Task Start(CancelTaskToken cToken )
    {
        await LockInterface(async () => {
            State = ConvertionState.Converting;
            string name = Path.GetFileNameWithoutExtension(path);
            string outPath = Path.Combine(outFolderPath, $"converted_{name}.{format}");

            try
            {
                EncoderParameters parameters = new EncoderParameters();
                FFMpeg ffmpeg = new FFMpeg();
                ffmpeg.EncoderParametersInit(parameters);
                parameters.AudioEncoder = AudioCodec.AAC.StringValue();
                var result = ffmpeg.ConvertMediaFile(path, outPath, parameters, cTokenSource);
                result.Progress = (IAsyncActionWithProgress<double> info, double value) => {
                    Progress.ProgressChangedHandler(null, value * 100);

                };
                await result;
                State = ConvertionState.Done;
            }
            catch (TaskCanceledException)
            {
                State = ConvertionState.Cancelled;
            }
            catch (Exception ex)
            {
                State = ConvertionState.Error;
                System.Diagnostics.Debug.WriteLine($"Error converting file: {ex.Message}");
            }
        });
       
    }

    public void Cancel()
    {
        if (State != ConvertionState.Converting)
            return;
        State = ConvertionState.Cancelling;
        cTokenSource.Cancel();
    }
}

UWP_ZZMpeg- highlevel wrapper for FFMpeg libraries (not ffmpeg binary) for UWP(x86 only).
Basic usage:

  1. Create an object FFMpeg
  2. Call FFMpeg.ExtractVideoFrame to get preview image from video
  3. Call FFMpeg.ConvertMediaFile to asynchronously convert video to other format
  4. Call FFMpeg.AssembleMediaFiles to asynchronously concat multiple input files into single output. They are concatinated in the same order they are specified in inputFiles array
  5. Call FFMpeg.SplitMediaFile to asynchronously split source media file into specified number of lesser files of equal duartion
  6. Call FFmpeg.SplitMediaFileWithTS to asynchronously split source media file into several lesser files based on specified timestamps array
  7. Call FFMpeg.ExtractMediaInfo to get media info from file

Example converting video:

public class ConvertOperation : INotifyPropertyChanged{ 

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

 #region INPC implementation

    public event PropertyChangedEventHandler PropertyChanged;
    protected void SetMyProperty([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

    }

    #endregion
    
    private bool _isEnableInterface = true;
    private string path;
    private string outFolderPath;
    private string format;
    private CancelTaskToken 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;
            SetMyProperty();
        }
    }

  public bool IsEnableInterface
    {
        get
        {
            return _isEnableInterface;
        }
        set
        {
            if (value != _isEnableInterface)
            {
                _isEnableInterface = value;
               
                SetMyProperty();
            }
        }
    }

    public ConvertOperation(string filePath, string outFolderPath,string destFormat)
    {

        path = filePath;
        this.outFolderPath = outFolderPath;
        format = destFormat;
        Progress = new BindableProgress<double>();
        cTokenSource = new CancelTaskToken();
        State = ConvertionState.Idle;
    }

  protected async Task LockInterface(Func<Task> p)
    {
        bool value = IsEnableInterface;
        IsEnableInterface = false;
        try
        {
            await p.Invoke();
        }
        catch (Exception ex)
        {
        }
        IsEnableInterface = value;
    }
   

    public async Task Start(CancelTaskToken cToken )
    {
        await LockInterface(async () => {
            State = ConvertionState.Converting;
            string name = Path.GetFileNameWithoutExtension(path);
            string outPath = Path.Combine(outFolderPath, $"converted_{name}.{format}");

            try
            {
                EncoderParameters parameters = new EncoderParameters();
                FFMpeg ffmpeg = new FFMpeg();
                ffmpeg.EncoderParametersInit(parameters);
                parameters.AudioEncoder = AudioCodec.AAC.StringValue();
                var result = ffmpeg.ConvertMediaFile(path, outPath, parameters, cTokenSource);
                result.Progress = (IAsyncActionWithProgress<double> info, double value) => {
                    Progress.ProgressChangedHandler(null, value * 100);

                };
                await result;
                State = ConvertionState.Done;
            }
            catch (TaskCanceledException)
            {
                State = ConvertionState.Cancelled;
            }
            catch (Exception ex)
            {
                State = ConvertionState.Error;
                System.Diagnostics.Debug.WriteLine($"Error converting file: {ex.Message}");
            }
        });
       
    }

    public void Cancel()
    {
        if (State != ConvertionState.Converting)
            return;
        State = ConvertionState.Cancelling;
        cTokenSource.Cancel();
    }
}

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 339 2/1/2018
1.0.0 341 1/29/2018