Script ui-test scenes
This commit is contained in:
@@ -94,6 +94,7 @@
|
|||||||
"electron-log": "^2.2.17",
|
"electron-log": "^2.2.17",
|
||||||
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist",
|
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git#dist",
|
||||||
"electron-updater": "^4.0.6",
|
"electron-updater": "^4.0.6",
|
||||||
|
"ffmpeg-concat": "^1.0.13",
|
||||||
"js-base64": "^2.5.1",
|
"js-base64": "^2.5.1",
|
||||||
"lowdb": "^1.0.0",
|
"lowdb": "^1.0.0",
|
||||||
"mqtt": "^2.18.8",
|
"mqtt": "^2.18.8",
|
||||||
|
|||||||
56
scripts/cutScenes.ts
Executable file
56
scripts/cutScenes.ts
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!./node_modules/.bin/ts-node
|
||||||
|
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import { Scene, SceneNames } from '../src/spec/SceneBuilder'
|
||||||
|
import { exec } from './util'
|
||||||
|
const concat = require('ffmpeg-concat')
|
||||||
|
|
||||||
|
async function cutScenes(scenes: Array<Scene>) {
|
||||||
|
for (const scene of scenes) {
|
||||||
|
const outputFile = `${scene.name}.mp4`
|
||||||
|
if (fs.existsSync(outputFile)) {
|
||||||
|
fs.unlinkSync(outputFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
await exec('ffmpeg', `-i app2.mp4 -ss ${scene.start / 1000} -t ${scene.duration / 1000} ${scene.name}.mp4`.split(' '))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Transistions = 'none' | 'pixelize' | 'cube' | 'directionalWarp' | 'hexagonalize'
|
||||||
|
|
||||||
|
class TransitionBuilder {
|
||||||
|
private scenes: Array<string> = []
|
||||||
|
private transitions: Array<string> = []
|
||||||
|
|
||||||
|
public startWith(scene: SceneNames): TransitionBuilder {
|
||||||
|
this.scenes.push(scene)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
public transitionTo(scene: SceneNames, transition: Transistions): TransitionBuilder {
|
||||||
|
this.scenes.push(scene)
|
||||||
|
this.transitions.push(transition)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
public buildOptions(outputFile: string) {
|
||||||
|
return {
|
||||||
|
output: outputFile,
|
||||||
|
videos: this.scenes.map(s => `${s}.mp4`),
|
||||||
|
transistions: this.transitions.map(name => ({
|
||||||
|
name: name !== 'none' ? name : 'fade',
|
||||||
|
duration: name !== 'none' ? 1000 : 10,
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// const scenes: Array<Scene> = JSON.parse(fs.readFileSync('./scenes.json').toString())
|
||||||
|
// cutScenes(scenes)
|
||||||
|
let builder = new TransitionBuilder()
|
||||||
|
.startWith('connect')
|
||||||
|
.transitionTo('numeric_plots', 'cube')
|
||||||
|
.transitionTo('diffs', 'pixelize')
|
||||||
|
.transitionTo('customize_subscriptions', 'hexagonalize')
|
||||||
|
|
||||||
|
concat(builder.buildOptions('test.mp4'))
|
||||||
@@ -1,15 +1,30 @@
|
|||||||
export interface Scene {
|
export interface Scene {
|
||||||
name: string,
|
name: SceneNames,
|
||||||
start: number
|
start: number
|
||||||
stop: number
|
stop: number
|
||||||
duration: number
|
duration: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SceneNames = 'connect'
|
||||||
|
| 'topic_updates'
|
||||||
|
| 'numeric_plots'
|
||||||
|
| 'json-formatting'
|
||||||
|
| 'diffs'
|
||||||
|
| 'publish_topic'
|
||||||
|
| 'json_formatting_publish'
|
||||||
|
| 'clipboard'
|
||||||
|
| 'topic_filter'
|
||||||
|
| 'delete_retained_topics'
|
||||||
|
| 'settings'
|
||||||
|
| 'customize_subscriptions'
|
||||||
|
| 'keyboard_shortcuts'
|
||||||
|
| 'end'
|
||||||
|
|
||||||
export class SceneBuilder {
|
export class SceneBuilder {
|
||||||
public scenes: Array<Scene> = []
|
public scenes: Array<Scene> = []
|
||||||
public offset = Date.now()
|
public offset = Date.now()
|
||||||
|
|
||||||
public async record(name: string, callback: () => Promise<any>): Promise<any> {
|
public async record(name: SceneNames, callback: () => Promise<any>): Promise<any> {
|
||||||
const start = Date.now() - this.offset
|
const start = Date.now() - this.offset
|
||||||
await callback()
|
await callback()
|
||||||
const stop = Date.now() - this.offset
|
const stop = Date.now() - this.offset
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ async function doStuff() {
|
|||||||
// Wait for Username input to be visible
|
// Wait for Username input to be visible
|
||||||
await browser.$(`//label[contains(text(), "Username")]/..//input`)
|
await browser.$(`//label[contains(text(), "Username")]/..//input`)
|
||||||
const scenes = new SceneBuilder()
|
const scenes = new SceneBuilder()
|
||||||
|
|
||||||
await scenes.record('connect', async () => {
|
await scenes.record('connect', async () => {
|
||||||
await connectTo('127.0.0.1', browser)
|
await connectTo('127.0.0.1', browser)
|
||||||
await sleep(2000)
|
await sleep(2000)
|
||||||
|
|||||||
Reference in New Issue
Block a user