Vlc.DotNet icon indicating copy to clipboard operation
Vlc.DotNet copied to clipboard

How to stream image ?

Open Yaya859 opened this issue 5 years ago • 10 comments

I have an issue / a question (pick one) about Vlc.DotNet.

Generic information

  • Vlc.DotNet version : 3.0.0
  • Vlc.DotNet project used : WinForms
  • libvlc version : 3.0.11 NuGet Package
  • .net version : 4.7.2
  • Project language : C#
  • Project build architecture : AnyCPU
  • Operating system : Windows 10 x64

Summary

I try to stream image to udp multicast :

var mediaOptions = new[]
                {
                ":fake-file D:\\img.png",
                ":sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}",
                ":std{access=udp,mux=ts,dst=239.1.1.1:1234}",
                ":pid-video=299",
                ":loop",
                ":repeat"
            };
            player.SetMedia("fake:", mediaOptions);
            player.Play();

Result error, what is the good way ?

LOG:

[06962300] stream_out_transcode stream out error: cannot create chain

[069706b0] main stream output error: stream chain failed for `transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}'

[0696c7a8] main input error: cannot start stream output instance, aborting

Thanks,

Yaya859 avatar Jun 26 '20 13:06 Yaya859

":fake-file D:\\img.png",
player.SetMedia("fake:", mediaOptions);

This looks weird.

Please share full logs.

mfkl avatar Jun 26 '20 13:06 mfkl

We can't help you until you manage to make that work in VLC itself. Once this is done, you wille probably already have the command line options to pass, and won't need our help anyway.

jeremyVignelles avatar Jun 26 '20 13:06 jeremyVignelles

In CLI it works :

start vlc fake: :fake-file D:\img.png :sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}:std{access=udp,mux=ts,dst=239.1.1.1:1234} :pid-video=299 :loop :repeat

I try to do same with Vlc.DotNet.

Yaya859 avatar Jun 26 '20 14:06 Yaya859

Try to replace ":fake-file D:\\img.png", with ":fake-file", "D:\\img.png",

jeremyVignelles avatar Jun 26 '20 14:06 jeremyVignelles

Same error :

var mediaOptions = new[]
                {
                ":fake-file",
                "D:\\img.png",
                ":sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}",
                ":std{access=udp,mux=ts,dst=239.1.1.1:1234}",
                ":pid-video=299",
                ":loop",
                ":repeat"
            };

            player.SetMedia("fake:", mediaOptions);

Yaya859 avatar Jun 26 '20 14:06 Yaya859

try with:

var mediaOptions = new[]
                {
                ":fake-file",
                "D:\\img.png",
                ":sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}:std{access=udp,mux=ts,dst=239.1.1.1:1234}",
                ":pid-video=299",
                ":loop",
                ":repeat"
            };

            player.SetMedia("fake:", mediaOptions);

:std is not a separate parameter but the configuration of the sout chain.

jeremyVignelles avatar Jun 26 '20 14:06 jeremyVignelles

Thanks, now its working while 2-3 seconds. Why the loop/repeat not working ?

FileInfo file = new FileInfo("D:\\img.png");

            var mediaOptions = new[]
                {
                ":fake-file",
                "D:\\img.png",
                ":sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}:std{access=udp,mux=ts,dst=239.1.1.1:1234}",
                ":pid-video=299",
                ":loop",
                ":repeat",
                ":input-repeat=-1"
            };

            player.SetMedia(file, mediaOptions);
            player.Play();

Yaya859 avatar Jun 26 '20 15:06 Yaya859

not sure it is supported with libvlc. does that work in vlc itself?

You could also handle the EndReached event ant loop yourself (don't forget to switch threads)

jeremyVignelles avatar Jun 26 '20 15:06 jeremyVignelles

Yes it works with VLC by CLI.

Edit : Mistake, loop not working with CLI. The stream is playing only 10 seconds, with event EndReached I force loop thanks. Why 10 seconds ? I don't found how increase to 60 seconds.

Yaya859 avatar Jun 26 '20 15:06 Yaya859

I found this : Default duration of 10s when fake isn't forced. Make it possible to use fake:///path/to/image as well

I use :fake-duration=60000 but always 10 seconds :

FileInfo file = new FileInfo("D:\\img.png");

            var mediaOptions = new[]
                {
                ":fake-file",
                ":sout=#transcode{vcodec=h264,acodec=none,vb=2000,width=1920,height=1080}:std{access=udp,mux=ts,dst=239.1.1.1:1234}",
                ":fake-duration=60000"
            };

            mediaPlayer1.SetMedia(file, mediaOptions);
            mediaPlayer1.Play();

Yaya859 avatar Jun 26 '20 16:06 Yaya859