xposed安卓虚拟摄像头
感谢https://github.com/wangwei1237/CameraHook 提供的HOOK思路!!
1、安装xposed框架(传统xposed,edxp,lsposed等均可,不确定虚拟框架能否使用,已经确定VMOS可用,应用转生不可用)
2、安装模块,启用模块,lsposed等包含定义域的框架需要选勾目标app,但无需选勾系统框架。
3、将需要替换的视频命名为virtual.mp4
,放在/sdcard/DCIM/Camera1/
目录下。(前置摄像头需要水平翻转后右旋90°保存,onPreviewFrame需要匹配分辨率)
4、若需要拦截拍照事件,请在/sdcard/DCIM/Camera1/
目录下放置 1000.bmp
用于替换,(前置摄像头需要水平翻转后右旋90°保存,需要匹配分辨率)
5、授予目标应用读取本地文件的权限,至少是允许读取媒体文件。
6、强制结束目标应用/重启手机。
在目标应用中打开摄像头,可在弹出的toast消息里看见。
是的,目前Camera2接口的HOOK不是所有应用程序都能生效,部分app报错打开相机失败,如果想停用Camera2接口的HOOK,可在/sdcard/DCIM/Camera1/
下创建disable.jpg
,以停用此项HOOK
在/sdcard/DCIM/Camera1/
下创建no-silent.jpg
,就不会静音了。
- Install this moudle. enable it in Xposed. Framework which has a scope list need to choose target app, but needn't to choose system framework.
- Create
virtual.mp4
and put it under/sdcard/DCIM/Camera1/
,(if use front camera ,image should be Flip horizontal and right rotation 90 degrees, if you want to hook onPreviewFrame ,the resolution should be matched) - If you wants to hook image capture event, you should create
1000.bmp
under/sdcard/DCIM/Camera1/
for replace. (if use front camera ,image should be Flip horizontal and right rotation 90 degrees, the resolution should be matched) - authorize the target app to access local storage in system.
- Reboot your phone or shutdown target app.
create disable.jpg
under /sdcard/DCIM/Camera1/
to disable this method hook.
open camera in target app, and you can find resolution in toast message.
Create no-silent.jpg
under /sdcard/DCIM/Camera1/
, and it will play sounds.
在/app/release/app-release.apk,下载前请注意分支。
GitHub: https://github.com/w2016561536/android_virtual_cam/blob/master/app/release/app-release.apk
gitee(中国大陆建议此点): https://gitee.com/w2016561536/android_virtual_cam/blob/master/app/release/app-release.apk