Code Monkey home page Code Monkey logo

Comments (6)

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

Hopefully, I will find sometime to write a documentation soon. Until then, I have some samples to help you out with the basic implementations. For the downloader, I have this one https://github.com/SuRGeoNix/Flyleaf/blob/master/Wpf%20Samples/Sample4_Downloader.xaml.cs

Did you have a look and you still need some help?

from flyleaf.

zydjohnHotmail avatar zydjohnHotmail commented on August 31, 2024

Hello:
Thank you very much for your reply.
I have some concerns: first, I don't know how to call this partical class, do you have the code sample for the caller?
second, I don't like to use WPF, which has many restrictions, can I use the class in either C# console project or C# WindForm project?
finally, I see your code:
public DemuxerBase Downloader { get; set; } = new VideoDemuxer(new Config(), 777);
I want to know what the number 777 means.
In my case, I have to download multiple M3U8 live streaming URLs at the same time. For example, I have 2 Olympic games are on going at the same time.
Can I use one client with Config() ID# 777, and another client with Config() ID# 888?
In short, I want to initalize the class instance from the caller with different Config() ID#, and different M3U8 URL.
Can this be done in C# console or WinForm project?
Finally, the download percentage can NOT decided for real live streaming URL.
I give you one of such URL, it will expire in a few hours from now.
https://video1.maxline.by:444/o1/stream04/chunks.m3u8?nimblesessionid=3025892
Can you show me the code on how to reach my target?
Thanks,

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

Hey @zydjohnHotmail

To use the solution right click on Wpf Samples project and select "Set as Startup Project". Then edit App.xaml and set the StartupUri to Sample4_Downloader.xaml. That's all.

Now, the code that you ask is already inside that project, the library code can be used from any project that you reference (winforms/wpf/consoles).

Basic steps to use the library for this purpose:

  1. Register FFmpeg libraries
Master.RegisterFFmpeg(@"c:\ffmpeg\x64");
  1. Create the Demuxer/Downloader classes (yes for each you need a unique id until I will decide what to do with it)
DemuxerBase Downloader = new VideoDemuxer(new Config(), 1);
  1. Register to event
Downloader.DownloadCompleted += Downloader_DownloadCompleted;
  1. Open input url
if (Downloader.Open(url) != 0) { MessageBox.Show("Could not open url input");  return; }
  1. Select the audio/video streams that you want to download (validate that they exist and what quality you want)
Downloader.EnableStream(Downloader.VideoStreams[0]);
if (Downloader.AudioStreams.Count != 0) Downloader.EnableStream(Downloader.AudioStreams[0]);
  1. Start the downloader
Downloader.Download(System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"testVideo{downloadCounter++}.mp4"));
  1. Catch the complete event
private void Downloader_DownloadCompleted(object sender, bool success)
{
    if (success)
    {
        if (Downloader.DownloadPercentage == 100)
            MessageBox.Show("Download Completed!");
        else
            MessageBox.Show("Partial/Live Download Completed!");
    }
    else
        MessageBox.Show("Download Failed!");
}

If you have a live stream of course there is no Downloader.DownloadPercentage. You decide when to manually stop with Downloader.Stop();

You can also use Record on demand while watching (ctrl+R for the demo version if you want to tested). The advantage is that you record the streams that you have selected from the player.

from flyleaf.

zydjohnHotmail avatar zydjohnHotmail commented on August 31, 2024

Hello:
Thank you very much for your kind help.
I tried to follow your advice, and I can download fixed size video. But for the live streaming video, I see that the program download only first 30 seconds, then it stops. I don't know how to fix this.
You can try this URL:
https://video1.maxline.by:444/o1/stream30/chunks.m3u8?nimblesessionid=3027958
But it will expire in a few hours.
Thanks,

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

You are right, I'm looking at it.

Edit: Yes it's a bug with the new version and the new timeouts...

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

It should be fixed now. Have a look and let me know if not. You might also want to check the timeouts/options/flags etc. for more advanced things.. see Demuxer's Config, FFmpeg's protocols, FFmpeg's formats

eg. you might need to use this for live streams:

config.demuxer.VideoFormatOpt.Add("reconnect_at_eof", "1");

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.