snap版scrcpyでAndroidデバイス画面をビデオデバイスに出力

Androidアプリの画面をsnap版のscrcpyでビデオデバイスに流し込もうとしたら少しハマったのでメモしておきます.

Debian Bullseye amd64のscrcpyでAndroidの画面をビデオデバイスに出力してみようと --v4l2-sink オプションを指定したところバージョンが古く未対応でした.

$ /bin/scrcpy --v4l2-sink /dev/video8
/bin/scrcpy: unrecognized option '--v4l2-sink'

Debian sidの 1.23-1 だと存在するオプションなのですがそれを入れると依存関係がおかしくなりそうなので避けたいところ.

Androidアプリの画面をsnap版のscrcpyでビデオデバイスに流し込もうとしたら少しハマったのでメモしておきます.


Debian Bullseye amd64のscrcpyでAndroidの画面をビデオデバイスに出力してみようと --v4l2-sink オプションを指定したところバージョンが古く未対応でした.

$ /bin/scrcpy --v4l2-sink /dev/video8
/bin/scrcpy: unrecognized option '--v4l2-sink'

Debian sidの 1.23-1 だと存在するオプションなのですがそれを入れると依存関係がおかしくなりそうなので避けたいところ.

$ rmadison scrcpy
scrcpy     | 1.17-1        | stable         | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
scrcpy     | 1.23-1        | unstable       | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
scrcpy     | 1.23-1        | unstable-debug | source

snapを確認すると1.23のようなのでこれを導入してみました.

$ snap find scrcpy
Name       Version  Publisher   Notes  Summary
scrcpy     v1.23    sisco311    -      Display and control your Android device
guiscrcpy  v4.9.0   srevinsaju  -      An opensource graphical user interface for Android screen mirroring
$ snao install scrcpy
$ snap info scrcpy
name:      scrcpy
summary:   Display and control your Android device
publisher: sisco311
store-url: https://snapcraft.io/scrcpy
contact:   https://github.com/sisco311/scrcpy-snap/issues
license:   Apache-2.0
description: |
  This application provides display and control of Android devices connected on USB (or over
  TCP/IP). It does not require any root access.

  This is an unofficial snap. The code of scrcpy can be found at:
  https://github.com/Genymobile/scrcpy
commands:
  - scrcpy.adb
  - scrcpy
snap-id:      M7yvgnqOvyQj64bolfpawIAEwHv7dQ5G
tracking:     latest/stable
refresh-date: today at 01:27 JST
channels:
  latest/stable:    v1.23             2022-03-03 (379)  87MB -
  latest/candidate: ↑
  latest/beta:      v1.23-2-gadbe7908 2022-03-02 (376)  87MB -
  latest/edge:      v1.21-2-g5704ec6  2021-12-07 (358) 101MB -
installed:          v1.23                        (379)  87MB -

1.23です.

$ which scrcpy
/snap/bin/scrcpy
$ scrcpy --version
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.0.8 / 2.0.8
 - libavcodec: 57.107.100 / 57.107.100
 - libavformat: 57.83.100 / 57.83.100
 - libavutil: 55.78.100 / 55.78.100
 - libavdevice: 57.10.100 / 57.10.100
 - libusb: - / 1.0.21

早速使おうと思いましたがエラーとなってしまいました.

$ scrcpy --v4l2-sink /dev/video8
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 6.8 MB/s (41123 bytes in 0.006s)
[server] INFO: Device: motorola moto g31(w) (Android 11)
INFO: Renderer: opengl
INFO: OpenGL version: 3.0 Mesa 20.0.8
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2400
ERROR: Failed to open output device: /dev/video8
ERROR: Could not open frame sink 1
ERROR: Could not open decoder sinks
ERROR: Could not open packet sink 0
ERROR: Could not open demuxer sinks
WARN: Device disconnected
WARN: Killing the server...

このデバイスは存在するし,別のアプリケーションから動画を流し込むと動作します.

issueを検索すると以下のコメントを見つけました.

以下のコマンドでsnapのscrcpyにビデオデバイスを接続する必要があるようです.

$ snap connect scrcpy:camera

認識させたあと実行するとうまく行きました.

$ scrcpy --v4l2-sink /dev/video8 --lock-video-orientation --max-size=720 -N
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 10.6 MB/s (41123 bytes in 0.004s)
[server] INFO: Device: motorola moto g31(w) (Android 11)
INFO: v4l2 sink started to device: /dev/video8

scrcpy snap2video

環境
$ snap info scrcpy | grep installed:
installed:          v1.23                        (379)  87MB -
$ dpkg-query -W snap v4l2loopback-dkms v4l2loopback-source v4l2loopback-utils
snap
v4l2loopback-dkms       0.12.5-1
v4l2loopback-source     0.12.5-1
v4l2loopback-utils      0.12.5-1
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ uname -a
Linux yoga-260 5.16.15-le9 #10 SMP PREEMPT Sat Mar 19 01:52:06 JST 2022 x86_64 GNU/Linux
$ arch
x86_64
$ rmadison scrcpy
scrcpy     | 1.17-1        | stable         | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
scrcpy     | 1.23-1        | unstable       | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
scrcpy     | 1.23-1        | unstable-debug | source

snapを確認すると1.23のようなのでこれを導入してみました.

$ snap find scrcpy
Name       Version  Publisher   Notes  Summary
scrcpy     v1.23    sisco311    -      Display and control your Android device
guiscrcpy  v4.9.0   srevinsaju  -      An opensource graphical user interface for Android screen mirroring
$ snao install scrcpy
$ snap info scrcpy
name:      scrcpy
summary:   Display and control your Android device
publisher: sisco311
store-url: https://snapcraft.io/scrcpy
contact:   https://github.com/sisco311/scrcpy-snap/issues
license:   Apache-2.0
description: |
  This application provides display and control of Android devices connected on USB (or over
  TCP/IP). It does not require any root access.

  This is an unofficial snap. The code of scrcpy can be found at:
  https://github.com/Genymobile/scrcpy
commands:
  - scrcpy.adb
  - scrcpy
snap-id:      M7yvgnqOvyQj64bolfpawIAEwHv7dQ5G
tracking:     latest/stable
refresh-date: today at 01:27 JST
channels:
  latest/stable:    v1.23             2022-03-03 (379)  87MB -
  latest/candidate: ↑
  latest/beta:      v1.23-2-gadbe7908 2022-03-02 (376)  87MB -
  latest/edge:      v1.21-2-g5704ec6  2021-12-07 (358) 101MB -
installed:          v1.23                        (379)  87MB -

1.23です.

$ which scrcpy
/snap/bin/scrcpy
$ scrcpy --version
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.0.8 / 2.0.8
 - libavcodec: 57.107.100 / 57.107.100
 - libavformat: 57.83.100 / 57.83.100
 - libavutil: 55.78.100 / 55.78.100
 - libavdevice: 57.10.100 / 57.10.100
 - libusb: - / 1.0.21

早速使おうと思いましたがエラーとなってしまいました.

$ scrcpy --v4l2-sink /dev/video8
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
INFO: Video orientation is locked for v4l2 sink. See --lock-video-orientation.
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 6.8 MB/s (41123 bytes in 0.006s)
[server] INFO: Device: motorola moto g31(w) (Android 11)
INFO: Renderer: opengl
INFO: OpenGL version: 3.0 Mesa 20.0.8
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2400
ERROR: Failed to open output device: /dev/video8
ERROR: Could not open frame sink 1
ERROR: Could not open decoder sinks
ERROR: Could not open packet sink 0
ERROR: Could not open demuxer sinks
WARN: Device disconnected
WARN: Killing the server...

このデバイスは存在するし,別のアプリケーションから動画を流し込むと動作します.

issueを検索すると以下のコメントを見つけました.

以下のコマンドでsnapのscrcpyにビデオデバイスを接続する必要があるようです.

$ snap connect scrcpy:camera

認識させたあと実行するとうまく行きました.

$ scrcpy --v4l2-sink /dev/video8 --lock-video-orientation --max-size=720 -N
scrcpy 1.23 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 10.6 MB/s (41123 bytes in 0.004s)
[server] INFO: Device: motorola moto g31(w) (Android 11)
INFO: v4l2 sink started to device: /dev/video8

scrcpy snap2video

環境
$ snap info scrcpy | grep installed:
installed:          v1.23                        (379)  87MB -
$ dpkg-query -W snap v4l2loopback-dkms v4l2loopback-source v4l2loopback-utils
snap
v4l2loopback-dkms       0.12.5-1
v4l2loopback-source     0.12.5-1
v4l2loopback-utils      0.12.5-1
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ uname -a
Linux yoga-260 5.16.15-le9 #10 SMP PREEMPT Sat Mar 19 01:52:06 JST 2022 x86_64 GNU/Linux
$ arch
x86_64

「snap版scrcpyでAndroidデバイス画面をビデオデバイスに出力」への2件のフィードバック

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です