-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High memory usage when using bitmap subtitles #502
Comments
So does VLC/mpv plays bitmap properly without specifying probesize/max_analyze_duration? I didn't do any further testing but if you think is memory leak, it should be opened on FFmpeg's trac. If you think is this can be resolve in Flyleaf with another way I'm opened to fix it. (Possible add a config for whether to increase those values in this case or not) |
Thanks for your reply. I would like to investigate as well, Does the problem only reproduce itself with certain decoders or container videos? It may be acceptable to increase the setting value only for problematic formats. |
Didn't test it but it is possible to be affected by HEVC. |
Just putting a seek after $ git diff
diff --git a/FlyleafLib/MediaFramework/MediaDemuxer/Demuxer.cs b/FlyleafLib/MediaFramework/MediaDemuxer/Demuxer.cs
index c414f98..8e5732b 100644
--- a/FlyleafLib/MediaFramework/MediaDemuxer/Demuxer.cs
+++ b/FlyleafLib/MediaFramework/MediaDemuxer/Demuxer.cs
@@ -515,6 +515,11 @@ public unsafe class Demuxer : RunThreadBase
ret = avformat_find_stream_info(fmtCtx, null);
if (ret == AVERROR_EXIT || Status != Status.Opening || Interrupter.ForceInterrupt == 1) return error = "Cancelled";
if (ret < 0) return error = $"[avformat_find_stream_info] {FFmpegEngine.ErrorCodeToMsg(ret)} ({ret})";
+
+ if (requiresMoreAnalyse)
+ {
+ avformat_seek_file(fmtCtx, -1, 0, 0, 0, 0);
+ } |
Seeking can cause issues so it should be avoided. Possible flushing the format/pb should work as well and it would be better. Maybe another ffmpeg option can avoid this memory usage too. I will try to look in to it in the future... |
This commit supports bitmap subtitles, but I have observed that the memory usage is temporarily large after enabling bitmap subs. It may possibly be a memory leak.
9a47e74
The following settings seem to temporarily increase memory usage. It appears to be released after a long distance seek.
Flyleaf/FlyleafLib/MediaFramework/MediaDemuxer/Demuxer.cs
Lines 511 to 512 in 9a47e74
test video file
Below are the results of the memory profiler in JetBrains Rider.
Starting playback of a video with bitmap subtitles enabled consumes a large amount of unmanaged memory usage. (
2. 750 MB
)If playback is continued without seeking, memory usage does not decrease.
If you use the seek bar and seek large, memory usage is reduced significantly. (
3. 350MB
)The following result shows the case where
probesize
andmax_analyze_duration
were not set.No particular leakage occurred in this case. Seeking does not result in any particular change.
I checked the mpv and VLC sources and it seems that neither of them specifically set
probesize
andmax_analyze_duration
.I would like to know in what situations these are necessary.
The text was updated successfully, but these errors were encountered: