radek-k / FFMediaToolkit

FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
MIT License
352 stars 56 forks source link

Encoding not worked #37

Closed quocdai92 closed 3 years ago

quocdai92 commented 3 years ago

Hello, I'm using the sample code from wiki:

// You can set there codec, bitrate, frame rate and many other options.
var settings = new VideoEncoderSettings(width: 1920, height: 1080, framerate: 30, codec: VideoCodec.H264);
settings.CRF = 17;
var file = MediaBuilder.CreateContainer(@"C:\videos\example.mp4").WithVideo(settings).Create();
while(file.Video.FramesCount < 300)
{
    file.Video.AddFrame(/*Your code*/);
}

But the result video can't play. saw the details I think something wrong. :( image image

radek-k commented 3 years ago

You should call file.Dispose() after encoding. I forgot about that when I was writing the sample code.