mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2025-02-17 18:59:19 +01:00
perf: 📸 Recording camera support
This commit is contained in:
parent
18dcd24e65
commit
10d0370b66
@ -58,8 +58,8 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
scrcpyArgs(...args) {
|
scrcpyParams(...args) {
|
||||||
return this.$store.preference.getScrcpyArgs(...args)
|
return this.$store.preference.scrcpyParameter(...args)
|
||||||
},
|
},
|
||||||
preferenceData(...args) {
|
preferenceData(...args) {
|
||||||
return this.$store.preference.getData(...args)
|
return this.$store.preference.getData(...args)
|
||||||
@ -82,7 +82,7 @@ export default {
|
|||||||
`${this.$store.device.getLabel(
|
`${this.$store.device.getLabel(
|
||||||
this.device,
|
this.device,
|
||||||
)}-displayId-${displayId}`,
|
)}-displayId-${displayId}`,
|
||||||
args: this.scrcpyArgs(this.device.id),
|
args: this.scrcpyParams(this.device.id),
|
||||||
})
|
})
|
||||||
|
|
||||||
res.forEach((item) => {
|
res.forEach((item) => {
|
||||||
|
@ -37,7 +37,7 @@ export default {
|
|||||||
|
|
||||||
this.toggleRowExpansion(row, true)
|
this.toggleRowExpansion(row, true)
|
||||||
|
|
||||||
const args = this.$store.preference.getScrcpyArgs(row.id, {
|
const args = this.$store.preference.scrcpyParameter(row.id, {
|
||||||
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa'],
|
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ export default {
|
|||||||
|
|
||||||
this.toggleRowExpansion(row, true)
|
this.toggleRowExpansion(row, true)
|
||||||
|
|
||||||
const args = `--video-source=camera ${this.$store.preference.getScrcpyArgs(
|
const args = `--video-source=camera ${this.$store.preference.scrcpyParameter(
|
||||||
row.id,
|
row.id,
|
||||||
{
|
{
|
||||||
excludes: [
|
excludes: [
|
||||||
|
@ -29,7 +29,7 @@ export default {
|
|||||||
|
|
||||||
this.toggleRowExpansion(row, true)
|
this.toggleRowExpansion(row, true)
|
||||||
|
|
||||||
const args = `--otg ${this.$store.preference.getScrcpyArgs(row.id, {
|
const args = `--otg ${this.$store.preference.scrcpyParameter(row.id, {
|
||||||
excludes: [
|
excludes: [
|
||||||
'--mouse=uhid',
|
'--mouse=uhid',
|
||||||
'--keyboard=uhid',
|
'--keyboard=uhid',
|
||||||
|
@ -32,7 +32,7 @@ export default {
|
|||||||
|
|
||||||
const savePath = this.getRecordPath(row)
|
const savePath = this.getRecordPath(row)
|
||||||
|
|
||||||
const args = this.$store.preference.getScrcpyArgs(row.id, {
|
const args = this.$store.preference.scrcpyParameter(row.id, {
|
||||||
isRecord: true,
|
isRecord: true,
|
||||||
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa'],
|
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa'],
|
||||||
})
|
})
|
||||||
|
@ -0,0 +1,96 @@
|
|||||||
|
<template>
|
||||||
|
<slot :loading="loading" :trigger="handleClick" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { sleep } from '$/utils'
|
||||||
|
import { openFloatControl } from '$/utils/device/index.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
row: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
toggleRowExpansion: {
|
||||||
|
type: Function,
|
||||||
|
default: () => () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async handleClick() {
|
||||||
|
const row = this.row
|
||||||
|
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
this.toggleRowExpansion(row, true)
|
||||||
|
|
||||||
|
const savePath = this.getRecordPath(row)
|
||||||
|
|
||||||
|
let args = this.$store.preference.scrcpyParameter(row.id, {
|
||||||
|
isRecord: true,
|
||||||
|
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa', '--video-source'],
|
||||||
|
})
|
||||||
|
|
||||||
|
args += ' --video-source=camera'
|
||||||
|
|
||||||
|
try {
|
||||||
|
const recording = this.$scrcpy.record(row.id, {
|
||||||
|
title: this.$store.device.getLabel(row, 'recording'),
|
||||||
|
savePath,
|
||||||
|
args,
|
||||||
|
stdout: this.onStdout,
|
||||||
|
stderr: this.onStderr,
|
||||||
|
})
|
||||||
|
|
||||||
|
await sleep(1 * 1000)
|
||||||
|
|
||||||
|
this.loading = false
|
||||||
|
|
||||||
|
openFloatControl(toRaw(this.row))
|
||||||
|
|
||||||
|
await recording
|
||||||
|
|
||||||
|
await this.handleSuccess(savePath)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error('record.args', args)
|
||||||
|
console.error('record.error', error)
|
||||||
|
|
||||||
|
if (error.message) {
|
||||||
|
this.$message.warning(error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onStdout() {},
|
||||||
|
onStderr() {},
|
||||||
|
getRecordPath(row) {
|
||||||
|
const config = this.$store.preference.getData(row.id)
|
||||||
|
const basePath = config.savePath
|
||||||
|
const extension = config['--record-format'] || 'mp4'
|
||||||
|
|
||||||
|
const fileName = this.$store.device.getLabel(
|
||||||
|
row,
|
||||||
|
({ time }) => `record-${time}.${extension}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
const joinValue = this.$path.join(basePath, fileName)
|
||||||
|
const value = this.$path.normalize(joinValue)
|
||||||
|
|
||||||
|
return value
|
||||||
|
},
|
||||||
|
async handleSuccess(savePath) {
|
||||||
|
return this.$message.success(
|
||||||
|
`${this.$t('device.record.success.title')}: ${savePath}`,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
@ -38,16 +38,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Camera from './components/Camera/index.vue'
|
|
||||||
import Custom from './components/Custom/index.vue'
|
|
||||||
import Otg from './components/Otg/index.vue'
|
|
||||||
import Record from './components/Record/index.vue'
|
import Record from './components/Record/index.vue'
|
||||||
|
import Camera from './components/Camera/index.vue'
|
||||||
|
import RecordCamera from './components/RecordCamera/index.vue'
|
||||||
|
import Otg from './components/Otg/index.vue'
|
||||||
|
import Custom from './components/Custom/index.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Record,
|
Record,
|
||||||
Otg,
|
|
||||||
Camera,
|
Camera,
|
||||||
|
RecordCamera,
|
||||||
|
Otg,
|
||||||
Custom,
|
Custom,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -63,14 +65,18 @@ export default {
|
|||||||
label: 'device.actions.more.record.name',
|
label: 'device.actions.more.record.name',
|
||||||
component: 'Record',
|
component: 'Record',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'device.actions.more.otg.name',
|
|
||||||
component: 'Otg',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'device.actions.more.camera.name',
|
label: 'device.actions.more.camera.name',
|
||||||
component: 'Camera',
|
component: 'Camera',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'device.actions.more.recordCamera.name',
|
||||||
|
component: 'RecordCamera',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'device.actions.more.otg.name',
|
||||||
|
component: 'Otg',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'device.actions.more.custom.name',
|
label: 'device.actions.more.custom.name',
|
||||||
component: 'Custom',
|
component: 'Custom',
|
||||||
|
@ -160,7 +160,7 @@ function handleReset(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function generateCommand() {
|
async function generateCommand() {
|
||||||
const value = await preferenceStore.getScrcpyArgs(preferenceData.value, {
|
const value = await preferenceStore.scrcpyParameter(preferenceData.value, {
|
||||||
isRecord: true,
|
isRecord: true,
|
||||||
isCamera: true,
|
isCamera: true,
|
||||||
isOtg: true,
|
isOtg: true,
|
||||||
|
@ -173,6 +173,7 @@ export default {
|
|||||||
|
|
||||||
handleSave() {
|
handleSave() {
|
||||||
this.preferenceStore.setData(this.preferenceData)
|
this.preferenceStore.setData(this.preferenceData)
|
||||||
|
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('preferences.config.save.placeholder'),
|
message: this.$t('preferences.config.save.placeholder'),
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -127,8 +127,9 @@
|
|||||||
"device.record.success.message": "Open record location?",
|
"device.record.success.message": "Open record location?",
|
||||||
"device.actions.more.name": "More Operation",
|
"device.actions.more.name": "More Operation",
|
||||||
"device.actions.more.record.name": "Start Recording",
|
"device.actions.more.record.name": "Start Recording",
|
||||||
"device.actions.more.otg.name": "Startup OTG",
|
|
||||||
"device.actions.more.camera.name": "Startup Camera",
|
"device.actions.more.camera.name": "Startup Camera",
|
||||||
|
"device.actions.more.recordCamera.name": "Record Camera",
|
||||||
|
"device.actions.more.otg.name": "Startup OTG",
|
||||||
"device.actions.more.custom.name": "Custom Startup",
|
"device.actions.more.custom.name": "Custom Startup",
|
||||||
|
|
||||||
"device.control.name": "Control",
|
"device.control.name": "Control",
|
||||||
|
@ -127,8 +127,9 @@
|
|||||||
"device.record.success.message": "Открыть место сохранения записи?",
|
"device.record.success.message": "Открыть место сохранения записи?",
|
||||||
"device.actions.more.name": "Дополнительные действия",
|
"device.actions.more.name": "Дополнительные действия",
|
||||||
"device.actions.more.record.name": "Начать запись",
|
"device.actions.more.record.name": "Начать запись",
|
||||||
|
"device.actions.more.camera.name": "Запустить камеры",
|
||||||
|
"device.actions.more.recordCamera.name": "Запись камеры",
|
||||||
"device.actions.more.otg.name": "Запустить OTG",
|
"device.actions.more.otg.name": "Запустить OTG",
|
||||||
"device.actions.more.camera.name": "Запустить камеру",
|
|
||||||
"device.actions.more.custom.name": "Пользовательский запуск",
|
"device.actions.more.custom.name": "Пользовательский запуск",
|
||||||
|
|
||||||
"device.control.name": "Управление",
|
"device.control.name": "Управление",
|
||||||
|
@ -127,8 +127,9 @@
|
|||||||
"device.record.success.message": "是否前往录制位置进行查看?",
|
"device.record.success.message": "是否前往录制位置进行查看?",
|
||||||
"device.actions.more.name": "更多操作",
|
"device.actions.more.name": "更多操作",
|
||||||
"device.actions.more.record.name": "开始录制",
|
"device.actions.more.record.name": "开始录制",
|
||||||
|
"device.actions.more.camera.name": "启动相机",
|
||||||
|
"device.actions.more.recordCamera.name": "录制相机",
|
||||||
"device.actions.more.otg.name": "启动OTG",
|
"device.actions.more.otg.name": "启动OTG",
|
||||||
"device.actions.more.camera.name": "启动摄像",
|
|
||||||
"device.actions.more.custom.name": "灵活启动",
|
"device.actions.more.custom.name": "灵活启动",
|
||||||
|
|
||||||
"device.control.name": "操作",
|
"device.control.name": "操作",
|
||||||
|
@ -127,8 +127,9 @@
|
|||||||
"device.record.success.message": "是否前往錄製位置進行檢視?",
|
"device.record.success.message": "是否前往錄製位置進行檢視?",
|
||||||
"device.actions.more.name": "更多操作",
|
"device.actions.more.name": "更多操作",
|
||||||
"device.actions.more.record.name": "開始錄製",
|
"device.actions.more.record.name": "開始錄製",
|
||||||
"device.actions.more.otg.name": "啟動 OTG",
|
|
||||||
"device.actions.more.camera.name": "啟動鏡頭",
|
"device.actions.more.camera.name": "啟動鏡頭",
|
||||||
|
"device.actions.more.recordCamera.name": "錄製鏡頭",
|
||||||
|
"device.actions.more.otg.name": "啟動 OTG",
|
||||||
"device.actions.more.custom.name": "靈活啟動",
|
"device.actions.more.custom.name": "靈活啟動",
|
||||||
|
|
||||||
"device.control.name": "操作",
|
"device.control.name": "操作",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user