1.win+r打开运行。
2.在运行中键入services.msc回车,打开服务。
3.右边下拉找到VMware Authorization Service。
4.双击打开属性,启动类型->自动,点击驱动,点击应用,点击确定。这个时候已经授权虚拟机能访问到摄像头了。
5.打开虚拟机,点击"虚拟机"->可移动设备,找到摄像头camera,点击链接。此时虚拟机完成对摄像头的接管。
6.查看在/dev/下有video的文件。

安装cheese,打开摄像头:

sudo apt-get install cheese

在终端输入cheese回车->此时可以看到打开的摄像头。

查看设备类型

ffmpeg  -devices

可以看到有video4linux2,v4l2这个选项
“ v4l2”可以用作“ video4linux2”的别名。
alsa是音频类型,见另一篇:虚拟机使用pc麦克风声卡

根据设备类型查看具体设备名

ffmpeg -sources video4linux2

ffmpeg -sources v4l2

可以看到有这两个设备,这两个设备对应pc的摄像头

 /dev/video1 [Integrated Camera: Integrated I]/dev/video0 [Integrated Camera: Integrated C]

用命令打开摄像头,另一个不能用来打开

ffplay -f video4linux2 -video_size 640x480 -pixel_format yuyv422 -framerate 30 -i /dev/video0

查看设备输入输出参数

ffmpeg -h demuxer=v4l2

如查看都支持哪些像素格式

ffplay -f video4linux2 -list_formats all  /dev/video0

这些选项也可以用代码设置,"video_size"等名称与ffmpeg -h demuxer=v4l2 命令列举的名称一样。
AVDictionary *options = NULL;
av_dict_set(&options, “video_size”, “1920x1080”, 0);
av_dict_set(&options, “framerate”, “30”, 0);
//以上参数如果不设置的话,ffmpeg就会用默认值,但默认值摄像头不一定支持
int re = avformat_open_input(&ic, “/dev/video0”, ifmt, &options);

其次对于显示在/dev/video中的摄像头其实都是支持UVC协议的摄像头,一般说摄像头免驱动也是基于UVC开发的,我们可以用luvcview这款软件查看所有基于UVC的摄像头的信息,对于ubuntu12,可以直接执行下列命令安装,因为当时是为ubuntu12设计的:
sudo apt-get install luvcview
对于其他版本,可以到官网下载deb包安装,连接:
luvcview_0.2.6-5_amd64.deb (52.3 KiB)
安装好后
打开摄像头

luvcview -l

打开摄像头

luvcview -d /dev/video1 -f yuv -s 640x480

查看设备支持的像素格式和帧率

luvcview -d /dev/video0 -L

可以看到支持的像素格式:MJPG YUYV RGB3 BGR3 YU12 YV12
Time interval between frame: 1/30 也就是帧间的时间间隔,也就是帧率了。

luvcview 0.2.6SDL information:Video driver: x11A window manager is available
Device information:Device path:  /dev/video0
{ pixelformat = 'MJPG', description = 'Motion-JPEG' }
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/30,
{ pixelformat = 'YUYV', description = 'YUYV 4:2:2' }
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/20,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/15,
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/10,
{ pixelformat = 'RGB3', description = 'RGB3' }
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/20,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/30,
{ pixelformat = 'BGR3', description = 'BGR3' }
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/20,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/30,
{ pixelformat = 'YU12', description = 'YU12' }
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/20,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/30,
{ pixelformat = 'YV12', description = 'YV12' }
{ discrete: width = 1280, height = 720 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 180 }Time interval between frame: 1/30,
{ discrete: width = 320, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 352, height = 288 }Time interval between frame: 1/30,
{ discrete: width = 424, height = 240 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 360 }Time interval between frame: 1/30,
{ discrete: width = 640, height = 480 }Time interval between frame: 1/30,
{ discrete: width = 848, height = 480 }Time interval between frame: 1/20,
{ discrete: width = 960, height = 540 }Time interval between frame: 1/30,
ffplay -f video4linux2 -framerate 60 -video_size 1920x1080 -pixel_format mjpeg  -i /dev/video4

用mjpeg的方式播放,并设置帧率。

如果你想把其他的raw流放入/dev/video设备中,也是可以用ffmpeg推流的:

ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0

以上把屏幕推流到/dev/video0上,但video0是必须是虚拟设备,不对应实际device
如何设置虚拟/dev/video参考:https://www.cnblogs.com/xl2432/p/13501145.html

补充:
ffmpeg的libavdevice模块支持的计算机中常用的音视频捕获或输出设备:ALSA、AUDIO_BEOS 、JACK、OSS、1394、VFW等。

虚拟机使用pc摄像头相关推荐

  1. 虚拟机使用pc麦克风声卡

    1.win+r打开运行. 2.在运行中键入services.msc回车,打开服务. 3.右边下拉找到VMware Authorization Service. 4.双击打开属性,启动类型->自动 ...

  2. 在虚拟机中使用摄像头

    在虚拟机中使用摄像头 最近购买了小觅双目相机,但是电脑只有一个ubuntu18.04的虚拟机,官网说SDK不支持虚拟机.尝试以下方法后,可以在虚拟机中成功运行samples: 虚拟机设置-硬件-USB ...

  3. js调用pc摄像头实现拍照、录视频等,新版Chrome无访问http页面无法打开麦克风、摄像头

    js调用pc摄像头实现拍照.录视频等,新版Chrome无访问http页面无法打开麦克风.摄像头 新版Chrome配置 vue环境下的前端 function部分 ##由于没有https环境,只有http ...

  4. html 调用pc摄像头,HTML调用PC摄像头

    使用HTML5中的canvas和video技术实现调用PC摄像头 1.[代码][HTML]代码 HTML5调用电脑摄像头实例 window.addEventListener("DOMCont ...

  5. HTML调用PC摄像头【申明:来源于网络】

    HTML调用PC摄像头[申明:来源于网络] ---- 地址:http://www.oschina.net/code/snippet_2440934_55195 <!DOCTYPE html> ...

  6. PC摄像头设置 默认摄像头设置 win11 默认摄像头设置

    PC摄像头设置  默认摄像头设置  win11 默认摄像头设置 答案: 在设备管理器中,禁用用不到的虚拟摄像头.

  7. JZ2440开发板与电脑通过网线直连,实现开发板、虚拟机、PC机三者互Ping,并成功挂接网络根文件系统

    声明: 本文提及的部分图片与内容属于韦东山老师的教学视频课程内容,本文提出的解决方案是基于韦老师教学视频中提及方案的扩展. 转载内容来自: [005_ARM裸机1期加强版_第006课_第006节_一句 ...

  8. EasyDarwin+ffmpeg进行PC(摄像头+麦克风)流媒体直播服务

    上一回我们描述了用EasyDarwin+ffmpeg进行摄像机直播的过程:ffmpeg推送,EasyDarwin转发,vlc播放 实现整个RTSP直播 我们再进行一个方面的描述,那就是pc摄像头+麦克 ...

  9. Unity调用PC摄像头

     Unity调用PC摄像头    绑定在一个带有Render组件的物体上就行了. 本帖隐藏的内容 [html] view plaincopyprint?  using UnityEngine;  ...

最新文章

  1. java中的与或非_与或非 · java development · 看云
  2. exists sql用法_SQL关于IN和EXISTS的用法和区别,读完之后,大部分程序员收藏了....
  3. mysql 一行取最大值_mysql 分组取最大值的同时获取包含最大值的行的其他字段
  4. QNX Software Development Platform
  5. linux下双击sh文件夹,Linux系统下如何运行.sh文件的实现
  6. 最大子数组累加和(2种方法)
  7. 在做简单网页时,遇到的一些js问题
  8. KEmulator与eclipse的集成
  9. 计算机硬盘型号怎么看,硬盘编号怎么看
  10. 页面404圈小猫游戏代码
  11. 喜洋洋大战灰太狼(大结局)
  12. Latex Table 合并行/列详解
  13. 用Vue写的一个简易的待办事项清单系统
  14. Vue ElementUI el-tree 修改节点收缩 icon
  15. web系统中的结构化数据标记
  16. 互联网日报 | 蚂蚁集团确定IPO发行价;小米双11将拿出10亿补贴;特斯拉上海超级工厂启动整车出口...
  17. 题目34 众数和中位数
  18. vue crud_使用Vue和Deepstream构建实时CRUD应用
  19. 关于IDEA Translation插件的谷歌翻译无法翻译问题
  20. IP 摄像机移动应用 SDK 开发入门教程(安卓版)

热门文章

  1. 抖音如何导流到微信?抖音官网链接引导加微信的设置
  2. KBQA_多轮对话——模型源码解析(一)Pickle模块功能详解
  3. PyinputPlus模块在麦当劳店三明治点餐计费的应用
  4. C语言的下载和环境设置
  5. 世界银行专家:区块链可以重塑全球电子政务采购
  6. iphone ios 如何查询apple store分类排名和下载量
  7. 2020大学计算机基础题库,2020年知到大学计算机基础第一单元章节测试答案
  8. 开源的单点登录系统CAS入门
  9. SAR命令的解析及使用
  10. 【数据分析】业务分析中常见模型-波士顿矩阵、逻辑回归模型