FFMpegCore
FFMpegCore copied to clipboard
Issue processing .gif with FromPipeInput
When trying to process .gif files with FromPipeInput I only see 520 bytes being written to either the file or stream in question.
Code that is trying to be used when working as intended:
private async Task<Stream> HandleThumbnailVideo(Stream stream)
{
var outputStream = new MemoryStream();
var info = await FFProbe.AnalyseAsync(stream);
var width = info.VideoStreams[0].Width;
var height = info.VideoStreams[0].Height;
var aspect = (float)width / height;
if (Math.Abs(aspect - 1) >= float.Epsilon)
throw new FormatException("Aspect ratio not 1:1");
if (width < 256)
throw new FormatException("Size not at or greater than 256x256");
stream.Seek(0, SeekOrigin.Begin);
await FFMpegArguments
.FromPipeInput(new StreamPipeSource(stream))
.OutputToPipe(new StreamPipeSink(outputStream), options => options
.WithVideoCodec("libvpx-vp9")
.ForceFormat("webm")
.WithConstantRateFactor(12)
.WithFramerate(60)
.WithFastStart()
.ForcePixelFormat("yuv420p")
.WithVideoBitrate(500)
.DisableChannel(Channel.Audio)
.WithCustomArgument("-vf \"scale='min(512,iw)':-1\"")
.WithCustomArgument("-quality good")
.WithCustomArgument("-cpu-used 0"))
.ProcessAsynchronously();
return outputStream;
}
I have tested the exact command arguments in a console and FFmpeg has 0 issues processing it from the file then. I also tested this code snip it with mp4 and had 0 issues with it only writing 520 bytes.