Linux环境下配置虚拟摄像头akvcam

下载源码

git clone https://github.com/webcamoid/akvcam.git

编译&安装

cd akvcam/src
make
sudo make dkms_install

确认是否安装驱动成功,如果有文件,则安装驱动成功

ls /lib/modules/$(uname -r)/extra/akvcam.ko*

可以使用如下命令卸载驱动

sudo make dkms_uninstall

配置虚拟摄像头

修改配置文件

sudo mkdir -p /etc/akvcam
sudo touch /etc/akvcam/config.ini
sudo chmod -vf 644 /etc/akvcam/config.ini

修改/etc/akvcam/config.ini,内容如下:

# Virtual camera configuration file example.
#
# Please, read the instructions to the end.

[Cameras]
# First at all you must define how many virtual cameras will be created.
cameras/size = 2

# Then, define it's properties.
#
# A virtual camera can be of 2 types: 'capture' and 'output'.
# A 'capture' device will be seen as a normal webcam by any webcam capture
# program.
# A 'output' device will receive frames from a producer program and send it to
# one or many 'capture' devices.
#
# A camera can have also 3 capture/output modes: 'mmap', 'userptr' and 'rw'.
# 'mmap' is the most widely supported mode by far, enabling this is more than
# enough in most cases. 'rw' allow you to "echo" or "cat" frames as raw data
# directly to the device using the default frame format. Enabling 'rw' mode will
# disable emulated camera controls in the 'capture' device (brightness,
# contrast, saturation, etc.).
# A device can support all 3 modes at same time.
#
# 'formats' is a comma separated list of index in the format list bellow.
#
# It's also possible to set the device number by setting the 'videonr' property,
# if for example videonr=7 the the device will be created as "/dev/video7".
# If 'videonr' is already taken, negative or not set, the driver will assign the
# first free device number.
cameras/1/type = output
cameras/1/mode = mmap, userptr, rw
cameras/1/description = Virtual Camera (output device)
cameras/1/formats = 2
cameras/1/videonr = 7

cameras/2/type = capture
cameras/2/mode = mmap, rw
cameras/2/description = Virtual Camera
cameras/2/formats = 1, 2

[Formats]
# Define how many formats will be supported by the camera.
formats/size = 2

# Now define the frame pixel formats, resolutions and frame rates supported by
# the camera.
#
# Supported capture formats:
#
#     RGB32
#     RGB24
#     RGB16
#     RGB15
#     BGR32
#     BGR24
#     UYVY
#     YUY2
#
# Supported output formats:
#
#     RGB24
#     BGR24
#
# YUY2 640x480 is one of the most widely supported formats in webcam capture
# programs. First format defined is the default frame format for
# 'capture'/'output'.
# 'width', 'height' and 'fps' are unsigned integers.
formats/1/format = YUY2
formats/1/width = 640
formats/1/height = 480
formats/1/fps = 30

# The parameters can also be specified as a comma separated list, so it's
# possible to combine the parameters to define several formats in one group.
# 'fps' can also be defined as a fraction.
# The following lines will define 4 formats:
#
#     RGB24 640x480 20  FPS
#     RGB24 640x480 7.5 FPS
#     YUY2  640x480 20  FPS
#     YUY2  640x480 7.5 FPS
formats/2/format = RGB24, YUY2
formats/2/width = 640
formats/2/height = 480
formats/2/fps = 20/1, 15/2

# Finally, to create a fully working virtual camera, you must connect one
# 'output' to one or many 'capture' devices.
# Connections are made by index, separated by a colon. The first index is the
# 'output' device, the following index are 'capture' devices.
[Connections]
connections/size = 1
connections/1/connection = 1:2

# You can also define a default frame when a 'capture' device is not receiving
# any input. Only 24 bpp and 32 bpp BMP files are supported.
[General]
# 修改此处的图片路径,只能是BMP格式的图片
default_frame = /etc/akvcam/default_frame.bmp
# This config will take effect on modprobe/insmod.

调试驱动

sudo modprobe akvcam loglevel=7

用法和例子

在前面的驱动和配置文件正常的情况下,使用如下命令加载驱动:

cd akvcam/src
sudo modprobe videodev

先卸载,再安装

sudo rmmod akvcam.ko
sudo insmod akvcam.ko

到此处已经虚拟摄像头已经配置好了,打开相机应用查看是否生效,

开机加载(非必需步骤)

要在启动时加载模块,请创建一个/etc/modules-load.d/akvcam.conf文件,然后在其中写入akvcam

echo akvcam > /etc/modules-load.d/akvcam.conf
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,686评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,668评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,160评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,736评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,847评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,043评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,129评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,872评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,318评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,645评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,777评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,470评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,126评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,861评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,095评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,589评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,687评论 2 351

推荐阅读更多精彩内容