aminrd
aminrd

Reputation: 5060

How to pass an in-memory-file address to another function in .NET

I have an in-memory file called byte[] FileContent and a third-party package ( FFMPEG in my case) that converts the given input file and saves it into the output directory:

FFMPEGCore.Join("/path/to/output.mp4", "path/to/input.mp4");

Unfortunately, at the API level, I cannot writes by byte [] into a file, so I was wondering if there's a way to keep everything in-memory and pass the address of my in-memory input, output to FFMPEGCore.Join?

Upvotes: 0

Views: 78

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112682

According to this you can write .FromPipeInput(new StreamPipeSource(inputStream))

Example:

byte[] FileContent = ...;
using var memoryStream = new MemoryStream(FileContent);
await FFMpegArguments
    .FromPipeInput(new StreamPipeSource(memoryStream))
    .OutputToFile(...)
    .ProcessAsynchronously();

Upvotes: 1

Related Questions