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

FfmpegException: Cannot decode a video frame with dimensions different than the previous one. #105

Closed ggolda closed 2 years ago

ggolda commented 2 years ago

I'm facing a strange exception with some video files:

FFMediaToolkit.FFmpegException: Cannot decode a video frame with dimensions different than the previous one.
 at FFMediaToolkit.Common.Internal.ImageConverter.AVFrameToBitmap(VideoFrame videoFrame, Byte* destination, Int32 stride)
   at FFMediaToolkit.Common.Internal.VideoFrame.ToBitmap(ImageConverter converter, ImagePixelFormat targetFormat, Size targetSize)
   at FFMediaToolkit.Decoding.VideoStream.GetFrame(TimeSpan time)
   at FFMediaToolkit.Decoding.VideoStream.TryGetFrame(TimeSpan time, ImageData& bitmap)

Can reproduce it 100% of times with a one webm file with such parameters (from ffprobe):

Input #0, matroska,webm, from '23c34405-f0f4-4495-92bb-6ce2eb667a01.webm':
  Metadata:
    encoder         : Chrome
  Duration: 00:00:26.19, start: 0.000000, bitrate: 1381 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(tv, bt709, progressive), 1364x766, SAR 1:1 DAR 682:383, 120 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1

Other webm files work without any issues and without any exceptions. If necessary, can provide this video file.

Thanks!

hey-red commented 2 years ago

@ggolda Can you post sample file? I think it's can handled by rescale the frame according previously decoded, but it seems like currently is not implemented

ggolda commented 2 years ago

@hey-red Here is a file example (sharing using WeTransfer, github doesn't allow to upload webm): https://we.tl/t-mees6IrgsV

Sorry for a late reply.