Repository: joelpurra/uvcc
Branch: develop
Commit: f38eda4f32d3
Files: 73
Total size: 144.4 KB
Directory structure:
gitextract_7tuha_tf/
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .prettierignore
├── .xo-config.cjs
├── CHANGELOG.md
├── DEVELOP.md
├── LICENSE
├── README.md
├── USAGE.md
├── examples/
│ ├── README.md
│ ├── elgato-facecam/
│ │ └── 4057-120/
│ │ ├── controls.json
│ │ ├── devices.json
│ │ ├── export.json
│ │ ├── metadata.json
│ │ └── ranges.json
│ ├── logitech-c920/
│ │ └── 1133-2093/
│ │ ├── controls.json
│ │ ├── demo/
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── auto.json
│ │ │ ├── cold.json
│ │ │ ├── crazy.json
│ │ │ ├── record-demo.sh
│ │ │ └── warm.json
│ │ ├── devices.json
│ │ ├── export.json
│ │ ├── metadata.json
│ │ └── ranges.json
│ ├── logitech-c922/
│ │ └── 1133-2140/
│ │ ├── controls.json
│ │ ├── devices.json
│ │ ├── export.json
│ │ ├── metadata.json
│ │ └── ranges.json
│ ├── microsoft-1425/
│ │ ├── 1118-1906/
│ │ │ ├── controls.json
│ │ │ ├── devices.json
│ │ │ ├── export.json
│ │ │ ├── metadata.json
│ │ │ └── ranges.json
│ │ └── 1118-2065/
│ │ ├── controls.json
│ │ ├── devices.json
│ │ ├── export.json
│ │ ├── metadata.json
│ │ └── ranges.json
│ └── update-example.sh
├── package.json
├── src/
│ ├── camera-control-helper-factory.ts
│ ├── camera-control-helper.ts
│ ├── camera-factory.ts
│ ├── camera-helper-factory.ts
│ ├── camera-helper.ts
│ ├── command-handlers/
│ │ ├── controls.ts
│ │ ├── devices.ts
│ │ ├── export.ts
│ │ ├── get.ts
│ │ ├── import.ts
│ │ ├── range.ts
│ │ ├── ranges.ts
│ │ └── set.ts
│ ├── command-handlers.ts
│ ├── command-manager.ts
│ ├── index.ts
│ ├── output.ts
│ ├── runtime-configurator.ts
│ ├── types/
│ │ ├── command.ts
│ │ ├── controls.ts
│ │ └── uvc-control.d.ts
│ ├── utilities/
│ │ ├── flatten-control-values.ts
│ │ ├── is-uvcc-control-value.ts
│ │ ├── is-uvcc-controls.ts
│ │ ├── to-formatted-hex.ts
│ │ └── wrapped-error.ts
│ └── uvc-device-lister.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[*.{json,md}]
indent_size = 2
indent_style = space
[*.md]
trim_trailing_whitespace = false
================================================
FILE: .gitattributes
================================================
* text=auto eol=lf
================================================
FILE: .gitignore
================================================
dist/
node_modules/
.uvccrc
.uvccrc.json
================================================
FILE: .prettierignore
================================================
dist/
examples/**/*.json
================================================
FILE: .xo-config.cjs
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = {
extends: [
"eslint-config-joelpurra/typescript",
],
};
================================================
FILE: CHANGELOG.md
================================================
# [`uvcc`](https://joelpurra.com/projects/uvcc/) changelog
See [full list of commits](https://github.com/joelpurra/uvcc/commits) for details.
## v7.0.0
- 8779b90 Target Node.js v16, v18, v19, v20
- Drop v14 (about two months early), drop v17 (about eight months late), add v19 (about four months late), add v20 (about two months early).
- 61d8071 Add example output from Elgato Facecam ([4057:0120](./examples/elgato-facecam/4057-120/)) (#28 by @m0ose)
## v6.0.0
- 3a79c54 Add example output from Logitech C922 Pro Stream Webcam ([1133:2140](./examples/logitech-c922/1133-2140/))
- 9342420 Add example output from Microsoft LifeCam Studio Model 1425 ([1118:2065](./examples/microsoft-1425/1118-2065/)) (#17 by @holbrookdev)
- aebbe71 Update example output from Logitech C920 ([1133:2093](./examples/logitech-c920/1133-2093/))
- 235fe37 Take vendor/product ids into account for examples
- Relates to [#21](https://github.com/joelpurra/uvcc/issues/21), where the differences between hardware variations within the same camera "marketing name" are discussed.
- 999c7d5 Upgrade forked uvc-control v2
- [Targets `node-usb` ^v2.4.1](https://github.com/node-usb/node-usb/releases/tag/v2.4.1) via [the forked `node-uvc-control` v2](https://github.com/joelpurra/node-uvc-control/commits/v2) at [`267b0db`](https://github.com/joelpurra/node-uvc-control/commit/267b0dbe77636e15e69cfb8f3de310641fac72b5).
- Still uses the legacy USB device interface.
- e5e9748 Target Node.js v14, v16, v17, v18
- These are the available [current/active/maintenance releases](https://github.com/nodejs/Release) as of 2022-05-12.
- Fixes [#25](https://github.com/joelpurra/uvcc/issues/25).
## v5.0.2
- 7cc2775 Upgrade [forked uvc-control v2](https://github.com/joelpurra/node-uvc-control)
- [Pins `node-usb` to v1.9.2](https://github.com/node-usb/node-usb/releases/tag/v1.9.2) via [the forked `node-uvc-control` v2](https://github.com/joelpurra/node-uvc-control/commit/v2).
- Includes an [upstream fix in `node-usb`](https://github.com/node-usb/node-usb/pull/460) for the `uvcc` program exit delay.
- Should fix [#20](https://github.com/joelpurra/uvcc/issues/20) and [#22](https://github.com/joelpurra/uvcc/issues/22).
## v5.0.1
- 3c171b1 Upgrade package-lock.json
- Includes [pinning `node-usb` to v1.8.0](https://github.com/node-usb/node-usb/releases/tag/v1.8.0) via [the forked `node-uvc-control` v2](https://github.com/joelpurra/node-uvc-control/commit/d87e551f95d281e6a32f6ad4b379bc7e81ff6273).
- Should fix [#19 package errors after node/npm upgrade](https://github.com/joelpurra/uvcc/issues/19).
## v5.0.0
- a2bab40 Target Node.js v12, v14, v16, v17
- Fixes [#18](https://github.com/joelpurra/uvcc/issues/18).
- ebea941 Upgrade package-lock.json
- Includes an upgrade to [`node-usb` v1.8.0](https://github.com/node-usb/node-usb/releases/tag/v1.8.0) via [the forked `node-uvc-control` v2](https://github.com/joelpurra/node-uvc-control/commit/42d1c526719f064a5bd4edfeab457a81687f69aa), which breaks [#16](https://github.com/joelpurra/uvcc/issues/16) (delay at program exit) again.
- The alternative is that `uvcc` doesn't work at all on the [current Node.js v17](https://github.com/nodejs/Release).
- See also [node-usb/node-usb#418](https://github.com/node-usb/node-usb/issues/418).
- Other dependencies also upgraded.
## v4.0.1
- ccf5e05 Fix `--version` flag
## v4.0.0
- 77757f0 Switch to ESM
- Modernizes code to use [Node.js ECMAScript modules](https://nodejs.org/api/esm.html).
- Targets [current stable Node.js versions](https://github.com/nodejs/Release) (basically v12, v14, v16) which have ESM support.
## v3.0.1
- 08eb9fe Run npm update
- Includes fix in [joelpurra/node-uvc-control@8c5f5f4](https://github.com/joelpurra/node-uvc-control/commit/8c5f5f41389bb6a8b4b243115ab92892d633cb55) for [#16](https://github.com/joelpurra/uvcc/issues/16), pin `node-usb` to v1.6.5 due to long delay due when using v1.7.0.
- b0ad267 Add npm run debug
## v3.0.0
- e8d7dec Target node.js v12+
- efde45e Update example output from Logitech C920
- bed8ac3 Upgrade forked uvc-control v2
- Swallows errors when discovering/listing USB/UVC devices.
- Avoids some problems with `LIBUSB_ERROR_IO` when using `uvcc devices`. The issue seems to be dependent on the internal (software) state (perhaps the traversal order) of USB drivers/devices (and perhaps on _which_ other USB devices are used) connected to the system. Using `sudo` does not prevent `LIBUSB_ERROR_IO`.
- The change means that `uvcc devices` can be used without `sudo` (by swallowing `LIBUSB_ERROR_ACCESS` thrown when opening some USB devices) even when the user has insufficient privileges, although inaccessible UVC devices will not be listed.
- e5d9f49 Warn for camera mismatch
- Fixes part of [#10](https://github.com/joelpurra/uvcc/issues/10) by warning for unexpected camera results.
- 526b9f4 Upgrade forked uvc-control v2
- Fixes part of [#10](https://github.com/joelpurra/uvcc/issues/10) by allowing filtering by only product id, or only by device address.
- 7a9dd89 Add some styling to command help
- 4691cbf Update usage examples
- Fixes [#14](https://github.com/joelpurra/uvcc/issues/14) by improving examples.
## v2.0.4
- 9f3073e Upgrade forked uvc-control v2
- Fixes [#8](https://github.com/joelpurra/uvcc/issues/8), setting `absolute_focus`.
## v2.0.3
- d34da77 Upgrade forked uvc-control v2
- Fixes [#6](https://github.com/joelpurra/uvcc/issues/6), setting `absolute_exposure_time`.
## v2.0.2
- 8c24f19 Add compatible cameras and help wanted notes
## v2.0.1
- ff28515 Fix broken anchor tag in README.md
## v2.0.0
### ⚠ Breaking changes
- Camera controls changed name in the upstream `uvc-control` v2, so old exports won't import without edits.
- Most changes are from camel-case `someCameraControl` to snake-case `some_camera_control`, for example `autoExposureMode` to `auto_exposure_mode`.
- Other controls changed name a bit more, such as `autoWhiteBalance` to `auto_white_balance_temperature`.
- See `uvcc controls` for your camera.
### Features
- Uses forked `uvc-control` v2, as breaking bug fixes were not reviewed (not commented, accepted, nor rejected) in time for this release ([uvc-control#64](https://github.com/makenai/node-uvc-control/pull/64)).
- If the equivalent changes are made, `uvcc` can go back to using the upstream.
- Below feature changes are a mix of changes in `uvc-control` and `uvcc`.
- Should support additional cameras and camera controls by `uvc-control` dynamically mapping camera controls.
- Both `uvc-control` and `uvcc` were developed testing (only?) against Logitech C920 cameras.
- Several users tested previews/manual patches using other cameras ([#4](https://github.com/joelpurra/uvcc/issues/4)).
- Further changes have only been confirmed using Logitech C920.
- If a UVC camera is available, it will be autodetected by `uvc-control` using `node-usb`.
- Most users will not need to run `uvcc devices` to find and configure their camera.
- Uses the "first" camera, which may depend on the system, drivers, and in which port the cameras are plugged in.
- If necessary, the vendor/product can still be configured as before.
- If multiple cameras with the same vendor/product are available, it is possible to distinguish between them using `--address`.
- Can also be configured using environment variables or configuration files.
- See output from `uvcc devices`.
- Should work on Linux, by changing how `uvc-control` targets the USB device ([uvc-control#58](https://github.com/makenai/node-uvc-control/issues/58)).
- Might need to use `sudo uvcc devices` to access and filter the full list of USB devices.
- Might need to set up userspace `/dev` (`udev`) rules or equivalent to further get/set camera control values.
### Other changes
- d6b4700 Add example output from Logitech C920
- 80848a6 Make device address configurable
- 97a34d0 Make vendor/product ids optional
- 7b334fa Fix devices command
- b6c191f Target uvc-control v2
## v1.0.2
- 51e824c Add `find-up`
## v1.0.1
- a4eb66f Use file-relative path to file in the `uvc-control` package
## v1.0.0
- 047980e Initial public release
- Thanks you [Pawel Szymczykowski](http://twitter.com/makenai) for [uvc-control](https://github.com/makenai/node-uvc-control) for node.js. Without his code I would never have gotten close to automating — or perhaps even being _able_ to — changing camera controls on macOS.
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: DEVELOP.md
================================================
# [`uvcc`](https://joelpurra.com/projects/uvcc/) development
Get the source code from the [`uvcc` repository](https://github.com/joelpurra/uvcc).
Follow [git-flow](https://danielkummer.github.io/git-flow-cheatsheet/) and use [git-flow-avh](https://github.com/petervanderdoes/gitflow-avh).
```shell
# Make sure git-flow is initialized.
git flow init -d
# Fetch dependencies.
npm install
# Get a fresh local build.
npm run --silent rebuild
# Make sure tests pass.
npm run --silent test
# Try some commands on your local build.
node ./dist/index.js
node ./dist/index.js controls
node ./dist/index.js ranges
node ./dist/index.js export
node ./dist/index.js get absolute_zoom
node ./dist/index.js set absolute_zoom 120
# Start debugging.
# Use the Node.js inspector built-in to Chromium-based browsers.
npm run --silent debug:run:break
# Use -- to separate the npm command from uvcc arguments.
npm run --silent debug:run:break -- export
```
## Todo
- Check [open issues and pull requests](https://github.com/joelpurra/uvcc/issues?q=is%3Aopen) and see what can be done.
- Add tests.
- Add output examples from additional camera models.
- Perhaps create and record a demo video/gif for that model.
- Add workarounds for cameras with known issues.
- Some cameras are known to have issues in other implementations.
- Avoid camera- or system-specific workarounds, try to be generic in their detection and prevention.
- See [Linux UVC device drivers](https://www.ideasonboard.org/uvc/)'s supported devices list for examples.
- Compare UVC controls/values with the output from [`v4l2-ctl`](https://www.mankier.com/1/v4l2-ctl).
- `v4l2-ctl --list-devices`
- `v4l2-ctl --list-ctrls`
- See for example the article [Manual USB camera settings in Linux](http://kurokesu.com/main/2016/01/16/manual-usb-camera-settings-in-linux/).
## See also
- The lower-level UVC Node.js library [uvc-control](https://github.com/makenai/node-uvc-control) used by `uvcc`.
- The even lower level library [`libusb`](http://libusb.info/) ([Wikipedia](https://en.wikipedia.org/wiki/Libusb)) through the [npm package `usb`](https://www.npmjs.com/package/usb).
- The [`v4l-utils`](https://linuxtv.org/wiki/index.php/V4l-utils) for [video4linux](https://www.linuxtv.org) ([Wikipedia](https://en.wikipedia.org/wiki/Video4Linux)), which includes [`v4l2-ctl`](https://www.mankier.com/1/v4l2-ctl).
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
================================================
FILE: README.md
================================================
<p align="center">
<a href="https://files.joelpurra.com/projects/uvcc/demo/2020-09-02/uvcc-demo.2020-09-02.mp4"><img src="https://files.joelpurra.com/projects/uvcc/demo/2020-09-02/uvcc-demo.2020-09-02.gif" alt="uvcc demo video showing rubber ducks and a candle with varying camera settings" width="480" height="270" border="0" /></a>
</p>
<h1 align="center">
<a href="https://joelpurra.com/projects/uvcc/">uvcc</a>
</h1>
<p align="center">
<a href="https://en.wikipedia.org/wiki/USB_video_device_class">USB Video Class</a> (UVC) device configurator
</p>
## Overview
- Fine-tune camera controls on the fly, such as brightness, contrast, saturation, gain, white balance/color temperature, zoom.
- Export/import of settings makes it easy to reliably configure one or more cameras for various situations.
- Command line interface (CLI) with JSON input/output for automation and repeatability.
## Compatible cameras
- [Elgato Facecam](https://www.elgato.com/facecam) ([4057:0120](./examples/elgato-facecam/4057-120/))
- [Logitech C920 HD Pro Webcam](https://www.logitech.com/en-us/products/webcams/c920s-pro-hd-webcam.html) ([1133:2093](./examples/logitech-c920/1133-2093/))
- [Logitech C922 Pro Stream Webcam](https://www.logitech.com/en-us/products/webcams/c922-pro-stream-webcam.html) ([1133:2140](./examples/logitech-c922/1133-2140/))
- [Microsoft LifeCam Studio](https://www.microsoft.com/en-WW/accessories/products/webcams/lifecam-studio) Model 1425 ([1118:1906](./examples/microsoft-1425/1118-1906/), [1118:2065](./examples/microsoft-1425/1118-2065/))
- Hopefully other [UVC-compatible webcams and digital camcorders](https://en.wikipedia.org/wiki/List_of_USB_video_class_devices).
### Do you have another UVC-compatible camera?
- Add it to the [`./examples/`](./examples/).
- Is it not working?
- [Report an issue.](https://github.com/joelpurra/uvcc/issues?q=is%3Aopen)
- [Help fix the source code!](./DEVELOP.md)
## Installation
Requires [Node.js](https://nodejs.org/) (`node` and `npm` commands). Published on npm as [`uvcc`](https://www.npmjs.com/package/uvcc).
```shell
npm install --global uvcc
```
Or use [`npx`](https://www.npmjs.com/package/npx) to execute with `npx uvcc`.
On Linux, you may need to [change device access permissions](./USAGE.md#linux).
## Features
- List available UVC cameras and camera controls.
- Get/set individual camera controls.
- Export/import full JSON control snapshots using `stdout`/`stdin`.
- Per-user/per-directory/custom configuration files to handle multiple cameras.
## Short usage example
First start a program which shows a camera preview, such as Photo Booth on macOS or Cheese on Linux.
```shell
# Display commands and options.
uvcc --help
# Export current configuration. You can save it to a file, modify, and import later.
uvcc export
# Turn off automatic white balance to manually set the white balance.
uvcc set auto_white_balance_temperature 0
# Set the white balance temperature to 2000.
# NOTE: the white_balance_temperature range for Logitech C920 is 2000-6500.
uvcc set white_balance_temperature 2000
# Set the contrast to 192.
# NOTE: the contrast range for Logitech C920 is 0-255, default value 128.
uvcc set contrast 192
```
## See also
- Further help and configuration in [USAGE.md](./USAGE.md).
- The [./examples/](./examples/) directory for some sample output.
- The [CHANGELOG.md](./CHANGELOG.md), in particular for breaking changes.
- Read [DEVELOP.md](./DEVELOP.md) to submit a patch or add your camera output to the examples.
- [USB Video Class](https://en.wikipedia.org/wiki/USB_video_device_class) and [list of USB video class devices](https://en.wikipedia.org/wiki/List_of_USB_video_class_devices) on Wikipedia.
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: USAGE.md
================================================
# [`uvcc`](https://joelpurra.com/projects/uvcc/) usage
By default, the first detected UVC camera will be used. See [configuration](#configuration) to target a specific camera. Note that [many cameras are not UVC-compatible](https://en.wikipedia.org/wiki/List_of_USB_video_class_devices).
```shell
uvcc --help
```
```text
uvcc: USB Video Class (UVC) device configurator for the command line (CLI). Used for webcams, camcorders, etcetera.
Commands:
uvcc get <control> Get current control value.
uvcc set <control> <value1> [value2] Set control value(s).
uvcc range <control> Get possible range (min and max) for a control.
uvcc ranges Get all ranges (min and max).
uvcc devices List connected UVC devices.
uvcc controls List all supported controls for the camera.
uvcc export Output configuration in JSON format, on stdout.
uvcc import Input configuration in JSON format, from stdin.
Device selection for multi-camera setups.
Numbers in hex (0x000) or decimal (0000) format.
--vendor Camera vendor id (vId). [number] [default: 0]
--product Camera product id (pId). [number] [default: 0]
--address Camera device address. [number] [default: 0]
Options:
--version Show version number [boolean]
--config Load command arguments from a JSON file.
--verbose Enable verbose output. [boolean] [default: false]
--help Show help [boolean]
Examples:
Basic usage:
uvcc controls Available controls for the camera.
uvcc set auto_white_balance_temperature 0 Turn off automatic color correction.
uvcc set saturation 64 Low color saturation (near grayscale).
uvcc ranges List possible control ranges.
uvcc set absolute_zoom 200 Zoom in.
Automate config:
- Not all controls can be imported.
- Control order matters.
uvcc export > my-uvcc-export.json Save to file.
cat my-uvcc-export.json | uvcc import Load from file.
Target a specific device:
- Only useful for multi-camera setups.
- For same-model cameras, also specify address.
- Alt. use system USB settings to find devices.
uvcc devices List available cameras.
sudo uvcc devices Avoid LIBUSB_ERROR_ACCESS.
uvcc --vendor 0x46d --product 0x82d export
uvcc Copyright © 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it
under certain conditions. See GPL-3.0 license for details.
See also: https://joelpurra.com/projects/uvcc/
```
## Configuration
The command line arguments can optionally be provided using environment variables, implicit per-user/per-directory configuration files, or explicitly loaded from JSON files.
### Command line
```shell
# Find your UVC device, note the vendor id (vId) and product id (pId).
# The ids can be in hexadecimal (0x000) or decimal (0000) format.
# Example:
# - The vendor is Logitech (hexadecimal 0x46d, or decimal 1133).
# - The product is C920 HD Pro Webcam (hexadecimal 0x82d, or decimal 2093).
# NOTE: listing USB devices might require root (sudo) on some systems.
uvcc devices
# Use the vendor id and product id to export current configuration.
# NOTE: explicitly defining vendor/product is usually not necessary.
uvcc --vendor 0x46d --product 0x82d export
```
### Environment variables
Set `UVCC_<argument name>`.
```shell
UVCC_VERBOSE=true uvcc controls
```
### Configuration file format
Configuration files for `uvcc` are in JSON format. If you configure the same camera each time, it is convenient to put `vendor` and `product` in the configuration file.
```json
{
"vendor": 1133,
"product": 2093
}
```
### Implicit configuration file
You can put any command line arguments as properties in a JSON file called either `.uvccrc` or `.uvccrc.json`. The file is loaded from the same directory as `uvcc` is executed in, or the nearest parent directory where it can be found. A convenient location might be your `$HOME` directory.
### Explicit configuration file
Instead of passing command line arguments one by one, an explicit configuration file can be used. Explicitly defining a configuration file will prevent loading of the implicit configuration files.
```shell
uvcc --config <my-uvcc-config.json>
```
## Examples
See additional output examples in [./examples/](./examples/).
### Exported configuration
- Save the exported JSON data to a file as a snapshot of the current camera settings using `uvcc export > my-export.json`.
- The export format is made to be imported again using `cat my-export.json | uvcc import`.
- Note that some values are read-only, and are thus not exported.
- Note that the order of the imported values matters, as for example automatic white balance needs to be turned off before setting a custom white balance.
```shell
uvcc export
```
```json
{
"absolute_pan_tilt": 0,
"absolute_zoom": 100,
"auto_exposure_mode": 8,
"auto_exposure_priority": 1,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"backlight_compensation": 0,
"brightness": 128,
"contrast": 128,
"gain": 28,
"power_line_frequency": 2,
"saturation": 128,
"sharpness": 128,
"white_balance_temperature": 4675
}
```
## System-specific details
### Linux
User access to hardware devices, such as USB cameras, may be restricted by default on Linux. If, for example, `sudo uvcc devices` lists your camera but `uvcc devices` (without `sudo`) does not, then for ease-of-use you may adjust the device access level.
Below [userspace `/dev`](https://en.wikipedia.org/wiki/Udev) (`udev`) is used to change the access level for a specific device model. Note that relaxing the access level in this way reduces device security.
1. Find your camera model's vendor and product id using, for example, [`lsusb`](https://en.wikipedia.org/wiki/Lspci#lsusb).
```shell
lsusb
```
Example output for Logitech (vendor id `046d`) C920 HD Pro Webcam (product id `082d`).
```shell
Bus 005 Device 013: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
```
1. Create a new `udev` rules file for your UVC camera using your favorite text editor.
```shell
sudo nano /etc/udev/rules.d/90-uvc-camera.rules
```
1. Add one line for your device by vendor and product id, replacing `046d` and `082d` with the ids for your camera.
```text
SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="082d", TAG+="uaccess"
```
If you have more than one camera model, just add more lines.
1. Reload the device rules files after editing, and apply the changes.
```shell
sudo udevadm control --reload-rules
sudo udevadm trigger --action='change'
```
1. Unplug your camera and plug it back in.
1. Try `uvcc devices` (without `sudo`) and check if your camera is listed.
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: examples/README.md
================================================
# [`uvcc`](https://joelpurra.com/projects/uvcc/) output examples
A small sample of `uvcc` camera control output. See individual subdirectories for specific cameras. Note that [cameras with the same "marketing name" may have several USB hardware implementations with different vendor/product ids](https://github.com/joelpurra/uvcc/issues/21), so there may be more than one subdirectory.
## How to add or update the output from your camera
- Open the terminal.
- Create and/or enter the correct camera product marketing name subdirectory.
- The "marketing name" is the product name (usually including a short codename) you would see on the box when you buy a camera.
- Use [kebab-case](https://en.wikipedia.org/wiki/Kebab_case) naming, with vendor name and product code/name.
- Do not use the full "marketing name", such as "Logitech HD Pro Webcam C920".
- Correct examples:
- [`logitech-c920`](./logitech-c920/) from `Logitech HD Pro Webcam C920` (`name` in `uvcc devices`).
- [`logitech-c922`](./logitech-c922/) from the vendor name and `C922 Pro Stream Webcam` (`name` in `uvcc devices`).
- [`microsoft-1425`](./microsoft-1425/) from the vendor name and the model number `1425` found on the label on the camera cable as well as the box the camera was delivered in.
- Create and/or enter the correct vendor/product id subdirectory.
- This is due to [cameras with the same "marketing name" having different USB product ids](https://github.com/joelpurra/uvcc/issues/21), and this possibly having different hardware properties.
- Use the format `<vendor id>-<product id>` with decimal number formatting, without leading zero padding.
- You can find the USB `vendor` and `product` ids in the output of `uvcc devices`.
- Correct examples:
- [`logitech-c920/1133-2093`](./logitech-c920/1133-2093/)
- [`logitech-c922/1133-2140`](./logitech-c920/1133-2140/)
- [`microsoft-1425/1118-1906`](./microsoft-1425/1118-1906/)
- [`microsoft-1425/1118-2065`](./microsoft-1425/1118-2065/)
- Reset the camera to default values.
- Unplug all cameras.
- Reconnect only the camera you want to test.
- This done to get "fresh" (hopefully default) values for `uvcc export`.
- Run [`../../update-example.sh`](./update-example.sh)
- Verify that the `*.json` files were created/updated.
- Commit your changes and [submit a pull request](https://github.com/joelpurra/uvcc/compare).
## Is it not working?
Not all cameras are [UVC-compatible](https://en.wikipedia.org/wiki/List_of_USB_video_class_devices). If you can confirm that your camera model supports UVC, perhaps `uvcc` needs some fixes to support it.
- [Report the issue](https://github.com/joelpurra/uvcc/issues?q=is%3Aopen) with as much detail as you can.
- [Fix the source code](../DEVELOP.md) directly, since it is much easier debugging with access to the camera itself.
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: examples/elgato-facecam/4057-120/controls.json
================================================
[
"absolute_exposure_time",
"absolute_zoom",
"auto_exposure_mode",
"auto_white_balance_temperature",
"brightness",
"contrast",
"power_line_frequency",
"saturation",
"sharpness",
"white_balance_temperature"
]
================================================
FILE: examples/elgato-facecam/4057-120/devices.json
================================================
[
{
"name": "Elgato Facecam",
"vendor": 4057,
"product": 120,
"address": 5
}
]
================================================
FILE: examples/elgato-facecam/4057-120/export.json
================================================
{
"absolute_exposure_time": 156,
"absolute_zoom": 1,
"auto_exposure_mode": 2,
"auto_white_balance_temperature": 1,
"brightness": 88,
"contrast": 4,
"power_line_frequency": 2,
"saturation": 37,
"sharpness": 3,
"white_balance_temperature": 2800
}
================================================
FILE: examples/elgato-facecam/4057-120/metadata.json
================================================
{
"node": "v18.12.1",
"npm": "8.19.2",
"uname": "Linux dooderson-ThinkPad-T490 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux",
"uvcc": "v6.0.0"
}
================================================
FILE: examples/elgato-facecam/4057-120/ranges.json
================================================
{
"absolute_exposure_time": {
"min": 1,
"max": 2500
},
"absolute_zoom": {
"min": 1,
"max": 31
},
"brightness": {
"min": 0,
"max": 255
},
"contrast": {
"min": 0,
"max": 10
},
"saturation": {
"min": 0,
"max": 63
},
"sharpness": {
"min": 0,
"max": 4
},
"white_balance_temperature": {
"min": 2800,
"max": 12500
}
}
================================================
FILE: examples/logitech-c920/1133-2093/controls.json
================================================
[
"absolute_exposure_time",
"absolute_focus",
"absolute_pan_tilt",
"absolute_zoom",
"auto_exposure_mode",
"auto_exposure_priority",
"auto_focus",
"auto_white_balance_temperature",
"backlight_compensation",
"brightness",
"contrast",
"gain",
"power_line_frequency",
"saturation",
"sharpness",
"white_balance_temperature"
]
================================================
FILE: examples/logitech-c920/1133-2093/demo/.gitignore
================================================
recording/
================================================
FILE: examples/logitech-c920/1133-2093/demo/README.md
================================================
# [`uvcc`](https://joelpurra.com/projects/uvcc/) demo recording
Scripted (repeatable) demo recording showcasing `uvcc` capabilities.
- This is a development tool.
- Requires additional software to function.
- Does not have usage documentation.
- The output is intended for the project `README.md`.
- Written specifically for Logitech C920.
- Uses a mix of imported `*.json` files and direct `uvcc set`.
- Not expected to, but might, work with other cameras.
- Rubber ducks?
- The rubber ducks used in the (initial) demo video are used for [rubber duck debugging](https://en.wikipedia.org/wiki/Rubber_duck_debugging).
- They are also mascots for [joelpurra's stream on Twitch](https://www.twitch.tv/joelpurra).
---
[`uvcc`](https://joelpurra.com/projects/uvcc/) Copyright © 2018, 2019, 2020, 2021, 2022 [Joel Purra](https://joelpurra.com/). Released under [GNU General Public License version 3.0 (GPL-3.0)](https://www.gnu.org/licenses/gpl.html). [Your donations are appreciated!](https://joelpurra.com/donate/)
================================================
FILE: examples/logitech-c920/1133-2093/demo/auto.json
================================================
{
"absolute_pan_tilt": [
0,
0
],
"absolute_zoom": 100,
"auto_exposure_mode": 8,
"auto_exposure_priority": 1,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"brightness": 128,
"contrast": 128,
"gain": 128,
"saturation": 128,
"sharpness": 128
}
================================================
FILE: examples/logitech-c920/1133-2093/demo/cold.json
================================================
{
"auto_white_balance_temperature": 0,
"white_balance_temperature": 2000
}
================================================
FILE: examples/logitech-c920/1133-2093/demo/crazy.json
================================================
{
"absolute_zoom": 500,
"auto_exposure_mode": 1,
"auto_focus": 0,
"auto_white_balance_temperature": 0,
"brightness": 255,
"contrast": 0,
"gain": 255,
"saturation": 255,
"sharpness": 255,
"white_balance_temperature": 2000
}
================================================
FILE: examples/logitech-c920/1133-2093/demo/record-demo.sh
================================================
#!/usr/bin/env bash
set -o errexit
set -o noclobber
set -o nounset
set -o pipefail
function die() {
echo "FATAL:" "$@" >&2
exit 1
}
function changeOverlayTextAsync() {
# NOTE: don't wait for zmqsend, even if it usually is quick.
echo "drawtext reinit 'text=${@}" | zmqsend &
}
[[ -x "$(which node)" ]] || die 'Could not find ffmpeg executable in $PATH.' 'https://nodejs.org/'
[[ -x "$(which ffmpeg)" ]] || die 'Could not find ffmpeg executable in $PATH.' 'https://ffmpeg.org/'
[[ -x "$(which gifski)" ]] || die 'Could not find gifski executable in $PATH.' 'https://gif.ski/'
declare -r SCRIPT_BASE="${BASH_SOURCE%/*}"
declare SCRIPT_BASE_ABSOLUTE
SCRIPT_BASE_ABSOLUTE="$(realpath "$SCRIPT_BASE")"
# NOTE: using the local repository version of uvcc, with any local (even uncommitted) changes.
declare UVCC_INDEX
UVCC_INDEX="$(realpath "${SCRIPT_BASE_ABSOLUTE}/../../../../dist/index.js")"
declare -r UVCC="node -- ${UVCC_INDEX}"
mkdir -p './recording/'
set -x
# NOTE: requires
# - ffmpeg compiled with --enable-libzmq
# - zmqsend from the ffmpeg repository
# http://www.ffmpeg-archive.org/how-to-build-tools-zmqsend-td4686430.html
# https://raspberrypi.stackexchange.com/questions/93786/ffmpeg-doesnt-have-tools-zmqsend
coproc 'RECORDER' {
ffmpeg \
-hide_banner \
-loglevel 'error' \
-f 'v4l2' \
-framerate '24' \
-video_size '1280x720' \
-input_format 'h264' \
-i /dev/video0 \
-ss '2' \
-an \
-sn \
-vf "
zmq='',
scale=sws_flags=spline+accurate_rnd:out_range=tv,
drawbox='y=(ih/5):color=black@0.3:width=iw:height=(ih/6):t=fill',
drawtext='fontsize=(h/8):fontcolor=black:x=((w-tw)/2):y=(h/5)+(h/36):text=auto.json'
" \
-c:v 'libx264' \
-colorspace 'bt709' \
-color_trc 'bt709' \
-color_primaries 'bt709' \
-color_range 'tv' \
-pix_fmt 'yuv420p' \
-f 'mp4' \
-y \
'./recording/uvcc-demo.mp4'
}
# NOTE: setting -ss '2' to skip the first two seconds of video, to let the camera autoadjust to current lighting conditions.
sleep 2
changeOverlayTextAsync 'auto.json'
cat 'auto.json' | $UVCC import
sleep 5
changeOverlayTextAsync 'warm.json'
cat 'warm.json' | $UVCC import
sleep 3
changeOverlayTextAsync 'cold.json'
cat 'cold.json' | $UVCC import
sleep 3
changeOverlayTextAsync 'zoom in, pan/tilt'
$UVCC set absolute_zoom 500
sleep 1
# TODO: could be smoother by adding more steps.
$UVCC set absolute_pan_tilt -18000 -18000
$UVCC set absolute_pan_tilt -36000 -36000
sleep 0.6
$UVCC set absolute_pan_tilt -18000 -36000
$UVCC set absolute_pan_tilt 0 -36000
$UVCC set absolute_pan_tilt 18000 -36000
$UVCC set absolute_pan_tilt 36000 -36000
sleep 0.6
$UVCC set absolute_pan_tilt 18000 -36000
$UVCC set absolute_pan_tilt 0 -36000
sleep 1
changeOverlayTextAsync 'crazy.json'
cat 'crazy.json' | $UVCC import
sleep 4
# TODO: generate the json for these steps and import, instead of individual step commands.
changeOverlayTextAsync 'stepwise color changes'
$UVCC set brightness 200
$UVCC set saturation 200
$UVCC set sharpness 200
$UVCC set gain 200
sleep 0.5
$UVCC set brightness 150
$UVCC set saturation 150
$UVCC set sharpness 150
$UVCC set gain 150
sleep 0.5
$UVCC set brightness 100
$UVCC set saturation 100
$UVCC set sharpness 100
$UVCC set gain 100
sleep 0.5
$UVCC set brightness 50
$UVCC set saturation 50
$UVCC set sharpness 50
# $UVCC set gain 50
sleep 0.5
# $UVCC set brightness 0
$UVCC set saturation 0
$UVCC set sharpness 0
# $UVCC set gain 0
sleep 2
# NOTE: hardcoded range because dynamically the current absolute_zoom value to get a
# starting point isn't really reliable, as it depends on camera image output size.
for absolute_zoom in {150..100};
do
$UVCC set absolute_zoom "$absolute_zoom"
done
# NOTE: the video is made to loop, so going back to auto.json at the end.
changeOverlayTextAsync 'auto.json'
cat 'auto.json' | $UVCC import
sleep 3
# NOTE: emulate ffmpeg "q" (quit) keyboard key press.
echo -n 'q' >& "${RECORDER[1]}"
# NOTE: wait for ffmpeg to finish writing the video.
wait "${RECORDER_PID}"
# https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
# https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
# ffmpeg -hide_banner -loglevel 'error' -i './recording/uvcc-demo.mp4' -filter_complex "[0:v] fps=4,scale=480:-2:flags=lanczos,split [a][b];[a] palettegen=stats_mode=diff [p];[b][p] paletteuse" -vsync '0' -loop '0' -y './recording/uvcc-demo.gif'
# https://gif.ski/
find ./recording -iname 'demo-*.png' -delete
ffmpeg -hide_banner -loglevel 'error' -i './recording/uvcc-demo.mp4' -vf "fps='4'" './recording/demo-%04d.png'
find ./recording -iname 'demo-*.png' -print0 | xargs -0 gifski --fps '4' --width '480' --quality '25' --output './recording/uvcc-demo.gif'
================================================
FILE: examples/logitech-c920/1133-2093/demo/warm.json
================================================
{
"auto_white_balance_temperature": 0,
"white_balance_temperature": 6500
}
================================================
FILE: examples/logitech-c920/1133-2093/devices.json
================================================
[
{
"name": "HD Pro Webcam C920",
"vendor": 1133,
"product": 2093,
"address": 66
}
]
================================================
FILE: examples/logitech-c920/1133-2093/export.json
================================================
{
"absolute_exposure_time": 333,
"absolute_focus": 0,
"absolute_pan_tilt": [
0,
0
],
"absolute_zoom": 100,
"auto_exposure_mode": 8,
"auto_exposure_priority": 1,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"backlight_compensation": 0,
"brightness": 128,
"contrast": 128,
"gain": 97,
"power_line_frequency": 2,
"saturation": 128,
"sharpness": 128,
"white_balance_temperature": 4852
}
================================================
FILE: examples/logitech-c920/1133-2093/metadata.json
================================================
{
"node": "v18.1.0",
"npm": "8.8.0",
"uname": "Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux",
"uvcc": "v6.0.0"
}
================================================
FILE: examples/logitech-c920/1133-2093/ranges.json
================================================
{
"absolute_exposure_time": {
"min": 3,
"max": 2047
},
"absolute_focus": {
"min": 0,
"max": 250
},
"absolute_pan_tilt": {
"min": [
-36000,
-36000
],
"max": [
36000,
36000
]
},
"absolute_zoom": {
"min": 100,
"max": 500
},
"backlight_compensation": {
"min": 0,
"max": 1
},
"brightness": {
"min": 0,
"max": 255
},
"contrast": {
"min": 0,
"max": 255
},
"gain": {
"min": 0,
"max": 255
},
"saturation": {
"min": 0,
"max": 255
},
"sharpness": {
"min": 0,
"max": 255
},
"white_balance_temperature": {
"min": 2000,
"max": 6500
}
}
================================================
FILE: examples/logitech-c922/1133-2140/controls.json
================================================
[
"absolute_exposure_time",
"absolute_focus",
"absolute_pan_tilt",
"absolute_zoom",
"auto_exposure_mode",
"auto_exposure_priority",
"auto_focus",
"auto_white_balance_temperature",
"backlight_compensation",
"brightness",
"contrast",
"gain",
"power_line_frequency",
"saturation",
"sharpness",
"white_balance_temperature"
]
================================================
FILE: examples/logitech-c922/1133-2140/devices.json
================================================
[
{
"name": "C922 Pro Stream Webcam",
"vendor": 1133,
"product": 2140,
"address": 43
}
]
================================================
FILE: examples/logitech-c922/1133-2140/export.json
================================================
{
"absolute_exposure_time": 250,
"absolute_focus": 0,
"absolute_pan_tilt": [
0,
0
],
"absolute_zoom": 100,
"auto_exposure_mode": 8,
"auto_exposure_priority": 1,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"backlight_compensation": 0,
"brightness": 128,
"contrast": 128,
"gain": 0,
"power_line_frequency": 2,
"saturation": 128,
"sharpness": 128,
"white_balance_temperature": 4000
}
================================================
FILE: examples/logitech-c922/1133-2140/metadata.json
================================================
{
"node": "v18.1.0",
"npm": "8.8.0",
"uname": "Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux",
"uvcc": "v6.0.0"
}
================================================
FILE: examples/logitech-c922/1133-2140/ranges.json
================================================
{
"absolute_exposure_time": {
"min": 3,
"max": 2047
},
"absolute_focus": {
"min": 0,
"max": 250
},
"absolute_pan_tilt": {
"min": [
-36000,
-36000
],
"max": [
36000,
36000
]
},
"absolute_zoom": {
"min": 100,
"max": 500
},
"backlight_compensation": {
"min": 0,
"max": 1
},
"brightness": {
"min": 0,
"max": 255
},
"contrast": {
"min": 0,
"max": 255
},
"gain": {
"min": 0,
"max": 255
},
"saturation": {
"min": 0,
"max": 255
},
"sharpness": {
"min": 0,
"max": 255
},
"white_balance_temperature": {
"min": 2000,
"max": 6500
}
}
================================================
FILE: examples/microsoft-1425/1118-1906/controls.json
================================================
[
"absolute_exposure_time",
"absolute_focus",
"absolute_pan_tilt",
"absolute_zoom",
"auto_exposure_mode",
"auto_focus",
"auto_white_balance_temperature",
"backlight_compensation",
"brightness",
"contrast",
"power_line_frequency",
"saturation",
"sharpness",
"white_balance_temperature"
]
================================================
FILE: examples/microsoft-1425/1118-1906/devices.json
================================================
[
{
"name": "Microsoft® LifeCam Studio(TM)",
"vendor": 1118,
"product": 1906,
"address": 28
}
]
================================================
FILE: examples/microsoft-1425/1118-1906/export.json
================================================
{
"absolute_exposure_time": 156,
"absolute_focus": 0,
"absolute_pan_tilt": [
0,
0
],
"absolute_zoom": 0,
"auto_exposure_mode": 8,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"backlight_compensation": 5,
"brightness": 133,
"contrast": 5,
"power_line_frequency": 2,
"saturation": 103,
"sharpness": 25,
"white_balance_temperature": 4500
}
================================================
FILE: examples/microsoft-1425/1118-1906/metadata.json
================================================
{
"node": "v16.6.0",
"npm": "7.20.3",
"uname": "Darwin MacBook-Pro 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64",
"uvcc": "3.0.1"
}
================================================
FILE: examples/microsoft-1425/1118-1906/ranges.json
================================================
{
"absolute_exposure_time": {
"min": 1,
"max": 10000
},
"absolute_focus": {
"min": 0,
"max": 40
},
"absolute_pan_tilt": {
"min": [
-529200,
-432000
],
"max": [
529200,
432000
]
},
"absolute_zoom": {
"min": 0,
"max": 317
},
"backlight_compensation": {
"min": 0,
"max": 10
},
"brightness": {
"min": 30,
"max": 255
},
"contrast": {
"min": 0,
"max": 10
},
"saturation": {
"min": 0,
"max": 200
},
"sharpness": {
"min": 0,
"max": 50
},
"white_balance_temperature": {
"min": 2500,
"max": 10000
}
}
================================================
FILE: examples/microsoft-1425/1118-2065/controls.json
================================================
[
"absolute_exposure_time",
"absolute_focus",
"absolute_pan_tilt",
"absolute_zoom",
"auto_exposure_mode",
"auto_focus",
"auto_white_balance_temperature",
"backlight_compensation",
"brightness",
"contrast",
"power_line_frequency",
"saturation",
"sharpness",
"white_balance_temperature"
]
================================================
FILE: examples/microsoft-1425/1118-2065/devices.json
================================================
[
{
"name": "Microsoft® LifeCam Studio(TM)",
"vendor": 1118,
"product": 2065,
"address": 38
}
]
================================================
FILE: examples/microsoft-1425/1118-2065/export.json
================================================
{
"absolute_exposure_time": 156,
"absolute_focus": 0,
"absolute_pan_tilt": [
0,
0
],
"absolute_zoom": 0,
"auto_exposure_mode": 8,
"auto_focus": 1,
"auto_white_balance_temperature": 1,
"backlight_compensation": 5,
"brightness": 133,
"contrast": 5,
"power_line_frequency": 2,
"saturation": 109,
"sharpness": 25,
"white_balance_temperature": 6358
}
================================================
FILE: examples/microsoft-1425/1118-2065/metadata.json
================================================
{
"node": "v18.1.0",
"npm": "8.8.0",
"uname": "Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux",
"uvcc": "v6.0.0"
}
================================================
FILE: examples/microsoft-1425/1118-2065/ranges.json
================================================
{
"absolute_exposure_time": {
"min": 1,
"max": 10000
},
"absolute_focus": {
"min": 0,
"max": 40
},
"absolute_pan_tilt": {
"min": [
-529200,
-432000
],
"max": [
529200,
432000
]
},
"absolute_zoom": {
"min": 0,
"max": 317
},
"backlight_compensation": {
"min": 0,
"max": 10
},
"brightness": {
"min": 30,
"max": 255
},
"contrast": {
"min": 0,
"max": 10
},
"saturation": {
"min": 0,
"max": 200
},
"sharpness": {
"min": 0,
"max": 50
},
"white_balance_temperature": {
"min": 2500,
"max": 10000
}
}
================================================
FILE: examples/update-example.sh
================================================
#!/usr/bin/env bash
set -o errexit
set -o noclobber
set -o nounset
set -o pipefail
declare -r SCRIPT_BASE="${BASH_SOURCE%/*}"
declare SCRIPT_BASE_ABSOLUTE
SCRIPT_BASE_ABSOLUTE="$(realpath "$SCRIPT_BASE")"
declare UVCC_INDEX
UVCC_INDEX="$(realpath "${SCRIPT_BASE_ABSOLUTE}/../dist/index.js")"
declare -r UVCC="node -- ${UVCC_INDEX}"
rm -f 'controls.json'
$UVCC controls > 'controls.json'
rm -f 'devices.json'
$UVCC devices > 'devices.json'
rm -f 'export.json'
$UVCC export > 'export.json'
rm -f 'ranges.json'
$UVCC ranges > 'ranges.json'
rm -f 'metadata.json'
jq \
--null-input \
--arg uvcc "$($UVCC --version)" \
--arg node "$(node --version)" \
--arg npm "$(npm --version)" \
--arg uname "$(uname -a)" \
--sort-keys \
'{
uvcc: $uvcc,
node: $node,
npm: $npm,
uname: $uname,
}' > 'metadata.json'
================================================
FILE: package.json
================================================
{
"name": "uvcc",
"version": "7.0.0",
"description": "USB Video Class (UVC) device configurator for the command line (CLI). Used for webcams, camcorders, etcetera.",
"homepage": "https://joelpurra.com/projects/uvcc/",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"uvcc": "./dist/index.js"
},
"files": [
"dist/**/*"
],
"scripts": {
"clean": "rimraf ./dist/",
"build": "tsc",
"rebuild": "npm run --silent clean && npm run --silent build",
"build:watch": "tsc --watch",
"debug:run": "node --inspect ./dist/index.js",
"debug:run:break": "node --inspect-brk ./dist/index.js",
"test": "npm run --silent lint",
"lint": "npm run --silent lint:xo && npm run --silent lint:prettier && npm run --silent lint:copyright",
"lint:fix": "npm run --silent lint:xo:fix && npm run --silent lint:prettier:fix",
"lint:copyright": "find . -not \\( -path './.git/*' -or -path './node_modules/*' -or -path './dist/*' \\) -type f \\( -iname '*.js' -or -iname '*.ts' \\) -print0 | xargs -0 grep -L 'This file is part of uvcc' | sed 's/^/File is missing copyright notice: /'",
"lint:prettier": "prettier --list-different \"**/*.json\" \"**/*.md\" || { echo \"Prettier needs to format the above files. Try 'npm run --silent lint:fix'.\" && exit 1; }",
"lint:prettier:fix": "prettier --write \"**/*.json\" \"**/*.md\"",
"lint:xo": "xo",
"lint:xo:fix": "xo --fix",
"prepublishOnly": "git diff-index --exit-code master && npm run --silent rebuild && npm run --silent test"
},
"dependencies": {
"array-non-uniq": "^1.0.0",
"bluebird": "^3.7.2",
"chalk": "^5.2.0",
"engine-check": "^1.0.1",
"filter-obj": "^3.0.0",
"find-up": "^6.3.0",
"map-obj": "^5.0.2",
"read-pkg-up": "^9.1.0",
"sort-keys": "^5.0.0",
"stream-to-promise": "^3.0.0",
"uvc-control": "github:joelpurra/node-uvc-control#v2",
"yargs": "^17.7.1"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^2.0.0",
"@types/bluebird": "^3.5.38",
"@types/engine-check": "^1.1.1",
"@types/stream-to-promise": "^2.2.1",
"@types/yargs": "^17.0.22",
"eslint-config-joelpurra": "github:joelpurra/eslint-config-joelpurra#semver:^v11.0.1",
"husky": "^4.3.8",
"rimraf": "^3.0.2",
"type-fest": "^2.19.0",
"typescript": "^4.9.5",
"usb": "^2.8.0",
"xo": "^0.48.0"
},
"engines": {
"node": "^16.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
},
"keywords": [
"usb",
"usb video class",
"uvc",
"camera",
"webcam",
"webcamera",
"controls",
"configuration",
"libusb",
"libuvc",
"uvc-control"
],
"bugs": {
"url": "https://github.com/joelpurra/uvcc/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/joelpurra/uvcc.git"
},
"author": {
"name": "Joel Purra",
"email": "mig@joelpurra.se",
"url": "https://joelpurra.com/"
},
"license": "GPL-3.0",
"husky": {
"hooks": {
"pre-commit": "npm run --silent test",
"pre-push": "npm run --silent test"
}
}
}
================================================
FILE: src/camera-control-helper-factory.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Camera, {
UvcControl,
} from "uvc-control";
import CameraControlHelperClass from "./camera-control-helper.js";
export default class CameraControlHelperFactory {
constructor(
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly UvcControl: ReadonlyDeep<UvcControl>,
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly CameraControlHelper: typeof CameraControlHelperClass,
) {
assert.strictEqual(arguments.length, 2);
assert(typeof this.UvcControl === "function");
assert(typeof this.CameraControlHelper === "function");
}
async get(camera: ReadonlyDeep<Camera>): Promise<CameraControlHelperClass> {
assert.strictEqual(arguments.length, 1);
assert(typeof camera === "object");
const cameraControlHelper = new this.CameraControlHelper(this.UvcControl, camera);
return cameraControlHelper;
}
}
================================================
FILE: src/camera-control-helper.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import arrayNonUniq from "array-non-uniq";
import filterObject from "filter-obj";
import assert from "node:assert";
import sortKeys from "sort-keys";
import {
ReadonlyDeep,
} from "type-fest";
import Camera,
{
CameraControl,
UvcControl,
} from "uvc-control";
import WrappedError from "./utilities/wrapped-error.js";
interface ControlFlags {
readonly isGettable: boolean;
readonly isRanged: boolean;
readonly isSettable: boolean;
}
type ControlsFlags = Record<string, ControlFlags>;
export default class CameraControlHelper {
private cachedMappedSupportedControls: ReadonlyDeep<ControlsFlags> | null = null;
constructor(
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly UvcControl: ReadonlyDeep<UvcControl>,
private readonly camera: ReadonlyDeep<Camera>,
) {
assert.strictEqual(arguments.length, 2);
assert(typeof this.UvcControl === "function");
assert(typeof this.camera === "object");
}
async getControlNames(): Promise<readonly string[]> {
const controls = await this.getSupportedControls();
return Object.keys(controls);
}
async getGettableControlNames(): Promise<readonly string[]> {
const gettableControls = await this.getGettableControls();
return Object.keys(gettableControls);
}
async getRangedControlNames(): Promise<readonly string[]> {
const rangedControls = await this.getRangedControls();
return Object.keys(rangedControls);
}
async getSettableControlNames(): Promise<readonly string[]> {
const settableControls = await this.getSettableControls();
return Object.keys(settableControls);
}
private isGettableControl(control: ReadonlyDeep<CameraControl>) {
// NOTE: relies on uvc-control internals.
return control.requests.includes(this.UvcControl.REQUEST.GET_CUR);
}
private isRangedControl(control: ReadonlyDeep<CameraControl>) {
// NOTE: relies on uvc-control internals.
return control.requests.includes(this.UvcControl.REQUEST.GET_MIN)
&& control.requests.includes(this.UvcControl.REQUEST.GET_MAX);
}
private isSettableControl(control: ReadonlyDeep<CameraControl>) {
// NOTE: relies on uvc-control internals.
return control.requests.includes(this.UvcControl.REQUEST.SET_CUR)
|| (
// TODO: treat optionally settable controls separately?
Array.isArray(control.optional_requests)
&& control.optional_requests.includes(this.UvcControl.REQUEST.SET_CUR)
);
}
private async mapSupportedControls() {
const supportedControls = this.camera.supportedControls
.map((supportedControlName) => this.UvcControl.controls[supportedControlName])
// TODO: proper ducktyping function.
.filter((t): t is CameraControl => Boolean(t));
const missingControls = supportedControls.filter((control) => !control);
if (missingControls.length > 0) {
throw new Error(`Controls were not found: ${JSON.stringify(missingControls)}`);
}
const nonUniqueControls = arrayNonUniq(supportedControls);
if (nonUniqueControls.length > 0) {
throw new Error(`Controls were already found: ${JSON.stringify(nonUniqueControls)}`);
}
const mappedControls = supportedControls.map((control) => {
try {
const uvccControl: [string, ControlFlags] = [
control.name,
{
// NOTE: minimal uvcc-specific mapping.
isGettable: this.isGettableControl(control),
isRanged: this.isRangedControl(control),
isSettable: this.isSettableControl(control),
},
];
return uvccControl;
} catch (error: unknown) {
if (error instanceof Error) {
const wrappedError = new WrappedError(error, `Could not map control: ${JSON.stringify(control.name)}`);
throw wrappedError;
}
throw error;
}
});
const controlsObject: ControlsFlags = {};
for (const mappedControl of mappedControls) {
controlsObject[mappedControl[0]] = mappedControl[1];
}
const sortedControls = sortKeys(controlsObject);
return sortedControls;
}
private async getSupportedControls() {
if (this.cachedMappedSupportedControls === null) {
this.cachedMappedSupportedControls = await this.mapSupportedControls();
}
return this.cachedMappedSupportedControls;
}
private async getGettableControls() {
const controls = await this.getSupportedControls();
return filterObject(controls, (_key, control) => control.isGettable);
}
private async getRangedControls() {
const controls = await this.getSupportedControls();
return filterObject(controls, (_key, control) => control.isRanged);
}
private async getSettableControls() {
const controls = await this.getSupportedControls();
return filterObject(controls, (_key, control) => control.isSettable);
}
}
================================================
FILE: src/camera-factory.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Camera, {
ConstructorOptions,
UvcControl,
} from "uvc-control";
import Output from "./output.js";
import toFormattedHex from "./utilities/to-formatted-hex.js";
import WrappedError from "./utilities/wrapped-error.js";
interface GetFunctionArguments {
address: number | null;
product: number | null;
vendor: number | null;
}
export default class CameraFactory {
constructor(
private readonly output: Output,
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly UvcControl: UvcControl,
) {
assert.strictEqual(arguments.length, 2);
assert(typeof this.UvcControl === "function");
}
async get(vendor: number | null, product: number | null, address: number | null): Promise<Camera> {
assert.strictEqual(arguments.length, 3);
assert(vendor === null || (typeof vendor === "number" && vendor >= 0));
assert(product === null || (typeof product === "number" && product >= 0));
assert(address === null || (typeof address === "number" && address >= 0));
const constructorOptions: ConstructorOptions = {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
deviceAddress: address || undefined,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
pid: product || undefined,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
vid: vendor || undefined,
};
try {
const camera = new this.UvcControl(constructorOptions);
if (vendor && vendor !== camera.device.deviceDescriptor.idVendor) {
this.output.warning("Camera vendor id mismatch.", "Input", vendor, `(${toFormattedHex(vendor, 4)})`, "Actual", camera.device.deviceDescriptor.idVendor, `(${toFormattedHex(camera.device.deviceDescriptor.idVendor, 4)})`);
}
if (product && product !== camera.device.deviceDescriptor.idProduct) {
this.output.warning("Camera product id mismatch.", "Input", product, `(${toFormattedHex(product, 4)})`, "Actual", camera.device.deviceDescriptor.idProduct, `(${toFormattedHex(camera.device.deviceDescriptor.idProduct, 4)})`);
}
if (address && address !== camera.device.deviceAddress) {
this.output.warning("Camera device address mismatch.", "Input", address, `(${toFormattedHex(address, 1)})`, "Actual", camera.device.deviceAddress, `(${toFormattedHex(camera.device.deviceAddress, 1)})`);
}
return camera;
} catch (error: unknown) {
if (error instanceof Error) {
// NOTE: basically a duplicate of both the arguments to this function and to the uvc-control constructor.
const getFunctionArguments: GetFunctionArguments = {
address,
product,
vendor,
};
const wrappedError = this.createWrappedError(error, getFunctionArguments, constructorOptions);
throw wrappedError;
}
throw error;
}
}
private createWrappedError(error: ReadonlyDeep<Error>, getFunctionArguments: ReadonlyDeep<GetFunctionArguments>, constructorOptions: ReadonlyDeep<ConstructorOptions>) {
let errorMessage = null;
// NOTE: relies on uvc-control internals.
// NOTE: may rely on user locale.
const guessThatUvcDeviceWasNotFound = typeof error.name === "string"
&& error.name === "TypeError"
&& typeof error.message === "string"
&& (
// NOTE: message formatting differs across versions; could use a regular expression instead.
error.message === "Cannot read property 'interfaces' of undefined"
|| error.message === "Cannot read properties of undefined (reading 'interfaces')"
);
errorMessage = guessThatUvcDeviceWasNotFound ? `Could not find UVC device. Is a compatible camera connected? ${JSON.stringify(getFunctionArguments)}` : `Could create uvc-control object: ${JSON.stringify(constructorOptions)}`;
errorMessage += ` (${JSON.stringify(String(error))})`;
const wrappedError = new WrappedError(error, errorMessage);
return wrappedError;
}
}
================================================
FILE: src/camera-helper-factory.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Camera from "uvc-control";
import CameraControlHelperFactory from "./camera-control-helper-factory.js";
import CameraHelperClass from "./camera-helper.js";
import Output from "./output.js";
export default class CameraHelperFactory {
constructor(
private readonly output: ReadonlyDeep<Output>,
private readonly cameraControlHelperFactory: ReadonlyDeep<CameraControlHelperFactory>,
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly CameraHelper: typeof CameraHelperClass,
) {
assert.strictEqual(arguments.length, 3);
assert(typeof this.output === "object");
assert(typeof this.cameraControlHelperFactory === "object");
assert(typeof this.CameraHelper === "function");
}
async get(camera: ReadonlyDeep<Camera>): Promise<CameraHelperClass> {
assert.strictEqual(arguments.length, 1);
assert(typeof camera === "object");
const cameraControlHelper = await this.cameraControlHelperFactory.get(camera);
const cameraHelper = new this.CameraHelper(this.output, cameraControlHelper, camera);
return cameraHelper;
}
}
================================================
FILE: src/camera-helper.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Bluebird from "bluebird";
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Camera, {
ControlName,
ControlRange,
ControlValue,
ControlValues,
} from "uvc-control";
import CameraControlHelper from "./camera-control-helper.js";
import Output from "./output.js";
import {
UvccControls,
} from "./types/controls.js";
import isUvccControlValue from "./utilities/is-uvcc-control-value.js";
export type ControlsValues = Record<string, ControlValues>;
export type ControlRanges = Record<string, ControlRange>;
export default class CameraHelper {
constructor(private readonly output: ReadonlyDeep<Output>, private readonly cameraControlHelper: ReadonlyDeep<CameraControlHelper>, private readonly camera: ReadonlyDeep<Camera>) {
assert.strictEqual(arguments.length, 3);
assert(typeof this.output === "object");
assert(typeof this.cameraControlHelper === "object");
assert(typeof this.camera === "object");
}
async getValues(controlName: ControlName): Promise<ReadonlyDeep<ControlValues>> {
const gettableControlNames = await this.cameraControlHelper.getGettableControlNames();
if (!gettableControlNames.includes(controlName)) {
throw new Error(`Could not find a gettable control named ${JSON.stringify(controlName)}.`);
}
const valueObject = await this.camera.get(controlName);
return valueObject;
}
async getRange(controlName: ControlName): Promise<ReadonlyDeep<ControlRange>> {
const rangedControlNames = await this.cameraControlHelper.getRangedControlNames();
if (!rangedControlNames.includes(controlName)) {
throw new Error(`Could not find a ranged control named ${JSON.stringify(controlName)}.`);
}
const range = this.camera.range(controlName);
return range;
}
async setValues(controlName: ControlName, values: readonly ControlValue[]): Promise<void> {
const settableControlNames = await this.cameraControlHelper.getSettableControlNames();
if (!settableControlNames.includes(controlName)) {
throw new Error(`Could not find a settable control named ${JSON.stringify(controlName)}.`);
}
await this.camera.set(controlName, ...values);
return undefined;
}
async getControlNames(): Promise<readonly ControlName[]> {
return this.cameraControlHelper.getControlNames();
}
async getRanges(): Promise<ReadonlyDeep<ControlRanges>> {
// TODO: replace with Object.fromEntries(...);
return Bluebird.reduce(
this.cameraControlHelper.getRangedControlNames(),
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
async (object, controlName) => {
try {
object[controlName] = await this.getRange(controlName);
} catch (error: unknown) {
// TODO: ignore only specific errors, such as usb.LIBUSB_TRANSFER_STALL?
this.output.verbose("Error getting range, ignoring.", controlName, error);
}
return object;
},
{} as ControlRanges,
);
}
async getSettableControls(): Promise<ReadonlyDeep<ControlsValues>> {
// TODO: replace with Object.fromEntries(...);
return Bluebird.reduce(
this.cameraControlHelper.getSettableControlNames(),
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
async (object, controlName) => {
try {
object[controlName] = await this.getValues(controlName);
} catch (error: unknown) {
// TODO: ignore only specific errors, such as usb.LIBUSB_TRANSFER_STALL?
this.output.verbose("Error getting settable value, ignoring.", controlName, error);
}
return object;
},
{} as ControlsValues,
);
}
async setControls(configuration: ReadonlyDeep<UvccControls>): Promise<void> {
const controlNames = Object.keys(configuration);
const settableControlNames = await this.cameraControlHelper.getSettableControlNames();
// NOTE: checking all control names before attempting to set any.
const nonSettableNames = controlNames.filter((controlName) => !settableControlNames.includes(controlName));
if (nonSettableNames.length > 0) {
throw new Error(`Could not find a settable controls, aborting setting values: ${JSON.stringify(nonSettableNames)}`);
}
await Bluebird.map(
controlNames,
// eslint-disable-next-line unicorn/no-array-method-this-argument
async (controlName) => {
const controlValues = configuration[controlName];
if (!isUvccControlValue(controlValues)) {
throw new TypeError(`Expected number value for configuration ${controlName}, got ${typeof controlValues} ${JSON.stringify(controlValues)}.`);
}
// eslint-disable-next-line unicorn/prefer-spread
const controlValuesArray = new Array<number>().concat(controlValues);
try {
await this.setValues(controlName, controlValuesArray);
} catch (error: unknown) {
// TODO: ignore only specific errors, such as usb.LIBUSB_TRANSFER_STALL?
this.output.verbose("Error setting value, ignoring.", controlName, controlValues, error);
}
},
);
}
}
================================================
FILE: src/command-handlers/controls.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
export default class ControlsCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
];
}
async execute(...args: readonly unknown[]): Promise<unknown> {
assert.strictEqual(arguments.length, 1);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const controlNames = await cameraHelper.getControlNames();
return controlNames;
}
}
================================================
FILE: src/command-handlers/devices.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
Command,
CommandHandlerArgumentNames,
} from "../types/command.js";
import UvcDeviceLister from "../uvc-device-lister.js";
export default class DevicesCommand implements Command {
constructor(private readonly uvcDeviceLister: UvcDeviceLister) {
assert.strictEqual(arguments.length, 1);
assert(typeof this.uvcDeviceLister === "object");
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [];
}
async execute(): Promise<unknown> {
assert.strictEqual(arguments.length, 0);
const devices = await this.uvcDeviceLister.get();
return devices;
}
}
================================================
FILE: src/command-handlers/export.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import mapObj from "map-obj";
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
import {
UvccControls,
} from "../types/controls.js";
import flattenControlValues from "../utilities/flatten-control-values.js";
export default class ExportCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
];
}
async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<UvccControls>> {
assert.strictEqual(arguments.length, 1);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
// NOTE: exporting un-settable values breaks imports because of strict settable value checks.
// TODO: export also un-settable values with --all flag?
const settableControls = await cameraHelper.getSettableControls();
const values = mapObj(
settableControls,
(
settableControlName,
settableControlValue,
) => [
settableControlName,
flattenControlValues(settableControlValue),
],
);
return values;
}
}
================================================
FILE: src/command-handlers/get.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import {
ControlName,
} from "uvc-control";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
import flattenControlValues from "../utilities/flatten-control-values.js";
export default class GetCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
"control",
];
}
async execute(...args: readonly unknown[]): Promise<number | readonly number[]> {
assert.strictEqual(arguments.length, 2);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const controlName = args[1] as ControlName;
const valueObject = await cameraHelper.getValues(controlName);
const value = flattenControlValues(valueObject);
return value;
}
}
================================================
FILE: src/command-handlers/import.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Bluebird from "bluebird";
import assert from "node:assert";
import process from "node:process";
import streamToPromise from "stream-to-promise";
import {
ReadonlyDeep,
} from "type-fest";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
import isUvccControls from "../utilities/is-uvcc-controls.js";
export default class ImportCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
];
}
async execute(...args: readonly unknown[]): Promise<void> {
assert.strictEqual(arguments.length, 1);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const stdinTimeout = 1000;
const controlValues = await Bluebird.try(async () => {
const buffer = await streamToPromise(process.stdin);
const json = JSON.parse(buffer.toString()) as unknown;
assert(typeof json === "object");
assert(json !== null);
return json;
})
.timeout(stdinTimeout, `Could not read uvcc configuration from stdin within the ${stdinTimeout} millisecond timeout. Was any data piped in?`)
.tapCatch((error) => {
process.stdin.destroy(error);
});
assert(isUvccControls(controlValues));
return cameraHelper.setControls(controlValues);
}
}
================================================
FILE: src/command-handlers/range.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import {
ControlName,
ControlRange,
} from "uvc-control";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
export default class RangeCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
"control",
];
}
async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<ControlRange>> {
assert.strictEqual(args.length, 2);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const controlName = args[1] as ControlName;
const range = await cameraHelper.getRange(controlName);
return range;
}
}
================================================
FILE: src/command-handlers/ranges.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import CameraHelper,
{
ControlRanges,
} from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
export default class RangesCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
];
}
async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<ControlRanges>> {
assert.strictEqual(arguments.length, 1);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const ranges = await cameraHelper.getRanges();
return ranges;
}
}
================================================
FILE: src/command-handlers/set.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import {
ControlName,
ControlValue,
} from "uvc-control";
import CameraHelper from "../camera-helper.js";
import {
Command,
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentNames,
} from "../types/command.js";
export default class SetCommand implements Command {
constructor() {
assert.strictEqual(arguments.length, 0);
}
async getArguments(): Promise<CommandHandlerArgumentNames[]> {
return [
CommandHandlerArgumentCameraHelper,
"control",
"values",
];
}
async execute(...args: readonly unknown[]): Promise<void> {
assert(args.length >= 2);
const cameraHelper = args[0] as ReadonlyDeep<CameraHelper>;
const controlName = args[1] as ControlName;
const values = args[2] as readonly ControlValue[];
return cameraHelper.setValues(controlName, values);
}
}
================================================
FILE: src/command-handlers.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Output from "./output.js";
import {
CommandHandlerArgumentNames,
CommandName,
Commands,
} from "./types/command.js";
export default class CommandHandlers {
constructor(private readonly output: Output, private readonly commands: ReadonlyDeep<Commands>) {
assert.strictEqual(arguments.length, 2);
assert(typeof this.output === "object");
assert(typeof this.commands === "object");
}
async has(commandName: CommandName): Promise<boolean> {
assert.strictEqual(arguments.length, 1);
assert(typeof commandName === "string");
const command = this.commands[commandName];
return Boolean(command);
}
async execute(commandName: CommandName, ...args: readonly unknown[]): Promise<unknown> {
assert(typeof commandName === "string");
assert(Array.isArray(args));
const command = this.commands[commandName];
assert(typeof command === "object");
const output = await command.execute(...args);
return output;
}
async getArguments(commandName: CommandName): Promise<CommandHandlerArgumentNames[]> {
assert.strictEqual(arguments.length, 1);
assert(typeof commandName === "string");
const command = this.commands[commandName];
assert(typeof command === "object");
return command.getArguments();
}
}
================================================
FILE: src/command-manager.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import Camera from "uvc-control";
import CameraFactory from "./camera-factory.js";
import CameraHelperFactory from "./camera-helper-factory.js";
import CommandHandlers from "./command-handlers.js";
import Output from "./output.js";
import {
RuntimeConfiguration,
} from "./runtime-configurator.js";
import {
CommandHandlerArgumentCameraHelper,
CommandHandlerArgumentTypes,
CommandHandlerLookup,
} from "./types/command.js";
export default class CommandManager {
constructor(private readonly output: Output, private readonly cameraFactory: CameraFactory, private readonly cameraHelperFactory: CameraHelperFactory, private readonly commandHandlers: CommandHandlers) {
assert.strictEqual(arguments.length, 4);
assert(typeof this.output === "object");
assert(typeof this.cameraFactory === "object");
assert(typeof this.cameraHelperFactory === "object");
assert(typeof this.commandHandlers === "object");
}
async execute(runtimeConfig: ReadonlyDeep<RuntimeConfiguration>): Promise<void> {
this.output.verbose("Parsed arguments:", JSON.stringify(runtimeConfig, null, 2));
const commandName = runtimeConfig.cmd;
const commandHandlerExists = await this.commandHandlers.has(commandName);
if (!commandHandlerExists) {
this.output.error("Unknown command:", commandName);
return;
}
let camera: Camera | null = null;
const closeCamera = async () => {
if (camera) {
await camera.close();
}
};
const commandArguments = await this.commandHandlers.getArguments(commandName);
// TODO: smarter solution.
if (commandArguments.includes(CommandHandlerArgumentCameraHelper)) {
const {
vendor,
product,
address,
} = runtimeConfig;
assert(typeof vendor === "number");
assert(typeof product === "number");
assert(typeof address === "number");
camera = await this.cameraFactory.get(vendor, product, address);
}
try {
// NOTE HACK: don't mix "injection" with other arguments.
const argumentValues: CommandHandlerArgumentTypes[] = commandArguments
.filter((commandArgument) => commandArgument !== CommandHandlerArgumentCameraHelper)
.map((commandArgument) => (runtimeConfig as CommandHandlerLookup)[commandArgument]);
// TODO: smarter solution.
if (commandArguments.includes(CommandHandlerArgumentCameraHelper)) {
assert(camera !== null);
const cameraHelper = await this.cameraHelperFactory.get(camera);
argumentValues.unshift(cameraHelper);
}
const output = await this.commandHandlers.execute(commandName, ...argumentValues);
// NOTE: could separate of types of commands -- those with output, and those without.
if (typeof output !== "undefined") {
const json = JSON.stringify(output, null, 2);
this.output.normal(json);
}
await closeCamera();
} catch (error: unknown) {
try {
await closeCamera();
} catch {
// NOTE: if there were previous errors, ignore errors when closing the camera connection.
}
throw error;
}
}
}
================================================
FILE: src/index.ts
================================================
#!/usr/bin/env node
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import engineCheck from "engine-check";
import {
dirname,
join,
} from "node:path";
import process from "node:process";
import {
fileURLToPath,
} from "node:url";
import UvcControl from "uvc-control";
import CameraControlHelper from "./camera-control-helper.js";
import CameraControlHelperFactory from "./camera-control-helper-factory.js";
import CameraFactory from "./camera-factory.js";
import CameraHelper from "./camera-helper.js";
import CameraHelperFactory from "./camera-helper-factory.js";
import CommandHandlers from "./command-handlers.js";
import ControlsCommand from "./command-handlers/controls.js";
import DevicesCommand from "./command-handlers/devices.js";
import ExportCommand from "./command-handlers/export.js";
import GetCommand from "./command-handlers/get.js";
import ImportCommand from "./command-handlers/import.js";
import RangeCommand from "./command-handlers/range.js";
import RangesCommand from "./command-handlers/ranges.js";
import SetCommand from "./command-handlers/set.js";
import CommandManager from "./command-manager.js";
import Output from "./output.js";
import runtimeConfigurator from "./runtime-configurator.js";
import {
Commands,
} from "./types/command.js";
import UvcDeviceLister from "./uvc-device-lister.js";
// TODO: load package.json at compile time, use process.cwd() for resolving other paths.
const __dirname = dirname(fileURLToPath(import.meta.url));
const mainAsync = async () => {
try {
// NOTE: ignoring unhandled rejections and exceptions, as there is (practically) nothing to gracefully shut down.
const runtimeConfig = await runtimeConfigurator();
const output = new Output(runtimeConfig.verbose);
process.on("unhandledRejection", (...args: readonly unknown[]) => {
output.error(...args);
process.exitCode = 1;
});
process.on("uncaughtException", (...args: readonly unknown[]) => {
output.error(...args);
process.exitCode = 1;
});
const cameraFactory = new CameraFactory(output, UvcControl);
const cameraControlHelperFactory = new CameraControlHelperFactory(UvcControl, CameraControlHelper);
const cameraHelperFactory = new CameraHelperFactory(output, cameraControlHelperFactory, CameraHelper);
const uvcDeviceLister = new UvcDeviceLister(UvcControl);
const commands: Commands = {
controls: new ControlsCommand(),
devices: new DevicesCommand(uvcDeviceLister),
"export": new ExportCommand(),
get: new GetCommand(),
"import": new ImportCommand(),
range: new RangeCommand(),
ranges: new RangesCommand(),
set: new SetCommand(),
};
const commandHandlers = new CommandHandlers(output, commands);
const commandManager = new CommandManager(output, cameraFactory, cameraHelperFactory, commandHandlers);
await commandManager.execute(runtimeConfig);
} catch (error: unknown) {
// NOTE: root error handler for asynchronous errors.
// eslint-disable-next-line no-console
console.error(error);
process.exitCode = 1;
}
};
const main = () => {
try {
engineCheck({
searchRoot: join(__dirname, ".."),
});
void mainAsync();
} catch (error: unknown) {
// NOTE: root error handler for synchronous errors.
// eslint-disable-next-line no-console
console.error(error);
process.exitCode = 1;
}
};
main();
================================================
FILE: src/output.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
export default class Output {
constructor(public enableVerboseOutput: boolean) {
assert.strictEqual(arguments.length, 1);
assert(typeof this.enableVerboseOutput === "boolean");
}
normal(...args: readonly unknown[]): void {
this.consoleLog(...args);
}
error(...args: readonly unknown[]): void {
this.consoleError(...args);
}
warning(...args: readonly unknown[]): void {
this.consoleWarn(...args);
}
verbose(...args: readonly unknown[]): void {
if (!this.enableVerboseOutput) {
return undefined;
}
this.consoleError(...args);
}
private consoleLog(...args: readonly unknown[]) {
// eslint-disable-next-line no-console
console.log(...args);
}
private consoleError(...args: readonly unknown[]) {
// eslint-disable-next-line no-console
console.error(...args);
}
private consoleWarn(...args: readonly unknown[]) {
// eslint-disable-next-line no-console
console.warn(...args);
}
}
================================================
FILE: src/runtime-configurator.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import chalk from "chalk";
import {
findUpSync,
} from "find-up";
import assert from "node:assert";
import fs from "node:fs";
import {
dirname,
join,
} from "node:path";
import process from "node:process";
import {
fileURLToPath,
} from "node:url";
import {
readPackageUp,
} from "read-pkg-up";
import {
JsonValue,
ReadonlyDeep,
} from "type-fest";
import yargs, {
Argv,
} from "yargs";
// TODO: load package.json at compile time, use process.cwd() for resolving other paths.
const __dirname = dirname(fileURLToPath(import.meta.url));
const getJsonSync = (fileRelativePath: string): JsonValue => {
const resolvedPath = join(__dirname, fileRelativePath);
try {
// eslint-disable-next-line no-sync
const json = JSON.parse(fs.readFileSync(resolvedPath).toString()) as JsonValue;
return json;
} catch (error: unknown) {
throw new Error(`Could not read JSON file ${JSON.stringify(resolvedPath)}: ${JSON.stringify(String(error))}`);
}
};
export type RuntimeConfiguration = {
address: number;
cmd: string;
control?: string;
product: number;
values: readonly number[];
vendor: number;
verbose: boolean;
};
export type RuntimeConfigurationKeys = keyof RuntimeConfiguration;
export type RuntimeConfigurationTypes = readonly number[] | number | string | boolean | undefined;
const getYargsArgv = async (): Promise<ReadonlyDeep<Argv["argv"]>> => {
const packageJsonResult = await readPackageUp({
cwd: __dirname,
});
assert(typeof packageJsonResult !== "undefined");
const {
bin,
description,
homepage,
version,
} = packageJsonResult.packageJson;
assert(typeof bin === "object");
assert(typeof description === "string");
assert(typeof homepage === "string");
assert(!version.startsWith("v"));
const appBinaryName = Object.keys(bin)[0];
assert(typeof appBinaryName === "string");
const epilogue = chalk.dim`uvcc Copyright © 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>\n\nThis program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See GPL-3.0 license for details.\n\nSee also: ${homepage}`;
let fromImplicitConfigFile = null;
const hasConfigFlag = process.argv.includes("--config");
if (hasConfigFlag) {
fromImplicitConfigFile = {};
} else {
const nearestConfigPath = findUpSync([
`.${appBinaryName}rc`,
`.${appBinaryName}rc.json`,
]);
const configFromNearestConfigPath = nearestConfigPath ? getJsonSync(nearestConfigPath) : {};
fromImplicitConfigFile = configFromNearestConfigPath;
assert(typeof fromImplicitConfigFile === "object");
assert(fromImplicitConfigFile !== null);
}
const parserRoot: Argv = yargs(process.argv.slice(2));
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
const parser = parserRoot
.strict()
.wrap(parserRoot.terminalWidth())
.config(fromImplicitConfigFile)
.config("config", "Load command arguments from a JSON file.", (argumentConfigPath) => {
const fromExplicitConfigFile = argumentConfigPath ? getJsonSync(argumentConfigPath) : {};
assert(typeof fromExplicitConfigFile === "object");
assert(fromExplicitConfigFile !== null);
return fromExplicitConfigFile;
})
.env(appBinaryName.toUpperCase())
.version(`v${version}`)
.usage(`${chalk.bold("$0")}: ${description}`)
.command("get <control>", "Get current control value.", (yargsToApplyTo) => {
yargsToApplyTo
.positional("control", {
demandOption: true,
describe: "Name of the control.",
type: "string",
});
})
.command("set <control> <value1> [value2]", "Set control value(s).", (yargsToApplyTo) => {
yargsToApplyTo
.positional("control", {
demandOption: true,
describe: "Name of the control.",
type: "string",
})
.positional("value1", {
demandOption: true,
describe: "Value to set.",
type: "number",
})
.positional("value2", {
demandOption: false,
describe: "Second value to set, if supported by the control.",
type: "number",
});
})
.command("range <control>", "Get possible range (min and max) for a control.", (yargsToApplyTo) => {
yargsToApplyTo
.positional("control", {
demandOption: true,
describe: "Name of the control.",
type: "string",
});
})
.command("ranges", "Get all ranges (min and max).")
.command("devices", "List connected UVC devices.")
.command("controls", "List all supported controls for the camera.")
.command("export", "Output configuration in JSON format, on stdout.")
.command("import", "Input configuration in JSON format, from stdin.")
.option("vendor", {
"default": 0,
describe: "Camera vendor id (vId).",
type: "number",
})
.option("product", {
"default": 0,
describe: "Camera product id (pId).",
type: "number",
})
.option("address", {
"default": 0,
describe: "Camera device address.",
type: "number",
})
.option("verbose", {
"default": false,
describe: "Enable verbose output.",
type: "boolean",
})
.demandCommand(1, 1, chalk.red("Please provide a single command."), chalk.red("Please provide a single command."))
.group(
[
"vendor",
"product",
"address",
],
chalk.bold("Device selection for multi-camera setups.") + "\n " + chalk.dim("Numbers in hex (0x000) or decimal (0000) format."))
.help()
.example("", "")
.example(chalk.bold("Basic usage:"), "")
.example("$0 controls", "Available controls for the camera.")
.example("$0 set auto_white_balance_temperature 0", "Turn off automatic color correction.")
.example("$0 set saturation 64", "Low color saturation (near grayscale).")
.example("$0 ranges", "List possible control ranges.")
.example("$0 set absolute_zoom 200", "Zoom in.")
.example("", "")
.example(chalk.bold("Automate config:"), "")
.example(chalk.dim("- Not all controls can be imported."), "")
.example(chalk.dim("- Control order matters."), "")
.example("$0 export > my-uvcc-export.json", "Save to file.")
.example("cat my-uvcc-export.json | $0 import", "Load from file.")
.example("", "")
.example(chalk.bold("Target a specific device:"), "")
.example(chalk.dim("- Only useful for multi-camera setups."), "")
.example(chalk.dim("- For same-model cameras, also specify address."), "")
.example(chalk.dim("- Alt. use system USB settings to find devices."), "")
.example("$0 devices", "List available cameras.")
.example("sudo $0 devices", "Avoid LIBUSB_ERROR_ACCESS.")
.example("$0 --vendor 0x46d --product 0x82d export", "")
.epilogue(epilogue);
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types */
return parser.parseAsync();
};
const mapArgv = async (argv: ReadonlyDeep<Argv["argv"]>): Promise<RuntimeConfiguration> => {
// NOTE HACK: workaround yargs not being consistent with yargs.cmd versus yargs._ for defined/non-defined commands.
const cmd = "cmd" in argv && typeof argv["cmd"] === "string"
? argv["cmd"]
: (
"_" in argv && typeof argv._[0] === "string"
? argv._[0]
: null
);
const {
address,
control,
product,
value1,
value2,
vendor,
verbose,
} = argv as Record<string, unknown>;
assert(typeof address === "number");
assert(typeof cmd === "string");
assert(typeof product === "number");
assert(typeof vendor === "number");
assert(typeof verbose === "boolean");
// NOTE: accept one value if the first is a number, two if both are numbers.
let values: readonly number[] = [];
if (typeof value1 === "number") {
values = typeof value2 === "number" ? [
value1,
value2,
] : [
value1,
];
}
const mappedArgv: RuntimeConfiguration = {
address,
cmd,
control: typeof control === "string" ? control : undefined,
product,
values,
vendor,
verbose,
};
return mappedArgv;
};
export default async function runtimeConfigurator(): Promise<RuntimeConfiguration> {
const rawArgv = await getYargsArgv();
const argv = await mapArgv(rawArgv);
return argv;
}
================================================
FILE: src/types/command.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import CameraHelper from "../camera-helper.js";
import {
RuntimeConfigurationKeys,
RuntimeConfigurationTypes,
} from "../runtime-configurator.js";
export type CommandName = string;
// NOTE HACK: magic string hack so the command manager can inject camera helper to command handlers which need it.
// eslint-disable-next-line @typescript-eslint/naming-convention
export const CommandHandlerArgumentCameraHelper = "cameraHelper";
export type CommandHandlerArgumentNames = RuntimeConfigurationKeys | typeof CommandHandlerArgumentCameraHelper;
export type CommandHandlerArgumentTypes = RuntimeConfigurationTypes | CameraHelper;
export type CommandHandlerLookup = Record<CommandHandlerArgumentNames, CommandHandlerArgumentTypes>;
export interface Command {
execute: (...args: readonly unknown[]) => Promise<unknown>;
getArguments: () => Promise<CommandHandlerArgumentNames[]>;
}
export type Commands = Record<string, Command>;
================================================
FILE: src/types/controls.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
ReadonlyDeep,
} from "type-fest";
export type UvccControlValue = number | readonly number[];
export type UvccControls = ReadonlyDeep<Record<string, UvccControlValue>>;
================================================
FILE: src/types/uvc-control.d.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare module "uvc-control" {
// TODO: move type declarations to uvc-control.
import UvcControlModule from "uvc-control";
import {
ReadonlyDeep,
} from "type-fest";
import {
usb,
} from "usb";
/* eslint-disable @typescript-eslint/member-ordering */
export default class Camera {
// eslint-disable-next-line @typescript-eslint/naming-convention
public static readonly REQUEST: ReadonlyDeep<RequestTypes>;
public static readonly controls: ReadonlyDeep<CameraControls>;
public readonly supportedControls: readonly ControlName[];
public readonly device: usb.Device;
constructor(options: ConstructorOptions);
public static discover(): Promise<readonly UvcDevice[]>;
get(name: ControlName): Promise<ReadonlyDeep<ControlValues>>;
range(name: ControlName): Promise<ReadonlyDeep<ControlRange>>;
set(name: ControlName, ...values: readonly ControlValue[]): Promise<readonly number[]>;
close(): Promise<void>;
}
/* eslint-enable @typescript-eslint/member-ordering */
export type UvcControl = typeof Camera;
export interface UvcDevice {
readonly name: string;
readonly deviceDescriptor: {
readonly idVendor: number;
readonly idProduct: number;
};
readonly deviceAddress: number;
}
export type RequestType = number;
export interface RequestTypes {
readonly "GET_CUR": RequestType;
readonly "GET_MAX": RequestType;
readonly "GET_MIN": RequestType;
readonly "SET_CUR": RequestType;
}
export interface ConstructorOptions {
readonly deviceAddress?: number;
readonly pid?: number;
readonly vid?: number;
}
export interface CameraControl {
readonly name: ControlName;
readonly requests: readonly RequestType[];
readonly optional_requests: readonly RequestType[];
}
export type CameraControls = Record<string, CameraControl>;
export type ControlName = string;
export type ControlValue = number;
export type ControlValues = Record<string, ControlValue>;
export interface ControlRange {
readonly max: number;
readonly min: number;
}
}
================================================
FILE: src/utilities/flatten-control-values.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
ReadonlyDeep,
} from "type-fest";
import {
ControlValues,
} from "uvc-control";
export default function flattenControlValues(valueObject: ReadonlyDeep<ControlValues>): number | readonly number[] {
const values = Object.values(valueObject);
const firstValue = values[0];
const value = values.length === 1 && typeof firstValue === "number"
? firstValue
// NOTE: presumably the same order has to be used when setting values later.
: values;
return value;
}
================================================
FILE: src/utilities/is-uvcc-control-value.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
UvccControlValue,
} from "../types/controls.js";
export default function isUvccControlValue(controlValues: unknown): controlValues is UvccControlValue {
return typeof controlValues === "number"
|| (
Array.isArray(controlValues)
&& controlValues.every((controlValue) => typeof controlValue === "number")
);
}
================================================
FILE: src/utilities/is-uvcc-controls.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
UvccControls,
} from "../types/controls.js";
import isUvccControlValue from "./is-uvcc-control-value.js";
export default function isUvccControls(controlValues: unknown): controlValues is UvccControls {
return typeof controlValues === "object"
&& controlValues !== null
&& Object
.entries(controlValues)
.every(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
([
controlName,
controlValues,
]) => typeof controlName === "string" && isUvccControlValue(controlValues),
);
}
================================================
FILE: src/utilities/to-formatted-hex.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export default function toFormattedHex(i: number, minimumDigits: number): string {
return `0x${i.toString(16).padStart(minimumDigits, "0")}`;
}
================================================
FILE: src/utilities/wrapped-error.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
export default class WrappedError extends Error {
constructor(public readonly innerError: ReadonlyDeep<Error>,
message: string,
) {
super(message);
assert(this.innerError instanceof Error);
}
override toString(): string {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
return `${super.toString()} (${JSON.stringify(String(this.innerError))})`;
}
}
================================================
FILE: src/uvc-device-lister.ts
================================================
/*
This file is part of uvcc -- USB Video Class (UVC) device configurator.
Copyright (C) 2018, 2019, 2020, 2021, 2022 Joel Purra <https://joelpurra.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import assert from "node:assert";
import {
ReadonlyDeep,
} from "type-fest";
import {
UvcControl,
} from "uvc-control";
export interface MappedUvcDevice {
readonly name: string;
readonly vendor: number;
readonly product: number;
readonly address: number;
}
export default class UvcDeviceLister {
constructor(
// eslint-disable-next-line @typescript-eslint/naming-convention
private readonly UvcControl: ReadonlyDeep<UvcControl>,
) {
assert.strictEqual(arguments.length, 1);
assert(typeof this.UvcControl === "function");
}
async get(): Promise<readonly MappedUvcDevice[]> {
const devices = await this.UvcControl.discover();
const output = devices.map((device) =>
({
// NOTE: outputting in human-readable "logical" non-alphabetical order.
name: device.name,
vendor: device.deviceDescriptor.idVendor,
// eslint-disable-next-line sort-keys
product: device.deviceDescriptor.idProduct,
// eslint-disable-next-line sort-keys
address: device.deviceAddress,
}));
return output;
}
}
================================================
FILE: tsconfig.json
================================================
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"module": "es2020",
"outDir": "dist",
"target": "es2018",
"lib": ["es2018"],
"esModuleInterop": true
},
"include": ["./src/**/*"]
}
gitextract_7tuha_tf/ ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .prettierignore ├── .xo-config.cjs ├── CHANGELOG.md ├── DEVELOP.md ├── LICENSE ├── README.md ├── USAGE.md ├── examples/ │ ├── README.md │ ├── elgato-facecam/ │ │ └── 4057-120/ │ │ ├── controls.json │ │ ├── devices.json │ │ ├── export.json │ │ ├── metadata.json │ │ └── ranges.json │ ├── logitech-c920/ │ │ └── 1133-2093/ │ │ ├── controls.json │ │ ├── demo/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── auto.json │ │ │ ├── cold.json │ │ │ ├── crazy.json │ │ │ ├── record-demo.sh │ │ │ └── warm.json │ │ ├── devices.json │ │ ├── export.json │ │ ├── metadata.json │ │ └── ranges.json │ ├── logitech-c922/ │ │ └── 1133-2140/ │ │ ├── controls.json │ │ ├── devices.json │ │ ├── export.json │ │ ├── metadata.json │ │ └── ranges.json │ ├── microsoft-1425/ │ │ ├── 1118-1906/ │ │ │ ├── controls.json │ │ │ ├── devices.json │ │ │ ├── export.json │ │ │ ├── metadata.json │ │ │ └── ranges.json │ │ └── 1118-2065/ │ │ ├── controls.json │ │ ├── devices.json │ │ ├── export.json │ │ ├── metadata.json │ │ └── ranges.json │ └── update-example.sh ├── package.json ├── src/ │ ├── camera-control-helper-factory.ts │ ├── camera-control-helper.ts │ ├── camera-factory.ts │ ├── camera-helper-factory.ts │ ├── camera-helper.ts │ ├── command-handlers/ │ │ ├── controls.ts │ │ ├── devices.ts │ │ ├── export.ts │ │ ├── get.ts │ │ ├── import.ts │ │ ├── range.ts │ │ ├── ranges.ts │ │ └── set.ts │ ├── command-handlers.ts │ ├── command-manager.ts │ ├── index.ts │ ├── output.ts │ ├── runtime-configurator.ts │ ├── types/ │ │ ├── command.ts │ │ ├── controls.ts │ │ └── uvc-control.d.ts │ ├── utilities/ │ │ ├── flatten-control-values.ts │ │ ├── is-uvcc-control-value.ts │ │ ├── is-uvcc-controls.ts │ │ ├── to-formatted-hex.ts │ │ └── wrapped-error.ts │ └── uvc-device-lister.ts └── tsconfig.json
SYMBOL INDEX (122 symbols across 26 files)
FILE: src/camera-control-helper-factory.ts
class CameraControlHelperFactory (line 29) | class CameraControlHelperFactory {
method constructor (line 30) | constructor(
method get (line 41) | async get(camera: ReadonlyDeep<Camera>): Promise<CameraControlHelperCl...
FILE: src/camera-control-helper.ts
type ControlFlags (line 34) | interface ControlFlags {
type ControlsFlags (line 40) | type ControlsFlags = Record<string, ControlFlags>;
class CameraControlHelper (line 42) | class CameraControlHelper {
method constructor (line 45) | constructor(
method getControlNames (line 55) | async getControlNames(): Promise<readonly string[]> {
method getGettableControlNames (line 61) | async getGettableControlNames(): Promise<readonly string[]> {
method getRangedControlNames (line 67) | async getRangedControlNames(): Promise<readonly string[]> {
method getSettableControlNames (line 73) | async getSettableControlNames(): Promise<readonly string[]> {
method isGettableControl (line 79) | private isGettableControl(control: ReadonlyDeep<CameraControl>) {
method isRangedControl (line 84) | private isRangedControl(control: ReadonlyDeep<CameraControl>) {
method isSettableControl (line 90) | private isSettableControl(control: ReadonlyDeep<CameraControl>) {
method mapSupportedControls (line 100) | private async mapSupportedControls() {
method getSupportedControls (line 153) | private async getSupportedControls() {
method getGettableControls (line 161) | private async getGettableControls() {
method getRangedControls (line 167) | private async getRangedControls() {
method getSettableControls (line 173) | private async getSettableControls() {
FILE: src/camera-factory.ts
type GetFunctionArguments (line 32) | interface GetFunctionArguments {
class CameraFactory (line 38) | class CameraFactory {
method constructor (line 39) | constructor(
method get (line 48) | async get(vendor: number | null, product: number | null, address: numb...
method createWrappedError (line 97) | private createWrappedError(error: ReadonlyDeep<Error>, getFunctionArgu...
FILE: src/camera-helper-factory.ts
class CameraHelperFactory (line 29) | class CameraHelperFactory {
method constructor (line 30) | constructor(
method get (line 42) | async get(camera: ReadonlyDeep<Camera>): Promise<CameraHelperClass> {
FILE: src/camera-helper.ts
type ControlsValues (line 38) | type ControlsValues = Record<string, ControlValues>;
type ControlRanges (line 39) | type ControlRanges = Record<string, ControlRange>;
class CameraHelper (line 41) | class CameraHelper {
method constructor (line 42) | constructor(private readonly output: ReadonlyDeep<Output>, private rea...
method getValues (line 49) | async getValues(controlName: ControlName): Promise<ReadonlyDeep<Contro...
method getRange (line 61) | async getRange(controlName: ControlName): Promise<ReadonlyDeep<Control...
method setValues (line 73) | async setValues(controlName: ControlName, values: readonly ControlValu...
method getControlNames (line 85) | async getControlNames(): Promise<readonly ControlName[]> {
method getRanges (line 89) | async getRanges(): Promise<ReadonlyDeep<ControlRanges>> {
method getSettableControls (line 108) | async getSettableControls(): Promise<ReadonlyDeep<ControlsValues>> {
method setControls (line 127) | async setControls(configuration: ReadonlyDeep<UvccControls>): Promise<...
FILE: src/command-handlers.ts
class CommandHandlers (line 31) | class CommandHandlers {
method constructor (line 32) | constructor(private readonly output: Output, private readonly commands...
method has (line 38) | async has(commandName: CommandName): Promise<boolean> {
method execute (line 47) | async execute(commandName: CommandName, ...args: readonly unknown[]): ...
method getArguments (line 60) | async getArguments(commandName: CommandName): Promise<CommandHandlerAr...
FILE: src/command-handlers/controls.ts
class ControlsCommand (line 31) | class ControlsCommand implements Command {
method constructor (line 32) | constructor() {
method getArguments (line 36) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 42) | async execute(...args: readonly unknown[]): Promise<unknown> {
FILE: src/command-handlers/devices.ts
class DevicesCommand (line 27) | class DevicesCommand implements Command {
method constructor (line 28) | constructor(private readonly uvcDeviceLister: UvcDeviceLister) {
method getArguments (line 33) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 37) | async execute(): Promise<unknown> {
FILE: src/command-handlers/export.ts
class ExportCommand (line 36) | class ExportCommand implements Command {
method constructor (line 37) | constructor() {
method getArguments (line 41) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 47) | async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<UvccC...
FILE: src/command-handlers/get.ts
class GetCommand (line 35) | class GetCommand implements Command {
method constructor (line 36) | constructor() {
method getArguments (line 40) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 47) | async execute(...args: readonly unknown[]): Promise<number | readonly ...
FILE: src/command-handlers/import.ts
class ImportCommand (line 35) | class ImportCommand implements Command {
method constructor (line 36) | constructor() {
method getArguments (line 40) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 46) | async execute(...args: readonly unknown[]): Promise<void> {
FILE: src/command-handlers/range.ts
class RangeCommand (line 35) | class RangeCommand implements Command {
method constructor (line 36) | constructor() {
method getArguments (line 40) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 47) | async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<Contr...
FILE: src/command-handlers/ranges.ts
class RangesCommand (line 34) | class RangesCommand implements Command {
method constructor (line 35) | constructor() {
method getArguments (line 39) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 45) | async execute(...args: readonly unknown[]): Promise<ReadonlyDeep<Contr...
FILE: src/command-handlers/set.ts
class SetCommand (line 35) | class SetCommand implements Command {
method constructor (line 36) | constructor() {
method getArguments (line 40) | async getArguments(): Promise<CommandHandlerArgumentNames[]> {
method execute (line 48) | async execute(...args: readonly unknown[]): Promise<void> {
FILE: src/command-manager.ts
class CommandManager (line 38) | class CommandManager {
method constructor (line 39) | constructor(private readonly output: Output, private readonly cameraFa...
method execute (line 47) | async execute(runtimeConfig: ReadonlyDeep<RuntimeConfiguration>): Prom...
FILE: src/output.ts
class Output (line 21) | class Output {
method constructor (line 22) | constructor(public enableVerboseOutput: boolean) {
method normal (line 27) | normal(...args: readonly unknown[]): void {
method error (line 31) | error(...args: readonly unknown[]): void {
method warning (line 35) | warning(...args: readonly unknown[]): void {
method verbose (line 39) | verbose(...args: readonly unknown[]): void {
method consoleLog (line 47) | private consoleLog(...args: readonly unknown[]) {
method consoleError (line 52) | private consoleError(...args: readonly unknown[]) {
method consoleWarn (line 57) | private consoleWarn(...args: readonly unknown[]) {
FILE: src/runtime-configurator.ts
type RuntimeConfiguration (line 60) | type RuntimeConfiguration = {
type RuntimeConfigurationKeys (line 69) | type RuntimeConfigurationKeys = keyof RuntimeConfiguration;
type RuntimeConfigurationTypes (line 70) | type RuntimeConfigurationTypes = readonly number[] | number | string | b...
function runtimeConfigurator (line 280) | async function runtimeConfigurator(): Promise<RuntimeConfiguration> {
FILE: src/types/command.ts
type CommandName (line 25) | type CommandName = string;
type CommandHandlerArgumentNames (line 30) | type CommandHandlerArgumentNames = RuntimeConfigurationKeys | typeof Com...
type CommandHandlerArgumentTypes (line 31) | type CommandHandlerArgumentTypes = RuntimeConfigurationTypes | CameraHel...
type CommandHandlerLookup (line 32) | type CommandHandlerLookup = Record<CommandHandlerArgumentNames, CommandH...
type Command (line 34) | interface Command {
type Commands (line 39) | type Commands = Record<string, Command>;
FILE: src/types/controls.ts
type UvccControlValue (line 23) | type UvccControlValue = number | readonly number[];
type UvccControls (line 24) | type UvccControls = ReadonlyDeep<Record<string, UvccControlValue>>;
FILE: src/types/uvc-control.d.ts
class Camera (line 31) | class Camera {
type UvcControl (line 50) | type UvcControl = typeof Camera;
type UvcDevice (line 52) | interface UvcDevice {
type RequestType (line 61) | type RequestType = number;
type RequestTypes (line 63) | interface RequestTypes {
type ConstructorOptions (line 70) | interface ConstructorOptions {
type CameraControl (line 76) | interface CameraControl {
type CameraControls (line 82) | type CameraControls = Record<string, CameraControl>;
type ControlName (line 84) | type ControlName = string;
type ControlValue (line 85) | type ControlValue = number;
type ControlValues (line 86) | type ControlValues = Record<string, ControlValue>;
type ControlRange (line 87) | interface ControlRange {
FILE: src/utilities/flatten-control-values.ts
function flattenControlValues (line 26) | function flattenControlValues(valueObject: ReadonlyDeep<ControlValues>):...
FILE: src/utilities/is-uvcc-control-value.ts
function isUvccControlValue (line 23) | function isUvccControlValue(controlValues: unknown): controlValues is Uv...
FILE: src/utilities/is-uvcc-controls.ts
function isUvccControls (line 24) | function isUvccControls(controlValues: unknown): controlValues is UvccCo...
FILE: src/utilities/to-formatted-hex.ts
function toFormattedHex (line 19) | function toFormattedHex(i: number, minimumDigits: number): string {
FILE: src/utilities/wrapped-error.ts
class WrappedError (line 24) | class WrappedError extends Error {
method constructor (line 25) | constructor(public readonly innerError: ReadonlyDeep<Error>,
method toString (line 33) | override toString(): string {
FILE: src/uvc-device-lister.ts
type MappedUvcDevice (line 27) | interface MappedUvcDevice {
class UvcDeviceLister (line 34) | class UvcDeviceLister {
method constructor (line 35) | constructor(
method get (line 43) | async get(): Promise<readonly MappedUvcDevice[]> {
Condensed preview — 73 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (161K chars).
[
{
"path": ".editorconfig",
"chars": 222,
"preview": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\nindent_style = tab\ninsert_final_newline = true\ntrim_trailing_whitespac"
},
{
"path": ".gitattributes",
"chars": 19,
"preview": "* text=auto eol=lf\n"
},
{
"path": ".gitignore",
"chars": 41,
"preview": "dist/\nnode_modules/\n.uvccrc\n.uvccrc.json\n"
},
{
"path": ".prettierignore",
"chars": 25,
"preview": "dist/\nexamples/**/*.json\n"
},
{
"path": ".xo-config.cjs",
"chars": 848,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "CHANGELOG.md",
"chars": 8777,
"preview": "# [`uvcc`](https://joelpurra.com/projects/uvcc/) changelog\n\nSee [full list of commits](https://github.com/joelpurra/uvcc"
},
{
"path": "DEVELOP.md",
"chars": 2692,
"preview": "# [`uvcc`](https://joelpurra.com/projects/uvcc/) development\n\nGet the source code from the [`uvcc` repository](https://g"
},
{
"path": "LICENSE",
"chars": 35149,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "README.md",
"chars": 4024,
"preview": "<p align=\"center\">\n <a href=\"https://files.joelpurra.com/projects/uvcc/demo/2020-09-02/uvcc-demo.2020-09-02.mp4\"><img s"
},
{
"path": "USAGE.md",
"chars": 7433,
"preview": "# [`uvcc`](https://joelpurra.com/projects/uvcc/) usage\n\nBy default, the first detected UVC camera will be used. See [con"
},
{
"path": "examples/README.md",
"chars": 3167,
"preview": "# [`uvcc`](https://joelpurra.com/projects/uvcc/) output examples\n\nA small sample of `uvcc` camera control output. See in"
},
{
"path": "examples/elgato-facecam/4057-120/controls.json",
"chars": 228,
"preview": "[\n \"absolute_exposure_time\",\n \"absolute_zoom\",\n \"auto_exposure_mode\",\n \"auto_white_balance_temperature\",\n \"brightne"
},
{
"path": "examples/elgato-facecam/4057-120/devices.json",
"chars": 99,
"preview": "[\n {\n \"name\": \"Elgato Facecam\",\n \"vendor\": 4057,\n \"product\": 120,\n \"address\": 5\n }\n]\n"
},
{
"path": "examples/elgato-facecam/4057-120/export.json",
"chars": 265,
"preview": "{\n \"absolute_exposure_time\": 156,\n \"absolute_zoom\": 1,\n \"auto_exposure_mode\": 2,\n \"auto_white_balance_temperature\": "
},
{
"path": "examples/elgato-facecam/4057-120/metadata.json",
"chars": 201,
"preview": "{\n \"node\": \"v18.12.1\",\n \"npm\": \"8.19.2\",\n \"uname\": \"Linux dooderson-ThinkPad-T490 5.15.0-56-generic #62-Ubuntu SMP Tu"
},
{
"path": "examples/elgato-facecam/4057-120/ranges.json",
"chars": 395,
"preview": "{\n \"absolute_exposure_time\": {\n \"min\": 1,\n \"max\": 2500\n },\n \"absolute_zoom\": {\n \"min\": 1,\n \"max\": 31\n },"
},
{
"path": "examples/logitech-c920/1133-2093/controls.json",
"chars": 353,
"preview": "[\n \"absolute_exposure_time\",\n \"absolute_focus\",\n \"absolute_pan_tilt\",\n \"absolute_zoom\",\n \"auto_exposure_mode\",\n \"a"
},
{
"path": "examples/logitech-c920/1133-2093/demo/.gitignore",
"chars": 11,
"preview": "recording/\n"
},
{
"path": "examples/logitech-c920/1133-2093/demo/README.md",
"chars": 1034,
"preview": "# [`uvcc`](https://joelpurra.com/projects/uvcc/) demo recording\n\nScripted (repeatable) demo recording showcasing `uvcc` "
},
{
"path": "examples/logitech-c920/1133-2093/demo/auto.json",
"chars": 282,
"preview": "{\n \"absolute_pan_tilt\": [\n 0,\n 0\n ],\n \"absolute_zoom\": 100,\n \"auto_exposure_mode\": 8,\n \"auto_exposure_priorit"
},
{
"path": "examples/logitech-c920/1133-2093/demo/cold.json",
"chars": 79,
"preview": "{\n \"auto_white_balance_temperature\": 0,\n \"white_balance_temperature\": 2000\n}\n"
},
{
"path": "examples/logitech-c920/1133-2093/demo/crazy.json",
"chars": 243,
"preview": "{\n \"absolute_zoom\": 500,\n \"auto_exposure_mode\": 1,\n \"auto_focus\": 0,\n \"auto_white_balance_temperature\": 0,\n \"bright"
},
{
"path": "examples/logitech-c920/1133-2093/demo/record-demo.sh",
"chars": 4743,
"preview": "#!/usr/bin/env bash\n\nset -o errexit\nset -o noclobber\nset -o nounset\nset -o pipefail\n\nfunction die() {\n\techo \"FATAL:\" \"$@"
},
{
"path": "examples/logitech-c920/1133-2093/demo/warm.json",
"chars": 79,
"preview": "{\n \"auto_white_balance_temperature\": 0,\n \"white_balance_temperature\": 6500\n}\n"
},
{
"path": "examples/logitech-c920/1133-2093/devices.json",
"chars": 105,
"preview": "[\n {\n \"name\": \"HD Pro Webcam C920\",\n \"vendor\": 1133,\n \"product\": 2093,\n \"address\": 66\n }\n]\n"
},
{
"path": "examples/logitech-c920/1133-2093/export.json",
"chars": 434,
"preview": "{\n \"absolute_exposure_time\": 333,\n \"absolute_focus\": 0,\n \"absolute_pan_tilt\": [\n 0,\n 0\n ],\n \"absolute_zoom\": "
},
{
"path": "examples/logitech-c920/1133-2093/metadata.json",
"chars": 187,
"preview": "{\n \"node\": \"v18.1.0\",\n \"npm\": \"8.8.0\",\n \"uname\": \"Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55"
},
{
"path": "examples/logitech-c920/1133-2093/ranges.json",
"chars": 686,
"preview": "{\n \"absolute_exposure_time\": {\n \"min\": 3,\n \"max\": 2047\n },\n \"absolute_focus\": {\n \"min\": 0,\n \"max\": 250\n "
},
{
"path": "examples/logitech-c922/1133-2140/controls.json",
"chars": 353,
"preview": "[\n \"absolute_exposure_time\",\n \"absolute_focus\",\n \"absolute_pan_tilt\",\n \"absolute_zoom\",\n \"auto_exposure_mode\",\n \"a"
},
{
"path": "examples/logitech-c922/1133-2140/devices.json",
"chars": 109,
"preview": "[\n {\n \"name\": \"C922 Pro Stream Webcam\",\n \"vendor\": 1133,\n \"product\": 2140,\n \"address\": 43\n }\n]\n"
},
{
"path": "examples/logitech-c922/1133-2140/export.json",
"chars": 433,
"preview": "{\n \"absolute_exposure_time\": 250,\n \"absolute_focus\": 0,\n \"absolute_pan_tilt\": [\n 0,\n 0\n ],\n \"absolute_zoom\": "
},
{
"path": "examples/logitech-c922/1133-2140/metadata.json",
"chars": 187,
"preview": "{\n \"node\": \"v18.1.0\",\n \"npm\": \"8.8.0\",\n \"uname\": \"Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55"
},
{
"path": "examples/logitech-c922/1133-2140/ranges.json",
"chars": 686,
"preview": "{\n \"absolute_exposure_time\": {\n \"min\": 3,\n \"max\": 2047\n },\n \"absolute_focus\": {\n \"min\": 0,\n \"max\": 250\n "
},
{
"path": "examples/microsoft-1425/1118-1906/controls.json",
"chars": 315,
"preview": "[\n \"absolute_exposure_time\",\n \"absolute_focus\",\n \"absolute_pan_tilt\",\n \"absolute_zoom\",\n \"auto_exposure_mode\",\n \"a"
},
{
"path": "examples/microsoft-1425/1118-1906/devices.json",
"chars": 116,
"preview": "[\n {\n \"name\": \"Microsoft® LifeCam Studio(TM)\",\n \"vendor\": 1118,\n \"product\": 1906,\n \"address\": 28\n }\n]\n"
},
{
"path": "examples/microsoft-1425/1118-1906/export.json",
"chars": 384,
"preview": "{\n \"absolute_exposure_time\": 156,\n \"absolute_focus\": 0,\n \"absolute_pan_tilt\": [\n 0,\n 0\n ],\n \"absolute_zoom\": "
},
{
"path": "examples/microsoft-1425/1118-1906/metadata.json",
"chars": 206,
"preview": "{\n \"node\": \"v16.6.0\",\n \"npm\": \"7.20.3\",\n \"uname\": \"Darwin MacBook-Pro 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8"
},
{
"path": "examples/microsoft-1425/1118-1906/ranges.json",
"chars": 643,
"preview": "{\n \"absolute_exposure_time\": {\n \"min\": 1,\n \"max\": 10000\n },\n \"absolute_focus\": {\n \"min\": 0,\n \"max\": 40\n "
},
{
"path": "examples/microsoft-1425/1118-2065/controls.json",
"chars": 315,
"preview": "[\n \"absolute_exposure_time\",\n \"absolute_focus\",\n \"absolute_pan_tilt\",\n \"absolute_zoom\",\n \"auto_exposure_mode\",\n \"a"
},
{
"path": "examples/microsoft-1425/1118-2065/devices.json",
"chars": 116,
"preview": "[\n {\n \"name\": \"Microsoft® LifeCam Studio(TM)\",\n \"vendor\": 1118,\n \"product\": 2065,\n \"address\": 38\n }\n]\n"
},
{
"path": "examples/microsoft-1425/1118-2065/export.json",
"chars": 384,
"preview": "{\n \"absolute_exposure_time\": 156,\n \"absolute_focus\": 0,\n \"absolute_pan_tilt\": [\n 0,\n 0\n ],\n \"absolute_zoom\": "
},
{
"path": "examples/microsoft-1425/1118-2065/metadata.json",
"chars": 187,
"preview": "{\n \"node\": \"v18.1.0\",\n \"npm\": \"8.8.0\",\n \"uname\": \"Linux compendious 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55"
},
{
"path": "examples/microsoft-1425/1118-2065/ranges.json",
"chars": 643,
"preview": "{\n \"absolute_exposure_time\": {\n \"min\": 1,\n \"max\": 10000\n },\n \"absolute_focus\": {\n \"min\": 0,\n \"max\": 40\n "
},
{
"path": "examples/update-example.sh",
"chars": 820,
"preview": "#!/usr/bin/env bash\n\nset -o errexit\nset -o noclobber\nset -o nounset\nset -o pipefail\n\ndeclare -r SCRIPT_BASE=\"${BASH_SOUR"
},
{
"path": "package.json",
"chars": 3118,
"preview": "{\n \"name\": \"uvcc\",\n \"version\": \"7.0.0\",\n \"description\": \"USB Video Class (UVC) device configurator for the command li"
},
{
"path": "src/camera-control-helper-factory.ts",
"chars": 1737,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/camera-control-helper.ts",
"chars": 5420,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/camera-factory.ts",
"chars": 4711,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/camera-helper-factory.ts",
"chars": 1928,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/camera-helper.ts",
"chars": 5713,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/controls.ts",
"chars": 1520,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/devices.ts",
"chars": 1400,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/export.ts",
"chars": 2050,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/get.ts",
"chars": 1763,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/import.ts",
"chars": 2203,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/range.ts",
"chars": 1641,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/ranges.ts",
"chars": 1541,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers/set.ts",
"chars": 1652,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-handlers.ts",
"chars": 2095,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/command-manager.ts",
"chars": 3831,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/index.ts",
"chars": 4044,
"preview": "#!/usr/bin/env node\n/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019,"
},
{
"path": "src/output.ts",
"chars": 1733,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/runtime-configurator.ts",
"chars": 8754,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/types/command.ts",
"chars": 1699,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/types/controls.ts",
"chars": 949,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/types/uvc-control.d.ts",
"chars": 2787,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/utilities/flatten-control-values.ts",
"chars": 1248,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/utilities/is-uvcc-control-value.ts",
"chars": 1101,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/utilities/is-uvcc-controls.ts",
"chars": 1319,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/utilities/to-formatted-hex.ts",
"chars": 915,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/utilities/wrapped-error.ts",
"chars": 1232,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "src/uvc-device-lister.ts",
"chars": 1806,
"preview": "/*\nThis file is part of uvcc -- USB Video Class (UVC) device configurator.\nCopyright (C) 2018, 2019, 2020, 2021, 2022 Jo"
},
{
"path": "tsconfig.json",
"chars": 220,
"preview": "{\n \"extends\": \"@sindresorhus/tsconfig\",\n \"compilerOptions\": {\n \"module\": \"es2020\",\n \"outDir\": \"dist\",\n \"targe"
}
]
About this extraction
This page contains the full source code of the joelpurra/uvcc GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 73 files (144.4 KB), approximately 39.3k tokens, and a symbol index with 122 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.