AydinAdn/MediaToolkit

Can MediaFile support a byte[] or Stream

Opened this issue · 3 comments

can instantiating a MediaFile object be updated to support working with byte arrays or streams?

Any solutions ?

I dont think this is possible as the MediaToolkit is just an wrapper to the FFmpeg assembly. The FFmpeg assembly running in another process, cannot stream its data to another process the same way it would be possible with interopt.

if this library can do it. its possible to do.

url : https://stackoverflow.com/questions/15881574/get-image-from-video-stream-in-c-sharp

answer :

It is possible to capture frames with free VideoConverter for .NET that actually is a wrapper to FFMpeg tool. The idea is using live streaming capabilities (to C# Stream) of VideoConverter for special FFMpeg format "rawvideo" that actually is bitmap stream that can be processed by C# program, something like that:


var videoConv = new FFMpegConverter();
var ffMpegTask = videoConv.ConvertLiveMedia(
    "input.mp4",
    null, // autodetect live stream format
    rawBmpOutputStream,  // this is your special stream that will capture bitmaps
    "rawvideo",
    new ConvertSettings() {
        VideoFrameSize = "320x200",  // lets resize to exact frame size
        CustomOutputArgs = " -pix_fmt bgr24 ", // windows bitmap pixel format
        VideoFrameRate = 5, // lets consume 5 frames per second
        MaxDuration = 5 // lets consume live stream for first 5 seconds
    });

VideoConverter can read live streams from another .NET Stream (if input format can be used with live stream conversion).