是否可以根据通过网络接收的流创建虚拟网络摄像头?

Is it possible to create a virtual webcam based on a stream received over the network?

我有一个应用程序需要网络摄像头输入来进行面部表情分析。我想在服务器上托管这个应用程序,它可以处理从客户端(可以是网络、移动、桌面或任何其他类型的客户端)接收的视频流,然后将结果发送回 JSON.

面部表情分析应用程序不接受远程视频流作为输入,但它与网络摄像头配合使用效果很好。我的想法是,当客户端连接到服务器时,应该根据客户端提供的视频流创建一个虚拟网络摄像头。下图描述了该概念的简化版本:

是否存在能够执行此操作的任何程序或库?最初,我想在 JavaScript 中创建一个客户端,它使用 getUserMedia() 方法从一台 PC 上的网络摄像头捕获视频,然后将其流式传输到另一台 PC,即 运行 服务器。

尝试akvirtualcamera of the Webcamoid project (via). From the wiki:

AkVCamManager add-device -i VirtualCamera0 "Virtual Camera"
AkVCamManager add-format VirtualCamera0 RGB24 640 480 30
AkVCamManager update

# Test
ffmpeg -f avfoundation -list_devices true -i ""
# Placeholder until integrated
AkVCamManager set-picture /path/to/place_holder_picture.png
# List clients
AkVCamManager clients

# Stream
ffmpeg -i tcp://127.0.0.1:2000 -pix_fmt rgb24 -f rawvideo - | AkVCamManager stream --fps 30 VirtualCamera0 RGB24 640 480

如果相机无法正常工作,AkVCamManager hack set-service-up 可能会有所帮助。以下是 AkVCamManager 的帮助,供参考:

AkVCamManager [OPTIONS...] COMMAND [COMMAND_OPTIONS...] ...

AkVirtualCamera virtual device manager.

General Options:

-h, --help         Show help.
--help-all         Show advanced help.
-v, --version      Show program version.
-p, --parseable    Show parseable output.
-f, --force        Force command.

Commands:

devices                                                        List devices.
add-device        DESCRIPTION                                  Add a new device.

    -i, --id DEVICEID    Create device as DEVICEID.

remove-device     DEVICE                                       Remove a device.
remove-devices                                                 Remove all devices.
description       DEVICE                                       Show device description.
set-description   DEVICE DESCRIPTION                           Set device description.
supported-formats                                              Show supported formats.

    -i, --input     Show supported input formats.
    -o, --output    Show supported output formats.

default-format                                                 Default device format.

    -i, --input     Default input format.
    -o, --output    Default output format.

formats           DEVICE                                       Show device formats.
add-format        DEVICE FORMAT WIDTH HEIGHT FPS               Add a new device format.

    -i, --index INDEX    Add format at INDEX.

remove-format     DEVICE INDEX                                 Remove device format.
remove-formats    DEVICE                                       Remove all device formats.
update                                                         Update devices.
load              SETTINGS.INI                                 Create devices from a setting file.
stream            DEVICE FORMAT WIDTH HEIGHT                   Read frames from stdin and send them to the device.

    -f, --fps FPS    Read stream input at a constant frame rate.

listen-events                                                  Keep the manager running and listening to global events.
controls          DEVICE                                       Show device controls.
get-control       DEVICE CONTROL                               Read device control.

    -c, --description    Show control description.
    -t, --type           Show control type.
    -m, --min            Show minimum value for the control.
    -M, --max            Show maximum value for the control.
    -s, --step           Show increment/decrement step for the control.
    -d, --default        Show default value for the control.
    -l, --menu           Show options of a memu type control.

set-controls      DEVICE CONTROL_1=VALUE CONTROL_2=VALUE...    Write device controls values.
picture                                                        Placeholder picture to show when no streaming.
set-picture       FILE                                         Set placeholder picture.
loglevel                                                       Show current debugging level.
set-loglevel      LEVEL                                        Set debugging level.
clients                                                        Show clients using the camera.
dump                                                           Show all information in a parseable XML format.