如何使用ffmpeg从Docker容器访问内置摄像头? [英] How to access builtin webcam from a docker container using ffmpeg?

查看:154
本文介绍了如何使用ffmpeg从Docker容器访问内置摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了使用 ffmpeg 通过MAC的内置网络摄像头捕获视频的代码.
在本地计算机上,代码可以正常工作.但是,我构建了代码的docker容器,并尝试运行它,但出现以下错误:

I have wrote my code that captures videos by my builtin webcam of my MAC using ffmpeg.
On local machine, the code works fine. However, I built a docker container of my code, and tried to run it, but I got the following error:

error: Command failed: ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd -vf scale=640x480 -flags +global_header -f segment -segment_time 10 -segment_list ../out.csv -segment_format_options movflags=+faststart -reset_timestamps 1 -strftime 1 %Y%m%d-%H%M%S.mp4
ffmpeg version git-2016-05-25-9591ca7 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-openssl
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 43.100 / 57. 43.100
  libavformat    57. 37.100 / 57. 37.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.100 /  6. 46.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Unknown input format: 'avfoundation'

    据我从该日志中了解到的
  1. 容器无权访问本地设备.
    据此讨论 Docker-一种方法允许访问主机USB或串行设备?,我需要使用-device 标志来传递我的设备的位置.
    但是,根据此答案,那不可能吗?
  2. 除了我提到的内容上面,我一开始无法获取网络摄像头的路径.什么是Macbook网络摄像头的正确路径
  1. as far as what I understood from this log, is that the docker container doesn't have access to local devices.
    According to this discussion Docker - a way to give access to a host USB or serial device? , I need to use the --device flag to pass my device's location.
    However, according to this answer, that is not possible?
  2. In addition to what I've mentioned above, I couldn't get my webcam's path at the first place. what is a correct path for macbook webcam

我的问题是:如何访问我的MAC内置摄像机以从Docker容器进行记录?

My question is: How to access my MAC's builtin camera to record from a docker container?

推荐答案

我认为此评论将回答您的问题: https://stackoverflow.com/a/64634921/838712

I think this comment would answer your question: https://stackoverflow.com/a/64634921/838712

这说明了如何使macOS摄像机在Linux docker容器内可用.ffmpeg然后应该可以使用此设备,而不会出现任何问题.

This explains how to make the macOS camera available inside a linux docker container. ffmpeg should then be able to use this device without any problem.

这篇关于如何使用ffmpeg从Docker容器访问内置摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆