在 Ubuntu 20.04 上使用索尼数码相机 RX100M4 作为网络摄像头时出现问题

在 Ubuntu 20.04 上使用索尼数码相机 RX100M4 作为网络摄像头时出现问题

按照说明安装v4l2loopback内核模块和gphoto2
我可以使用控制相机和拍照Entangle,还可以在其中查看实时预览视频Entangle,但我无法使用 ffmpeg 流式传输视频以在其他应用程序中使用它。

$ gphoto2 --abilities
Abilities for camera             : Sony DSC-RX100M4                            
Serial port support              : no
USB support                      : yes
Capture choices                  :
                                 : Image
                                 : Preview
                                 : Trigger Capture
Configuration support            : yes
Delete selected files on camera  : yes
Delete all files on camera       : no
File preview (thumbnail) support : yes
File upload support              : yes

终止所有现有实例

$ sudo killall gvfs-gphoto2-volume-monitor
gvfs-gphoto2-volume-monitor: no process found

有 3 个 /dev/video*

$ ll /dev/video*
crw-rw----+ 1 root video 81, 0 Nov  7 08:46 /dev/video0
crw-rw----+ 1 root video 81, 1 Nov  7 08:46 /dev/video1
crw-rw----+ 1 root video 81, 2 Nov  7 09:35 /dev/video2

运行将视频传送到 /dev/video* 的命令对任何一个都不起作用:

$ gphoto2 --stdout --capture-movie | gst-launch-1.0 fdsrc ! decodebin3 name=dec ! queue ! videoconvert ! v4l2sink device=/dev/video2
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video2' is not a output device.
Additional debug info:
v4l2_calls.c(636): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x85208000
Setting pipeline to NULL ...
Freeing pipeline ...

*** Error ***              
Sorry, your Sony camera does not seem to return a JPEG image in LiveView mode
ERROR: Movie capture error... Exiting.
Movie capture finished (0 frames)

我尝试了在相机上切换自动和电影模式的不同方法,如官方说明,没有运气……

知道我遗漏了什么吗?

这是否Sorry, your Sony camera does not seem to return a JPEG image in LiveView mode意味着它不适用于我的相机?(Sony DSC-RX100M4

另一个命令(ffmpeg):

$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video1
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mjpeg @ 0x55bb2836b0c0] Format mjpeg detected only with low score of 25, misdetection possible!
Input #0, mjpeg, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1024x680, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
[swscaler @ 0x55bb283bef00] deprecated pixel format used, make sure you did set range correctly
[video4linux2,v4l2 @ 0x55bb28370dc0] Unable to open V4L2 device '/dev/video1'
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Error initializing output stream 0:0 -- 
Conversion failed!

答案1

  1. 来自此主题: https://sourceforge.net/p/gphoto/mailman/gphoto-user/thread/8D4C4496-8CF9-45D1-914A-36B217E044AC%40getmailspring.com/#msg37144578

libgphoto2 2.5.26 我们也对索尼预览捕捉进行了一些修复。

因此,要么使用 libgphoto2>=2.5.26 的现代发行版,要么使用以下脚本进行升级:https://github.com/gonzalo/gphoto2-updater/

使用以下方法检查 libgphoto2 版本

gphoto2 --version
  1. 之后,将相机 USB 模式切换为 PC 控制(PC 远程)模式。如果需要,更改省电设置(以便超时后不会关闭)。

  2. 检查照片拍摄

gphoto2 --capture-image-and-download
  1. 如果有效,继续进行电影捕捉测试
gphoto2 --capture-movie=10s
  1. 如果影片捕捉成功,则创建一个虚拟 V4L2 相机,从真实相机接收流并将其写入ffmpeg/dev/video2然后使用 VLC 打开 V4L2 相机流进行测试。(v4l2-ctl列出 V4L2 设备,之后rmmod可选择卸载v4l2loopback)。
sudo apt install v4l2loopback-utils
sudo modprobe v4l2loopback devices=1 exclusive_caps=1 max_buffers=2 video_nr=2 card_label="fake-cam"
v4l2-ctl --list-devices

gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt rgb32 -threads 0 -f v4l2 /dev/video2

vlc v4l2:///dev/video2

sudo rmmod v4l2loopback

相关内容