Better device picker
This commit is contained in:
parent
5fee511315
commit
a37faec700
23
record.ts
23
record.ts
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env -S ts-node-esm --compilerOptions='{"module": "es2022"}'
|
||||
|
||||
$.verbose = false;
|
||||
$.verbose = true;
|
||||
|
||||
import { $ } from "zx";
|
||||
// Or
|
||||
|
@ -15,10 +15,23 @@ function sleep(time: number) {
|
|||
}
|
||||
|
||||
void (async function () {
|
||||
const pick_device =
|
||||
await $`ls -1 /dev/video* | xargs -I {} bash -c "v4l2-ctl --device {} --info | grep --extended-regexp \\"(Model|Card type)\\" | awk -F: '{print \\$2}' | awk '{print \"{}\" \",\" \\$0}' | tr , '\n'" | zenity --list --column=device --column=name`;
|
||||
|
||||
const dev = `/dev/video${pick_device.stdout.split(" ")[0]}`;
|
||||
const device_ids = (await $`ls -1 /dev/video*`).stdout
|
||||
.split("\n")
|
||||
.slice(0, -1);
|
||||
const device_names = await Promise.all(
|
||||
device_ids.map(async (device_id) => {
|
||||
return (
|
||||
await $`v4l2-ctl --device ${device_id} --info | grep --extended-regexp "(Model|Card type)" | head -n 1 | cut -d: -f2`
|
||||
).stdout.replace("\n", "");
|
||||
})
|
||||
);
|
||||
let zenity_args = "";
|
||||
for (let i in device_ids) {
|
||||
zenity_args += device_ids[i] + "\n" + device_names[i] + "\n";
|
||||
}
|
||||
const dev = (
|
||||
await $`echo ${zenity_args} | zenity --list --column=device --column=name`
|
||||
).stdout.replace("\n", "");
|
||||
|
||||
const source = spawn("ffmpeg", [
|
||||
"-f",
|
||||
|
|
Loading…
Reference in New Issue
Block a user