Vlc.DotNet
Vlc.DotNet copied to clipboard
How to stream image ?
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,
":fake-file D:\\img.png",
player.SetMedia("fake:", mediaOptions);
This looks weird.
Please share full logs.
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.
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.
Try to replace
":fake-file D:\\img.png",
with
":fake-file", "D:\\img.png",
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);
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.
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();
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)
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.
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();