Closed kskalski closed 3 years ago
Yeah, I'd tend to agree with this. Question is more of how the buffer limit would be configured by the user, either via number of frames or by actual memory size.
number of frames seems to be easier to implement and actually might be also easier to reason about by the user
I'm processing large file, but only reading audio frames out of it with
media_file_.Audio.TryGetNextFrame(out FFMediaToolkit.Audio.AudioData frame)
. The process keeps growing the memory usage and finally fails withEncountered error when processing audio: Cannot read next packet from the file Error code: -12 : Cannot allocate memory
Seems like this is because by default we read both video and audio and when user skips the video frames by just using
Audio.TryGetNextFrame
, then the video frames gets accumulated in internal buffer.Switching
MediaFile.Open(filename)
toMediaFile.Open(filename, new MediaOptions() { StreamsToLoad = MediaMode.Audio })
fixes the memory usage. It's not completely clear how the library should handle such unread / undisposed frames, but I guess a reasonable thing to do would be to limit the video frames buffer.