Stream USB Capture Device

*nix specific usage questions
Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Stream USB Capture Device

Postby Dinosaur1946 » 03 Jul 2022 00:53

Hi All

Newbie here.
Post by SkyBlueGecko » 15 Feb 2021 09:35
For anyone coming across this in the future: Streaming the screen capture device to HTTP does not work in VLC and there is no solution other than using an alternative product.
VLC can still be used to record the screen by streaming to a file.
Is this still the case ??

I am currently using vlc to display hdmi capture device together with X11VNC to stream camera's onto a local network.
However, besides being long winded to set up, it occasionally drops out (haven't investigated why yet), then
have to go through the setup again.

Was hoping to combine the two by only using VLC.

Regards

Rémi Denis-Courmont
Developer
Developer
Posts: 15231
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Stream USB Capture Device

Postby Rémi Denis-Courmont » 03 Jul 2022 08:05

VLC has supported streaming USB camera for about 2 decades.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 03 Jul 2022 11:41

Hi All

Many thanks for the response, but perhaps I should give more detail.
My reason for quoting that post, was to show I DID search the site before asking a question.

We are using 16 port DVR's each with an HDMI output which has a HDMI splitter attached.
One leg direct to a Monitor and the other to a Video capture device on a PC.

This is repeated 3 times in 3 different locations with PC's running Debian on a LAN.(each with 2 x HDMI Monitors attached)
So, now each location has 3 Monitors.

Using VLC on each of these PC's we can play the captured screen from the DVR.
Currently I am using X11VNC Server and selecting the Window to broadcast onto the LAN.
Once I have selected the VLC window to use, I can minimize that window thereby freeing up that display
to show another location.(because I already have that screen on a direct connection)

End result is that I have 3 Monitors in 3 separate locations (9 in all) and we can see every DVR
in all 3 locations.

My question is , can I use VLC to broadcast the captured Video device onto the local LAN?
In other words what X11VNC server does for me at the moment.(But without the problems)

Regards

EDIT: PS: No Audio used or required.

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 03 Jul 2022 16:00

So this is about HDMI input streaming, not screen capture?

Or are you doing the crazy thing of viewing the 3 video feeds on the local PC and then trying to stream the desktop capture from that PC?

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 03 Jul 2022 22:33

Hi All
Spent an hour trying to explain, but obviously not successful.
Will try to find a place to host a pdf "a picture is worth a thousand words"

In a nutshell: at the moment I am using VLC to display a picture and then X11VNC to broadcast it to 2 other pc's.
I want to use VLC for both, as described above.

Regards

EDIT:
https://drive.google.com/file/d/1NNS_3f ... sp=sharing

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 03:34

at the moment I am using VLC to display a picture and then X11VNC to broadcast it to 2 other pc's.
Yeah, and this is unnecessarily complicated. Just broadcast directly from VLC.

Is there a specific problem you're encountering, or do you just want a general guide to set up VLC for streaming?

Based on your first post, are you thinking of using VLC to capture from the desktop which is displaying the camera feeds? Don't do that. Use VLC to capture the camera feed (from the USB device) and broadcast that directly.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 04 Jul 2022 04:40

Hi All
I guess looking for some guidance.
When I convert it, I have to make sure I got it right off site first.

Imagine:
PC1 captures and broadcasts with vlc. but only has to broadcast.
PC2 captures and broadcasts with vlc, but also is a client to PC1 & PC3.
PC3 captures and broadcasts with vlc, but also is a client to PC1 & PC2.

I haven't got my head around port numbers, as obviously I cant use the same port number on all ??
Numbering the PC's I used the following for vncviewer:
vncviewer 192.168.0.201:5901 for viewing PC1
vncviewer 192.168.0.202:5902 for viewing PC2
vncviewer 192.168.0.203:5903 for viewing PC3

If I simply run 3 copies of vlc with the first streaming and then the other two "Open Network Stream" with those IP's will that work ?

Your help much appreciate.

Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 06:08

If I simply run 3 copies of vlc with the first streaming and then the other two "Open Network Stream" with those IP's will that work ?
Yes, this sounds correct. On each PC, one VLC instance is capturing from USB and broadcasting. Additional VLC instances are playing the network streams which originate from the other PCs.

You don't, strictly speaking, need different ports. It's the combination of IP and port number that should be unique. Since each stream is originating from a different IP, the ports can be the same. However, it doesn't hurt anything to make them different and may make things easier to think about. Your choice.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 04 Jul 2022 10:55

Hi All

Many thanks for your help Mercury048, I will give it a try on site.

Regards

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 04 Jul 2022 11:35

Hi All

Struggling to understand what is happening.
I can ping two PC's from each other and then start a stream from 1.
Then when I get to "Open Network Stream" on PC2 I get this in the log.

main: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
main: playlist is empty
mjpeg error: cannot peek
-- logger module stopped --

This is just between 2 PC's at home.
EDIT: Firewall is Home profile with IN/Out allowed
and with Display Locally ticked, PC1 appears to stream using http
when selecting an mp4 video to stream.

Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 16:46

We need a lot more details. What commands are you using? How are you setting up the stream?

Although it sounds a little weird, try playing the network stream on the same PC as you're streaming from. I.e. set up the originating stream on PC1, then still on PC1 open a new VLC instance and try to play that network stream. This should work and will tell you the stream is set up properly.

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 18:28

I just tried something like this myself and HTTP just doesn't work for me. I have no idea why. I've always used RTP on my own LAN and it always seemed to work fine, so I never bothered with HTTP. Looks like that was the right call because I have no clue why this doesn't work:

Code: Select all

vlc -vvv '/home/mercury/Videos/TestVid.mkv' --sout '#duplicate{dst=rtp{dst=192.168.0.10,port=5004,mux=ts,sap,name=TestStream},dst=http{mux=ffmpeg{mux=flv},dst=:8080/TestStream}}'
This is (supposedly) streaming on both RTP and HTTP, but only the RTP steam is accessible.
Open Network Stream > "rtp://192.168.0.10:5004/TestStream" gives me the video as expected
Open Network Stream > "http://192.168.0.10:8080/TestStream" just gives an error

Someone else can chime in on what the problem here is. My recommendation is don't use HTTP.

Here's my debug log output trying to play the HTTP stream.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 04 Jul 2022 22:26

Hi All

Thanks for trying that Mercury048.
Have a look at the first half of this video ?
Are we talking about an earlier version of VLC here ?

https://www.youtube.com/watch?v=xW_vQW1fK4g

PS:I am in Australia, so our times may not align.
Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 22:41

No, we're talking current version. I just can't get HTTP streaming to work, so I'm suggesting RTP instead.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 04 Jul 2022 23:02

Hi All
I have tried RTP as well.
The video format I am using to test is mp4.
The format is RTP/MPEG Transport Stream
Have tried with empty target address and with rtp://192.168.0.9 (2nd PC)
Video H-264
:sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=display} :no-sout-all :sout-keep
Is the string generated.
Local screen shows first frame only, but progress bar moves along.
Still get empty stream error on send PC.

Running out of time this morning and will try a test on site.

Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 04 Jul 2022 23:13

That string doesn't actually send the video anywhere other than the local display.
Did you click the "add" button when selecting the destination?
For the basic test, select RTP/Basic Transport stream, click "Add", then fill in your local IP address and pick a name for the stream.

You should read this: https://docs.videolan.me/vlc-user/3.0/e ... r_rtp.html

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 06 Jul 2022 12:06

Hi All

Concluded the following after extensive testing.

1: Using VLC with Video capture device on PC1.
Then using x11vnc as a server for that captured screen on PC1.
Using vncviewer on PC2.
This is the only reliable way to make this work.(had a problem with one capture device dropping out, replacing it solved the problem)

2: Using any other vnc server like mplayer.
Works great capturing and displaying PC1 screen on PC2.(not video capture device)
Works great in displaying video capture device on PC1
Can't get it to work using video capture device on PC1 with any viewer on PC2.
I think it has to do with the tv: format.

3: Using vlc with video capture device on PC1 and PC2.
On PC1. /Media/Stream/Capture Device/Stream/Next/Display Locally/File take your pick here/Next/192.168.0.9 port = 5004/Next/H.265/Next/Stream
Cannot get the "Open Network Stream" URL to open the stream on PC2, regardless of what I do.
Cannot open the stream on vncviewer either.

So, the simple conclusion is:
Running a stream (of a video capture device) on VLC (regardless of the format) won't allow VLC on PC2 to display it.
Unless someone can tell me what I am doing wrong.

Another thing wrong is that after the first run of VLC in Debian, it closes the X system and you have to restart it.

Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 06 Jul 2022 15:41

I hope you don't give up.

First, guiding through the UI can get cumbersome and easy to miss steps while trying to reproduce. Consider using the command-line for consistency?

Assume the two PCs have IPs of 192.168.0.1 and 192.168.0.2
On PC1, choose Media > Stream > select your capture device > Stream > Next
Do not "Display locally"
Choose RTP/MPEG Transport stream, then Add
Choose 192.168.0.1 for the Address (This means PC1 will be streaming to itself!) and name the stream
Next, select the "dumbest" profile, that can't fail (MPEG-2 + MPGA), Next.
Your output string should look like:
:sout=#transcode{vcodec=mp2v,vb=800,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:rtp{dst=192.168.0.1,port=5004,mux=ts,sap,name=TestStream} :no-sout-all :sout-keep
Start the Stream
You will see no video (since Display Locally is off)
Still on PC1, launch a new instance of VLC
Open Network Stream > rtp://192.168.0.1:5004/TestStream

If this works, then streaming works and any remaining issues are to do with transcoding to a different format, or network/firewall issues, which can be solved one at a time. Notice we did not involve PC2 at all in this experiment. It is just a test to see if the capture device output can be sent over a stream, even if it's just right back to the originating PC.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 06 Jul 2022 23:17

Hi All

Mercury048, thanks for your perseverance, similarly I rarely give up if I know it is "supposed" to work.

The test you detailed worked, however when I then tried the second PC it failed.
Cannot resolve 192.168.0.9/Test Port 5004 Name or service unknown
I notice that the error message did not include rsp://.
I will have to get another usb capture device so I can do more testing at home.

Will keep you posted.

Regards

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 07 Jul 2022 01:43

When streaming RTP, the IP address you enter is the destination, so you have to adjust it when you involve the second PC. (Note that if you're going to stream to multiple machines as you intend, you'll either need to duplicate the stream for each one, or stream to a broadcast IP. Anyway, that can be done later. Better to add only one level of complexity at a time.).

So, the originating machine you input the IP of the receiver when setting up the stream.
On the receiving machine you Open Network Stream with the IP of the receiver (i.e. the receiver is using its own address to receive the stream. This is a bit counterintuitive but it's how RTP works. RTP is a "push to" a receiver rather than "pull from" the orignator.)
This is the first instance where some kind of firewall issue might interfere, so if you get nothing here, disable firewalls on both machines and try again.
I had to use the following command to configure the firewall on the receiving machine for this to work:

Code: Select all

sudo ufw allow in to any port 5004 from [originating IP] proto udp
I.e. allow incoming connection (on any interface) on port 5004 from the stream originator.


Also, I don't know if you made a typo, but it's "rtp" not "rsp". (There's also rtsp but I haven't personally tested how well that works.)

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 07 Jul 2022 05:34

Hi All
According to your instruction, both PC's now have the same IP address.
I have pinged both OK.

The originating PC1 now has 192.168.0.2
Which now displays the capture locally.

The Target PC2:
/Media/Open Network Stream/ rtp://192.168.0.2/Test then play.
This results in: VLC is unable to open the MRL 'rtp://192.168.0.2/Test

Regards
EDIT: Same result on a second Laptop (Both Linux Mint)
Same result using broadcast rtp://192.168.0.255/Test (if that is correct format)

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 07 Jul 2022 06:51

According to your instruction, both PC's now have the same IP address.
What do you mean by this? Do not change the IP address of the machine itself. We are talking about VLC settings only.
Same result using broadcast rtp://192.168.0.255/Test (if that is correct format)
Possibly. You can run "ip address" and check the currently configured broadcast address there.
If you wish to try broadcast, then use that IP address for the stream origin (on PC1) and for opening the stream (on PC2).

Please post the vlc output string for what you're trying. It helps a lot with troubleshooting.

I'm adjusting my earlier instructions. For direct stream to PC2:
Assume the two PCs have IPs of 192.168.0.1 and 192.168.0.2
On PC1, choose Media > Stream > select your capture device > Stream > Next
Do not "Display locally"
Choose RTP/MPEG Transport stream, then Add
Choose 192.168.0.2 for the Address (This means PC1 will be streaming to PC2) and name the stream
Next, select the "dumbest" profile, that can't fail (MPEG-2 + MPGA), Next.
Your output string should look like:
:sout=#transcode{vcodec=mp2v,vb=800,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:rtp{dst=192.168.0.2,port=5004,mux=ts,sap,name=TestStream} :no-sout-all :sout-keep
Start the Stream
You will see no video (since Display Locally is off)
On PC2, launch a new instance of VLC
Open Network Stream > rtp://192.168.0.2:5004/TestStream
For broadcast:
Assume the two PCs have IPs of 192.168.0.1 and 192.168.0.2
On PC1, choose Media > Stream > select your capture device > Stream > Next
Do not "Display locally"
Choose RTP/MPEG Transport stream, then Add
Choose 192.168.0.255 for the Address (This means PC1 will be broadcasting to the local subnet) and name the stream
Next, select the "dumbest" profile, that can't fail (MPEG-2 + MPGA), Next.
Your output string should look like:
:sout=#transcode{vcodec=mp2v,vb=800,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:rtp{dst=192.168.0.255,port=5004,mux=ts,sap,name=TestStream} :no-sout-all :sout-keep
Start the Stream
You will see no video (since Display Locally is off)
On PC2, launch a new instance of VLC
Open Network Stream > rtp://192.168.0.255:5004/TestStream
In all cases you must have firewall rules in place that allow the receiving PC to open the stream.

I have tested and it works on my own network.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device

Postby Dinosaur1946 » 07 Jul 2022 07:36

Hi All
SUCCESS
What do you mean by this? Do not change the IP address of the machine itself. We are talking about VLC settings only.
No, I meant setting both to 192.168.0.2 in VLC only.

Even though I don't tick "Display Locally" sometimes it still does. I assumed that when it did , it had succeeded
So then I tried to read the stream on PC2.
I never tried to read the stream whilst nothing was showing.
I would simply do "Open Capture Device" on PC1 to confirm the device is working, Stop the capture, then do the same Stream commands again and the stream would show on PC1, even though "Display Locally" was not ticked.
I have proven this by repeating again with "Open Capture Device".
I have to quit VLC and restart it to get it to work again.

This time I also tried with both pc's on Ethernet.
Connected an additional Laptop (Wifi only )
Now I can see the Video on PC2, PC3 and screen is blank on PC1.
:sout=#transcode{vcodec=mp2v,vb=800,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:rtp{dst=192.168.0.255,port=5004,mux=ts,sap,name=Test} :no-sout-all :sout-keep
So, almighty teacher, where do we go from here ?

Regards
EDIT: Video-Mpeg2+ MPGA(TS) appears to be the only one that will work.
Just stopping the Stream when you find out it doesn't work is not enough, I have to quit VLC , restart and specify the only format that works.
On site we have Cat5 between the 3 locations for which I am great-full as even at home on Wifi there are a few screen glitches.

So, a question.
With 3 streams happening on the LAN, is it enough to simply increment the port ie: Stream 1 = 5004, Stream 2 = 5005, Stream 3 = 5006 ?

Mercury048
Blank Cone
Blank Cone
Posts: 85
Joined: 20 Jan 2008 02:15

Re: Stream USB Capture Device

Postby Mercury048 » 07 Jul 2022 16:41

SUCCESS
Nice.
I have to quit VLC and restart it to get it to work again.
I can't explain that. It may be a bug, or VLC is doing something odd with its playlist. It's a different topic.
So, almighty teacher, where do we go from here ?
You chose to broadcast the stream, and it seems to work!
Finally you also want to also view the stream on the originating PC. Now, my recommendation is simply to open another VLC instance on the same PC and read the stream. Since you're broadcasting anyway, you don't need to change the configuration. Any PC on the network should be able to read it.

You can try using "Display Locally" instead. But my opinion is that a VLC instance should serve as a "server" running in the background or "client" to be viewed, and not be both. You will find people who disagree with me.
EDIT: Video-Mpeg2+ MPGA(TS) appears to be the only one that will work.
That implies a transcoding issue.
How about "H.264 + MP3 (TS)"? This seems to work fine for me. I am using Linux as well.
Something interesting to try: Don't transcode at all. (i.e. uncheck "Activate Transcoding" ) This may not work because the raw device may not be outputting stream-able data, but I think it's worth a shot. You'll see the output string:
:sout=#rtp{dst=192.168.0.255,port=5004,mux=ts,sap,name=Test} :no-sout-all :sout-keep
With 3 streams happening on the LAN, is it enough to simply increment the port ie: Stream 1 = 5004, Stream 2 = 5005, Stream 3 = 5006 ?
Yes, it should, but out of an abundance of caution, I recommend incrementing by a larger amount, say by tens: 5004, 5014, 5024.

Dinosaur1946
Blank Cone
Blank Cone
Posts: 26
Joined: 02 Jul 2022 23:00
VLC version: 3.0.8
Operating System: Linux

Re: Stream USB Capture Device [SOLVED]

Postby Dinosaur1946 » 07 Jul 2022 21:17

Hi All

Mercury048 , you have done well , many thanks for your time & effort. :D

YFYI, the installation is on a very large Museum & Historical village which is run totally by volunteers, usually retired people
like myself.

The solution you have helped me find is easy for me to setup, however whenever there is a power failure, it has to be done again,
possibly by certain other volunteers. I write step by step instructions, but simplification is always a guarantee that more volunteers can do it.

With that in mind I have been browsing for starting vlc either from CLI or some sort of recorded script.

Any suggestions you have for this much appreciated.
Once again many thanks.

Regards


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 18 guests