Comments (17)
I will try to create a proper stop even if flyleaf does not use it currently. In the meantime, have a look at MediaRouter.cs to free the queue frames (ClearVideoFrames). also in case of sws maybe you should also clean some buffers there in MediaDecoder.cs (outBufferPtr something). - Or just try to initialize both MediaRouter.cs and MediaDecoder/DecoderContexts -
from flyleaf.
I'm closing this, let me know if the new code done the job for you. In any case I'll not stop at the end for now, I will let the user choose whether to close it or re-seek / play
from flyleaf.
Any progress on this ?
from flyleaf.
@synologic That's an old thread. What is your issue? If you want to release the memory at the end of a video you need to call Player.Stop()
from flyleaf.
It is an old one yes :)
I am calling Player.Stop() however the memory is not freed and last frame remains on the player surface.
I'm using 3.4.7 from Nuget
from flyleaf.
Just tested again and it works fine (Sample on WinForms - Form1.cs)
using FlyleafLib;
using FlyleafLib.MediaPlayer;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
Player Player { get; set; }
public Form1()
{
Engine.Start(new EngineConfig()
{
FFmpegPath = @"c:\root\projects\Flyleaf\FFmpeg"
});
InitializeComponent();
Player = new Player();
Player.Control = flyleaf1;
Player.Open(@"C:\root\dev\flyleaf\videosamples\0.mp4");
Player.PlaybackCompleted += (o, e) =>
{
Player.Stop();
};
}
}
}
from flyleaf.
Maybe i should have mentioned, if it makes any difference. I'm playing a live RTSP stream, not a file and not waiting for completion.
I just call .Stop() in order to stop video or load another live stream.
Not sure if that changes anything :)
from flyleaf.
Yes, that makes a lot of difference :)
There is already an investigation from one of my users that has issues (memory leaks - not video memory). It could be an ffmpeg bug (with udp protocol). However, I was not able to reproduce it yet. I just tried this one https://www.wowza.com/developer/rtsp-stream-test. Does this leak for you?
from flyleaf.
I just upgraded to 3.4.9 and the memory gets freed once GC runs after .Stop() so that's that :)
The last frame still stays on the screen, for both Wowza's and my stream.
from flyleaf.
There is no difference between 3.4.7 and 3.4.9. Additionally, on my side I don't need to call GC to clear the memory.
Player.Stop clears the frame (leaves a black frame) and the memory, not sure what are you doing.
from flyleaf.
Not doing anything fancy:
public Form1()
{
InitializeComponent();
Engine.Start(new EngineConfig()
{
FFmpegPath = ":",
UIRefresh = true,
UIRefreshInterval = 250
});
// Prepares Player's Configuration
Config = new Config();
Config.Player.KeyBindings.Enabled = false;
Player = new Player(Config);
Player.Control = flyleaf1;
Player.Tag = "player1";
Player.PropertyChanged += playerPropertyChanged;
}
Then i just call OpenAsync("RTSP_STREAM") and when i'm done i just call .Stop().
The only other difference, between the wowza and my stream, is that i'm using H265
What i meant about the GC is that, once i call Stop() i see the memory being freed after a few seconds, so i assumed is the GC that frees it :)
from flyleaf.
Is it possible that you call Player.Stop before it actually Player.OpenAsync completes?
Do you see any difference between wowza and your stream and you mention the different codec?
I don't force GC on Player.Stop it's true. I do this only on Dispose. But I guess it is not required there.
from flyleaf.
You can try the same code that I use to see if we have any difference:
Opens/Plays/Stops check if you see the black frame in between
using FlyleafLib;
using FlyleafLib.MediaPlayer;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
Player Player { get; set; }
public Form1()
{
Engine.Start(new EngineConfig()
{
FFmpegPath = @"c:\root\projects\Flyleaf\FFmpeg"
});
Player = new Player();
InitializeComponent();
Player.Control = flyleaf1;
Task.Run(() =>
{
while (true)
{
Player.Open(@"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4");
Thread.Sleep(5000);
Player.Stop();
Thread.Sleep(5000);
}
});
}
}
}
from flyleaf.
I'm sorry, but still the same thing.
I even upgraded to VS 2022 and migrated the solution to .NET 6, however it's the same thing, the last frame stays on screen after .Stop() is called
from flyleaf.
Well reviewing the code it could be possible, however not sure why it happens to you every time and it never happens to me. I will fix it with the next update ;)
from flyleaf.
Not sure, may be Windows 11 related issue, i can live with it, or maybe there's a way i can directly paint something on the surface after stop ? :)
from flyleaf.
Possible, with Player.Control you could mess with the background refresh/paint etc. But, I think I found the problem and it will be fixed with the next update. I'm disposing the lastframe after I refresh the renderer and it just happens to be null most of the times (for me).
from flyleaf.
Related Issues (20)
- To get thumbnail of the video on seek bar HOT 1
- How to send commands directly to FFMPEG engine while video is loaded and playing HOT 3
- about key redefine~ HOT 2
- Audio render should be on different thread HOT 4
- Open/OpenAsync with ClearScreenOnOpen still shows black frame HOT 3
- I would like to print a specific part of the image by blurring it, is this possible? HOT 1
- About ShowFramePrev HOT 2
- Overlaps and Refresh in SharedOverlay
- Stream synchronization issue HOT 7
- Possible handle leak when repeatedly create/play/stop/dispose flyleaf players HOT 13
- Open stream at current position HOT 6
- FlyleafSharedOverlay in wpf ViewBox HOT 3
- Renderer: Level/Gamma Support HOT 4
- crash by set curtime HOT 2
- SharedOverlay as the Visual of a VisualBrush
- Get FlyleafSharedOverlay DetachedContent as Visual HOT 9
- Decoder (Subtitles): Bitmap Support HOT 1
- Issues of brightness control HOT 1
- [New feature requests]Added multi-threading support for M3U8 HOT 3
- Demuxer: Blu-Ray Support HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flyleaf.