Displaying the frame at a given time
Posted: 07 Oct 2020 07:26
Hello,
I'm using libLVCSharp.WinForms and trying to display the frame corresponding to a time in the video.
Basically, if I have a time in ms, how do I display the corresponding frame in my VideoView control?
From what I understand, the video must be playing or paused, so I'm doing the following:
mediaPlayer.Play();
[Edit] <- I realized that at this point I basically need to wait until the video is actually playing
mediaPlayer.SetPause(true);
mediaPlayer.Time = 500;
Sometimes it works, sometimes it does not, and I have the feeling that I'm missing a step or precondition?
[Edit] I still have a couple of issues:
1) if I do the above, I can see the beginning of the video for a fraction of second in the VideoView control before it switches to the right frame. How can I avoid this?
2) if I pass the media.Duration for the time in order to display the last frame, it will not work (same thing if I set mediaPlayer.Position to 1.0f instead)
I assume that it is because it is actually after the time at which the last frame is starting to be displayed? How do I get that time? Will calculating that time from the duration and the fps rate be accurate enough?
Any help/ pointers would be greatly appreciated.
I'm using libLVCSharp.WinForms and trying to display the frame corresponding to a time in the video.
Basically, if I have a time in ms, how do I display the corresponding frame in my VideoView control?
From what I understand, the video must be playing or paused, so I'm doing the following:
mediaPlayer.Play();
[Edit] <- I realized that at this point I basically need to wait until the video is actually playing
mediaPlayer.SetPause(true);
mediaPlayer.Time = 500;
Sometimes it works, sometimes it does not, and I have the feeling that I'm missing a step or precondition?
[Edit] I still have a couple of issues:
1) if I do the above, I can see the beginning of the video for a fraction of second in the VideoView control before it switches to the right frame. How can I avoid this?
2) if I pass the media.Duration for the time in order to display the last frame, it will not work (same thing if I set mediaPlayer.Position to 1.0f instead)
I assume that it is because it is actually after the time at which the last frame is starting to be displayed? How do I get that time? Will calculating that time from the duration and the fps rate be accurate enough?
Any help/ pointers would be greatly appreciated.