Giter Site home page Giter Site logo

Comments (12)

davsun55 avatar davsun55 commented on May 29, 2024 1

A couple of tweaks but this is now working perfectly. Thanks for the hints.

        private void LoadVideo()
        {
            // Open the stream and immediately get a snapshot at the 3sec mark
            flPlayer.SeekCompleted += FLPlayer_SeekCompleted;
            flPlayer.OpenCompleted += (o, e) =>
            {
                if (!e.Success) return;
                flPlayer.SeekAccurate(3000);
            };
            flPlayer.OpenAsync(SampleVideo);
        }
        private void FLPlayer_SeekCompleted(object sender, int e)
        {
            flPlayer.SeekCompleted -= FLPlayer_SeekCompleted;
            if (e == -1) return;
            pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
            flPlayer.Seek(0);
        }

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

Hi @davsun55 and thanks!

I know that the documentation requires more work that's why I tried to include more samples/tests and also check XML documentation/comments.

  1. Not sure what you want to do here (you can SeekAccurate to 2sec and then use TakeSnapshotToFile/TakeSnapshotToBitmap) or use PropertyChanged for CurTime and check when the current time is 2sec?

  2. Stop should work like that (closing the input and clears the frame). What you need is to Pause and Seek(0).

  3. Seek will seek at a keyframe (this means that it will not be accurate, depends from the video's GOP size) but it will be faster while SeekAccurate will be accurate but slower (as it needs to decode all the GOP frames until the actual timestamp). SeekBackward(2/3) and SeekForward(2/3) will use Seek or SeekAccurate based on Config.Player.SeekAccurate and the time offsets based on Config.Player.SeekOffset(2/3)

  4. Don't use this, always use the Player Set/Seek time and then use this without a frame (to get the current one)

Feel free to ask for more details

John

from flyleaf.

davsun55 avatar davsun55 commented on May 29, 2024

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

@davsun55 You just found some issues here I guess. The problem is the Sync/Async combination. You can't use OpenAsync and then Seek directly as it will not be opened yet. You can either use OpenCompleted event or synced Open. The problem after that is that you Seek is not synced and I don't provide Synched version of it or an event. It will work if you for example put a Thread.Sleep in between just to prove it works. However, I will need to provide a better way for that (it can be done with ShowFrame but just found an issue with it when used directly after open).

Buy me a beer when you come in Greece/Crete :)

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

@davsun55 With this commit now you can use this:-

Player.OpenAsync(@"c:\sample.avi");
Player.OpenCompleted += (o, e) =>
{
    if (!e.Success)
        return;
    
    Player.ShowFrame(Player.VideoDecoder.GetFrameNumber(TimeSpan.FromSeconds(2).Ticks));
    Player.TakeSnapshotToFile(@"c:\sample.jpg");
};

I will review also Seek/SeekAccurate if can use a synced version or an event

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

@davsun55 I've added SeekCompleted so now you can better use the following:-

Player.Config.Player.AutoPlay = false;

Player.OpenCompleted += (o, e) =>
{
    if (!e.Success)
        return;
    
    Player.Seek(20_000);
};

Player.SeekCompleted += (o, e) =>
{
    if (e == -1)
        return;

    Player.TakeSnapshotToFile(@"c:\sample.jpg");
};

Player.OpenAsync(@"c:\sample.avi");

from flyleaf.

davsun55 avatar davsun55 commented on May 29, 2024

Since I'm taking the snapshot to immediately show a thumbnail of the video before they press play, the .OpenCompleted doesn't work quickly enough. However this works:
flPlayer.Open(SampleVideo);
Thread.Sleep(500);
pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
flPlayer.Stop();
But it would be good to have a solution that doesn't require the somewhat arbitrary thread.sleep.
We were in Greece in 2014 and loved it - especially the Moussaka on Rhodes! And we decided that Greeks make the best Turkish Delight.
:)

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

@davsun55 This should work if you set the Player.Config.Player.AutoPlay = false;

from flyleaf.

davsun55 avatar davsun55 commented on May 29, 2024

I can wait till your next NuGet release so you don't need to answer this, but how do I incorporate your Player.SeekCompleted changes right now? I've downloaded the current package with your changes, rebuilt it as 'release' and copied the resultant FlyleafLib.dll and FlyleafLib.xml over the top of the v3.7.42 package files. But Player.SeekCompleted is not present...

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

The easiest way would be just adding the FlyleafLib project to your solution and reference it instead of using the NuGet package. Alternative you can release (pack) a new version custom and add a local repository folder in your VS. I would have a version for your but I want to review it before release it (I think i will do few changes).

from flyleaf.

davsun55 avatar davsun55 commented on May 29, 2024

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on May 29, 2024

If understood correctly:-

flPlayer.Config.Player.AutoPlay = false;
flPlayer.OpenCompleted += (o, e) =>
{
    if (!e.Success) return;
    flPlayer.SeekCompleted -= FlPlayer_SeekCompleted;
    flPlayer.SeekCompleted += FlPlayer_SeekCompleted;
    flPlayer.SeekAccurate(2000);
};

flPlayer.OpenAsync(SampleVideo);
...
private void FlPlayer_SeekCompleted(object sender, int e)
{
   flPlayer.SeekCompleted -= FlPlayer_SeekCompleted;
   if (e == -1) return;
   pbSnapshot.Image = flVideo.Player.TakeSnapshotToBitmap();
}

You could also check the e (int e) which is the ms that is 2000 (and not 0)

from flyleaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.