文档章节

ubuntu远程访问摄像头的设置

蓝薯
 蓝薯
发布于 2016/08/15 15:29
字数 1026
阅读 53
收藏 0

Last updated on September 3, 2013 Authored by Dan Nanni 15 Comments

Have you ever wanted to live stream a video feed from your webcam for someone else? You could use any existing video chat software such as Skype, Google+ Hangouts. However, if you do not want to rely on any third-party streaming infrastructure, you can set up your own webcam streaming server in house.

In this tutorial, I will describe how to live stream video from webcam by using VLC.VLC is an open-source, cross platform media player which can handle virtually all video and audio formats. VLC can also run as a streaming server supporting various streaming protocol such as RTP, HTTP, RTSP, etc.

Before attempting to set up webcam streaming on your own, you need to understand the huge potential security risk of streaming a webcam over the Internet. Anyone can tap into your streaming feed unless you properly access control the streaming server, and encrypt the streaming traffic. I'll briefly mention several security protections against threats towards the end of the tutorial.

Install VLC on Linux

Before setting up a streaming server with VLC, install VLC first.

To install VLC on Debian, Ubuntu or Linux Mint:

$ sudo apt-get install vlc

 

To install VLC on Fedora, first enable RPM Fusion's free repository, and then run:

$ sudo yum install vlc

 

To install VLC on CentOS or RHEL 6, first set up EPEL repository, and then use the following commands:

$ cd /etc/yum.repos.d/
$ sudo wget http://pkgrepo.linuxtech.net/el6/release/linuxtech.repo
$ sudo yum install vlc

 

Verify Webcam Device on VLC

Next, verify whether a webcam device is successfully detected on your Linux system and VLC.

To do so, first find out the device name of your webcam with the following command. In this example, the device name of the webcam is /dev/video0.

$ ls /dev/video*
/dev/video0

Now use the following command to test video from your webcam. Replace "video0" with your own device name.

$ vlc v4l2:///dev/video0

 

If your webcam is successfully detected by VLC, you should see a video stream of yourself.

Configure Webcam Streaming on VLC

Assuming that your webcam is successfully recognized by VLC, I am going to show how to configure webcam streaming. In this setup, webcam is streamed over HTTP in WMV format.

To configure VLC for webcam streaming, first launch VLC.

$ vlc

 

Choose "Streaming" from VLC menu.

On the screen, choose webcam/audio device name (e.g., /dev/video0 for webcam, and hw:0,0 for audio). Click on the checkbox of "Show more options". Make a note of value strings in "MRL" and "Edit Options" fields. We will use these strings later in the tutorial. Click on "Stream" button at the bottom.

Verify the video source (e.g., v4l2:///dev/video), and click on "Next" button to go next.

On this screen, choose the destination (i.e., streaming method/target) of webcam streaming. Since we use HTTP streaming, choose "HTTP" from the drop down list, and click on "Add" button.

Next, specify port number and path of a streaming service. For port number, fill in 8080 (assuming that the port number is not occupied), and "/stream.wmv" as path. For transcoding, choose "Video - WMV + WMA (ASF)" profile from the drop down list. Click on "Next" button.

On this screen, you will see stream output string which is automatically generated. Make a note of this string, and click on "Stream" button at the bottom.

At this point, VLC should start streaming video from your webcam over HTTP. You will not see anything on VLC screen itself since streaming traffic is sent directly to localhost at TCP port number 8080.

To verify that VLC is running correctly at TCP port 8080, run the following command, and look for VLC.

$ sudo netstat -nap | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      11959/vlc       
tcp6       0      0 :::8080                 :::*                    LISTEN      11959/vlc

Live Stream Webcam from the Command Line

The method described earlier is setting up webcam streaming via VLC GUI. VLC comes with a command-line utility called cvlc which allows you to use VLC without its interface. cvlc is useful when you have to configure VLC streaming on a remote headless host.

To set up webcam streaming from the command line, you need to use three string values that I told you to make note of during the above GUI-based configuration. In this test setup, those string values were:

 
  • "MRL": v4l2:///dev/video0
  • "Edit options": :v4l2-standard= :input-slave=alsa://hw:0,0 :live-caching=300
  • "Stream output string": :sout="#transcode{vcodec=WMV2,vb=800,scale=1,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}"

Concatenate those three strings to contruct arguments for cvlc command. That is, the following command will launch webcam streaming over HTTP in WMV format.

$ cvlc v4l2:///dev/video0 :v4l2-standard= :input-slave=alsa://hw:0,0 :live-caching=300 :sout="#transcode{vcodec=WMV2,vb=800,scale=1,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}"

 

In the above command, specific string values (e.g., audio device name) might be slightly different depending on your hardware configuration. So go through the above GUI-based VLC configuration yourself to find out the correct cvlc arguments for your system.

Watch Streaming Video from Webcam

Once a streaming server starts running, the webcam live feed is available at http://<ip_address_of_webcam_host>:8080/stream.wmv

You can use VLC player or MPlayer to access the webcam feed as follows.

$ vlc http://<ip_address_of_webcam_host>:8080/stream.wmv
$ mplayer http://<ip_address_of_webcam_host>:8080/stream.wmv

 

If you are testing the feed from the same host, use loopback address 127.0.0.1 instead.

Security Protections for Your Webcam Feed

As mentioned earlier, it is not a good idea to stream your webcam over the Internet without any security protection. Consider some of these measures to protect your webcam feeds.

  • Download the latest firmware from webcam vendors.
  • Stream webcam over a secure VPN
  • Use iptables to whitelist IP addresses that you trust, and block all other connections.  

 

 

本文转载自:http://xmodulo.com/live-stream-video-webcam-linux.html

共有 人打赏支持
蓝薯

蓝薯

粉丝 11
博文 13
码字总数 15662
作品 0
昌平
程序员
私信 提问
如何在 Linux 中禁用内置摄像头

今天,我们将看到如何禁用未使用的内置网络摄像头或外置摄像头,以及如何在 Linux 中需要时启用它。禁用网络摄像头可以在很多方面为你提供帮助。你可以防止恶意软件控制你的集成摄像头,并监...

23%
2018/06/20
0
0
Window远程访问VMware中的Ubuntu

Window 远程访问VMware 中的Ubuntu edapex http://www.edapex.uqc.cn/ 家中本本性能一般,跑不起Android 项目,而台式机是I3 配置,跑这玩意 儿应绰绰有余了。老婆现在用I3 看电影,因为屏幕...

我是小白白白
2014/01/08
0
0
VNC实现Windows远程访问Ubuntu 16.04(无需安装第三方桌面,直接使用自带远程工具)

 本文主要是讲解如果理由VNC实现Windows远程访问Ubuntu 16.04,其实网上有很多类似教程,但是很多需要安装第三方桌面(xfce桌面等等),而且很多人不太喜欢安装第三方桌面,很多人像笔者一样...

寻知者
01/30
0
0
喀纳斯Ubuntu 10.10 i386中文定制版发布

喀纳斯自由软件专卖店在Ubuntu 10.10的基础上,在不修改Ubuntu的条件下,针对国内的用户实际需要,对Ubuntu 10.10进行了中文定制化。我们的定制目标是让Ubuntu更加易用! 定制主要内容是添加...

UDN社区
2010/10/18
1K
3
树莓派 motion安装摄像头实现远程监控

下面我们介绍如何来给树莓派装个USB摄像头,然后远程访问摄像头拍摄的即时画面。 首先你需要一个树莓派能兼容的USB摄像头,笔者用的是罗技(Logitech)C270 高清网络摄像头,插上即可。软件方...

郝槟楠
2018/06/29
0
0

没有更多内容

加载失败,请刷新页面

加载更多

C++ vector和list的区别

1.vector数据结构 vector和数组类似,拥有一段连续的内存空间,并且起始地址不变。 因此能高效的进行随机存取,时间复杂度为o(1); 但因为内存空间是连续的,所以在进行插入和删除操作时,会造...

shzwork
今天
3
0
Spring之invokeBeanFactoryPostProcessors详解

Spring的refresh的invokeBeanFactoryPostProcessors,就是调用所有注册的、原始的BeanFactoryPostProcessor。 相关源码 public static void invokeBeanFactoryPostProcessors(Configu......

cregu
昨天
4
0
ibmcom/db2express-c_docker官方使用文档

(DEPRECIATED) Please check DB2 Developer-C Edition for the replacement. What is IBM DB2 Express-C ? ``IBM DB2 Express-C``` is the no-charge community edition of DB2 server, a si......

BG2KNT
昨天
3
0
Ubuntu 18.04.2 LTS nvidia-docker2 : 依赖: docker-ce (= 5:18.09.0~3-0~ubuntu-bionic)

平台:Ubuntu 18.04.2 LTS nvidia-docker2 版本:2.0.3 错误描述:在安装nvidia-docker2的时候报dpkg依赖错误 nvidia-docker2 : 依赖: docker-ce (= 5:18.09.0~3-0~ubuntu-bionic) 先看一下依......

Pulsar-V
昨天
4
0
学习笔记1-goland结构体(struct)

写在前面:若有侵权,请发邮件by.su@qq.com告知。 转载者告知:如果本文被转载,但凡涉及到侵权相关事宜,转载者需负责。请知悉! 本文永久更新地址:https://my.oschina.net/bysu/blog/3036...

不最醉不龟归
昨天
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部