user3646458
user3646458

Reputation: 29

c# async await task : cannot await 'void'

I've been using Xabe.FFmpeg for a project. Tasks, async and await are new to me but I've been learning. I trying do a basic conversion with Xabe.FFmpeg. I get an error that says "cannot await 'void'".

public partial class FormMain : Form
{
    public FormMain()
    {
        InitializeComponent();
    }

    private void FormMain_Load(object sender, EventArgs e)
    {
        Run().GetAwaiter().GetResult();
    }

    private static async Task Run()
    {
        string inputFileName = @"C:\Users\npsie\Videos\Sample.mkv";
        string outputFileName = Path.ChangeExtension(inputFileName, ".mp4");
        await FFmpeg.FFmpeg.Conversions.FromSnippet.ToMp4(inputFileName, outputFileName).Start();
    }
}

Upvotes: 2

Views: 460

Answers (1)

David
David

Reputation: 218837

You're trying to await the call to .Start() on the Task returned by ToMp4(). Remove that call to Start() and await the returned Task itself:

await FFmpeg.FFmpeg.Conversions.FromSnippet.ToMp4(inputFileName, outputFileName);

Upvotes: 6

Related Questions