Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConvertAsync never returns #69

Open
josago97 opened this issue Aug 24, 2022 · 2 comments
Open

ConvertAsync never returns #69

josago97 opened this issue Aug 24, 2022 · 2 comments

Comments

@josago97
Copy link

josago97 commented Aug 24, 2022

Hi,
I am trying to convert a file from .webm format to .gif using streams. I have been testing and the engine works fine if I use files. However, if I use streams, the engine freezes when I call the ConvertAsync function, no event or error is raised in the process. Here is the code that I am using.

I am using the version 7.1.3

Engine ffmpeg = new Engine();
ffmpeg.Progress += OnProgress;
ffmpeg.Data += OnData;
ffmpeg.Error += OnError;
ffmpeg.Complete += OnComplete;
var options = new ConversionOptions
{
    ExtraArguments = "-f gif -vf \"fps=30,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\" -loop 0 -y"
};
InputFile input = new InputFile("https://statics.memondo.com/p/99/gifs/2010/12/GIF_8818_745f4adf060a4d08bf83f77d6ac899d5_taconazo_magico.webm");
Stream stream = await ffmpeg.ConvertAsync(input, options, default);
@lj9142
Copy link

lj9142 commented Nov 27, 2023

@josago97 did you figure out this issue? I am getting the same problem.

@josago97
Copy link
Author

josago97 commented Nov 27, 2023

No, I had to use ffmpeg directly, without using this library. Here my code:

public async Task<Stream> ConvertToGifAsync(Stream data)
    {
        MemoryStream output = new MemoryStream();

        ProcessStartInfo processInfo = new ProcessStartInfo
        {
            RedirectStandardInput = true,
            RedirectStandardOutput = true,
            UseShellExecute = false,
            CreateNoWindow = true,
            Arguments = "-i pipe: -f gif -vf \"fps=30,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\" -loop 0 -y pipe:",
            FileName = "ffmpeg.exe"
        };

        using Process process = Process.Start(processInfo);
        data.Position = 0;
        await data.CopyToAsync(process.StandardInput.BaseStream);
        process.StandardInput.Close();
        await process.StandardOutput.BaseStream.CopyToAsync(output);
        await process.WaitForExitAsync();

        return output;
    }

TobiasFaller added a commit to TobiasFaller/FFmpeg.NET that referenced this issue Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants