adshot 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ _internal/
2
+ .work/
3
+ .venv/
4
+ __pycache__/
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ build/
8
+ dist/
9
+ .env
10
+ .env.*
adshot-0.2.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ https://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ include SKILL.md
2
+ include .gitignore
3
+ include examples/perfume/storyboard.csv
4
+ recursive-include tests *.py
5
+ prune _internal
6
+ prune .work
adshot-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: adshot
3
+ Version: 0.2.0
4
+ Summary: Storyboard, price, render, and revise product ads shot by shot.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: mcp>=1.9
10
+ Requires-Dist: tomli>=2; python_version < "3.11"
11
+ Dynamic: license-file
12
+
13
+ # adshot
14
+
15
+ [![Six product ads made with adshot: skincare, jewelry, coffee, pet, candle, earbuds](docs/examples.jpg)](https://toporush.com/adshot/#work)
16
+
17
+ *Six 16-second ads made with adshot, about $1.25 of model cost each. [Watch them](https://toporush.com/adshot/#work). Brands are fictional.*
18
+
19
+ Turn a product photograph and a brief into a shot list, see the estimated video cost, and render a short ad. Each row in the storyboard has a stable ID. Edit the camera move in S03 and the next run prices and renders S03 while reusing the other shots.
20
+
21
+ **See it in action:** a real Claude Code session that turns one product photo into a 16-second ad for $1.58 in model cost, including one redo: <https://toporush.com/adshot/>
22
+
23
+ **Get a key:** adshot defaults to [OpenLux](https://www.openlux.ai), one key for Seedance and other video models. Any compatible endpoint works; see [Providers, models, and prices](#providers-models-and-prices).
24
+
25
+ ## Try it offline
26
+
27
+ Run these commands from the repository with Python 3.10 or newer.
28
+
29
+ ```sh
30
+ pip install -e .
31
+ adshot init demo
32
+ adshot estimate
33
+ cd demo
34
+ adshot status
35
+ ```
36
+
37
+ The starter project contains four 4-second perfume shots, totaling 16 seconds. With the default Fast model, the example estimates **345,600 tokens and $1.2476** at the verified OpenLux rate of $3.61 per million tokens. You can edit the CSV and repeat the estimate without a key. Running `estimate` in the parent directory selects a project only when exactly one visible child contains an `adshot.toml`. Run all production commands inside the project. [Perfume storyboard](examples/perfume/storyboard.csv)
38
+
39
+ To use the agent skill, point your coding agent at this repository's `SKILL.md` and give it the brief and image path. The wheel also installs the skill under `share/adshot/SKILL.md` in the Python environment.
40
+
41
+ ## Use it from an MCP client
42
+
43
+ adshot also runs as an MCP server, so Claude Desktop, Cursor, and other MCP clients can make the ad without a terminal. Add this to the client's MCP configuration:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "adshot": {
49
+ "command": "uvx",
50
+ "args": ["--from", "git+https://github.com/TopoRush/adshot", "adshot", "mcp"],
51
+ "env": { "ADSHOT_API_KEY": "your video provider key" }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ The server offers seven tools: `init_project`, `get_storyboard`, `set_storyboard`, `estimate`, `render`, `status`, and `stitch`. They run the same commands described below, on a project folder you name by absolute path.
58
+
59
+ - `estimate` and `set_storyboard` return the price and spend nothing. They work without a key.
60
+ - `render` takes `approved_usd` and refuses to start if the current estimate is higher. Pass the total the user agreed to. It can never exceed `budget_usd` in `adshot.toml`, and no tool edits that file.
61
+ - `render` returns at once and works in the background. `status` shows progress. If the client closes mid-render, the saved task IDs let the next `render` resume the same jobs. A shot interrupted in the instant of submission is held as `needs_reconcile` and is not sent again.
62
+ - Resolving an uncertain submission (`run --reconcile`) and `abandon` stay on the command line, because each needs a person to check the provider's task history first.
63
+
64
+ Stitching needs FFmpeg on PATH, as in the command-line flow.
65
+
66
+ <!-- mcp-name: io.github.TopoRush/adshot -->
67
+
68
+ ## Make an ad
69
+
70
+ 1. Put a product image in the project. Write the rows yourself or have Claude Code, Codex, or OpenCode follow the agent instructions. For a reference ad, inspect the cuts and movement, then describe the shot sequence in the CSV. Use a product photo or an extracted still as the first frame where appropriate. [Agent skill](SKILL.md)
71
+ 2. Optionally, use the vision planner below. It sends the image and brief to the configured chat endpoint and replaces `storyboard.csv` after validating the reply. Save a copy first if you want to keep an earlier draft. The chat provider bills this call separately from the video estimate.
72
+ 3. Review the estimate and the rates in `adshot.toml`. Provide `ADSHOT_API_KEY` through your shell environment or secret manager when ready to render.
73
+ 4. Review the MP4s in `shots/`. Edit the rows that need a new take, estimate again, and stitch the approved shots.
74
+
75
+ ```sh
76
+ adshot plan --image product.jpg --brief "A warm, understated launch film for an amber perfume." --shots 4 --seconds 16
77
+ adshot estimate
78
+ adshot run --budget 5
79
+ adshot status
80
+
81
+ # After editing the two rows
82
+ adshot estimate --only S03,S04
83
+ adshot run --only S03,S04
84
+ adshot stitch --out ad.mp4
85
+ ```
86
+
87
+ `run` prints a quote and asks for confirmation. Use `--yes` after approving the quoted spend in an agent session. `--budget` overrides the project cap for this invocation. The cap applies to estimated **new video submissions** in that invocation. Provider rounding, adaptive dimensions, actual token usage, and unverified prices can affect the invoice.
88
+
89
+ If any new submission uses an unverified rate, review that rate and add `--accept-unverified-prices`. This approval is required even with `--yes`. Resuming or skipping a shot adds zero new spend.
90
+
91
+ Stitching requires an FFmpeg executable on PATH with H.264 and AAC encoders. It fits each shot onto the first shot's canvas, preserves proportions, pads silent sections and exports a 24 fps MP4 in storyboard order. An encoder error preserves the previous export.
92
+
93
+ ## Storyboard fields
94
+
95
+ Use UTF-8 CSV and quote any field containing commas, newlines, or quotation marks.
96
+
97
+ | Column | Meaning |
98
+ | --- | --- |
99
+ | `shot_id` | Stable, unique file stem such as `S03`. Use letters, digits, underscores, and hyphens. |
100
+ | `prompt` | A visible action, camera movement, and product details to preserve. |
101
+ | `seconds` | Positive whole seconds of output. Seedance accepts 4–15 seconds per shot; the planner drafts 4–6. |
102
+ | `image` | Optional local JPEG, PNG, WebP, GIF, or HTTPS first-frame URL. Relative paths resolve from the project. |
103
+ | `model`, `resolution`, `ratio` | Optional per-shot overrides. Empty fields inherit the project settings. |
104
+ | `notes` | Editorial notes. Changing notes or reordering rows adds no render cost. |
105
+
106
+ The signature covers the prompt, duration, first-frame content hash or URL, effective model, resolution, and ratio. Use a new URL when replacing the contents of a remote image at the same address. A successful revision moves the old MP4 to `shots/S03.v1.mp4`, then `.v2.mp4` and so on.
107
+
108
+ ## Providers, models, and prices
109
+
110
+ adshot defaults to OpenLux because one key covers several Chinese video models. The maintainers may receive a referral share from OpenLux for accounts opened through links in this repository. This never changes adshot's pricing logic or behavior, and any compatible provider works with one config line.
111
+
112
+ With the generated `base_url = ""`, changing one line to `provider = "ark"` selects Volcano Ark official. Alternatively, set `base_url` to your compatible service's HTTPS origin. Video and planner base URLs allow HTTP only on `localhost` and `127.0.0.1` for local testing. The video client appends `/api/v3/contents/generations/tasks`, reads `ADSHOT_API_KEY` from the environment, and uses Bearer authentication. Generation uses silent video and disables the watermark flag.
113
+
114
+ | Provider | Default API origin |
115
+ | --- | --- |
116
+ | OpenLux | `https://api.openlux.ai` |
117
+ | Volcano Ark | `https://ark.cn-beijing.volces.com` |
118
+
119
+ | Model ID | Use | Default USD per million tokens |
120
+ | --- | --- | ---: |
121
+ | `doubao-seedance-2-0-mini-260615` | Draft, up to 720p | 2.41, measured on OpenLux |
122
+ | `doubao-seedance-2-0-fast-260128` | Default, up to 720p | 3.61, measured on OpenLux |
123
+ | `doubao-seedance-2-0-260128` | Standard, supports 1080p | 8.00, unverified placeholder |
124
+ | `doubao-seedance-2-5-260628` | Pro, first-frame shots require `ratio = "adaptive"` | 12.00, unverified placeholder |
125
+
126
+ Choose a model with the `model` line in `adshot.toml`. Each price entry has an editable `usd_per_million` and `verified` flag. Set the entry's `base_url` to the endpoint whose rate you confirmed. A provider change makes the shipped OpenLux measurement unverified at the new endpoint. For a custom model, add a price entry under its exact model ID.
127
+
128
+ The video estimate uses `(input_video_seconds + output_seconds) × width × height × 24 / 1024`. Text and still-image inputs have zero input video seconds. The reference-ad workflow uses the source as creative guidance. Adaptive estimates use the larger supported pixel area for the selected resolution.
129
+
130
+ On November 19, 2026, an OpenLux Mini text-only call at 480p, 9:16, and four seconds reported **40,594 tokens**, cost **$0.098**, and took about **140 seconds**. Using the 496 × 864 pixel bucket, adshot estimates **40,176 tokens** and **$0.0968**.
131
+
132
+ On November 19, 2026, four OpenLux Fast shots at 720p and 9:16, each four seconds long with a first-frame image, used **87,300 tokens per shot**. The **$1.26** total charge gives a rounded rate of **$3.61 per million tokens**.
133
+
134
+ The planner uses `plan_model` (default `gpt-4o-mini`). Its default `plan_base_url` is `{base_url}/v1` for OpenLux and `{base_url}/api/v3` for Ark. Set `plan_base_url` explicitly to use another vision-capable chat service. The planner appends `/chat/completions` and reads `ADSHOT_PLAN_KEY` first, then `ADSHOT_API_KEY`. The video client reads only `ADSHOT_API_KEY`.
135
+
136
+ ## Resume and reconcile
137
+
138
+ Keep `manifest.json`, `.adshot/`, and `shots/` with the project. Use a local filesystem shared by the runners. Each shot has an exclusive claim, and the manifest records submission intent before the paid POST. The provider task ID is the next durable update after a successful response. Different processes can work on the same project with the configured concurrency limit.
139
+
140
+ | Status | What the next run does |
141
+ | --- | --- |
142
+ | `pending` | Quotes a new submission. |
143
+ | `done` | Skips the matching downloaded video at zero new cost. |
144
+ | `changed` | Quotes a replacement and keeps the previous video until the new download is ready. |
145
+ | `running` | Resumes the saved task or yields to its active owner. A missing local download with a saved ID can be recovered the same way. |
146
+ | `needs_reconcile` | Holds the shot for a provider-history check. |
147
+ | `failed` | The provider reported failure, cancellation, or expiry, or you abandoned the attempt. A subsequent run can quote a new attempt. |
148
+
149
+ After an interrupted poll or download, run `adshot run` again. It polls the original task and downloads the temporary video URL immediately on success. If the brief changed while a task was running, adshot recovers that version first. The next estimate prices your edit. Restore the original endpoint and its key before resuming a task from a different provider.
150
+
151
+ Ctrl+C stops new submissions. Requests already in flight can still incur a charge, and adshot saves any task IDs they return. Task polling retries network errors and HTTP 5xx after 1, 3, and 9 seconds. Each paid POST is sent once.
152
+
153
+ On a polling timeout, adshot prints the last provider status and keeps the task ID. Check the task in provider history. If it cannot finish, or if a completed shot's local file is missing and its download URL has expired, run `adshot abandon S03` and type `RETRY` (or use `--confirm RETRY`). This marks the attempt failed locally and preserves its task ID and recorded usage. The provider may still bill the original task. Review `adshot estimate --only S03` before submitting a replacement.
154
+
155
+ If a submit might have reached the provider but the receipt was lost, check the provider's task history and reconcile the affected shot.
156
+
157
+ ```sh
158
+ adshot run --reconcile S03
159
+ ```
160
+
161
+ Paste the matching task ID to recover it with zero new submissions. If you have checked the provider's history and authorize another charge, type `RETRY S03` at the prompt. adshot shows the new quote and enforces the cap. Even `--yes` requires an explicit reconciliation decision. If the provider history is inconclusive, leave the shot on hold.
162
+
163
+ `status` calculates spend from provider-reported usage and the rate saved for each attempt. It retains earlier revisions, marks unverified rates, and shows `+ unknown` when the provider has supplied no token count. The provider's billing record is authoritative.
164
+
165
+ ## Development
166
+
167
+ Install pytest in your development environment, then run `pytest`. HTTP tests use mocked responses. The process tests terminate an actual worker in the uncertain submission window and run competing workers against a local receipt store. Installing FFmpeg enables an additional offline encode/decode test.
168
+
169
+ Licensed under the Apache License, Version 2.0. [License text](LICENSE)
adshot-0.2.0/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # adshot
2
+
3
+ [![Six product ads made with adshot: skincare, jewelry, coffee, pet, candle, earbuds](docs/examples.jpg)](https://toporush.com/adshot/#work)
4
+
5
+ *Six 16-second ads made with adshot, about $1.25 of model cost each. [Watch them](https://toporush.com/adshot/#work). Brands are fictional.*
6
+
7
+ Turn a product photograph and a brief into a shot list, see the estimated video cost, and render a short ad. Each row in the storyboard has a stable ID. Edit the camera move in S03 and the next run prices and renders S03 while reusing the other shots.
8
+
9
+ **See it in action:** a real Claude Code session that turns one product photo into a 16-second ad for $1.58 in model cost, including one redo: <https://toporush.com/adshot/>
10
+
11
+ **Get a key:** adshot defaults to [OpenLux](https://www.openlux.ai), one key for Seedance and other video models. Any compatible endpoint works; see [Providers, models, and prices](#providers-models-and-prices).
12
+
13
+ ## Try it offline
14
+
15
+ Run these commands from the repository with Python 3.10 or newer.
16
+
17
+ ```sh
18
+ pip install -e .
19
+ adshot init demo
20
+ adshot estimate
21
+ cd demo
22
+ adshot status
23
+ ```
24
+
25
+ The starter project contains four 4-second perfume shots, totaling 16 seconds. With the default Fast model, the example estimates **345,600 tokens and $1.2476** at the verified OpenLux rate of $3.61 per million tokens. You can edit the CSV and repeat the estimate without a key. Running `estimate` in the parent directory selects a project only when exactly one visible child contains an `adshot.toml`. Run all production commands inside the project. [Perfume storyboard](examples/perfume/storyboard.csv)
26
+
27
+ To use the agent skill, point your coding agent at this repository's `SKILL.md` and give it the brief and image path. The wheel also installs the skill under `share/adshot/SKILL.md` in the Python environment.
28
+
29
+ ## Use it from an MCP client
30
+
31
+ adshot also runs as an MCP server, so Claude Desktop, Cursor, and other MCP clients can make the ad without a terminal. Add this to the client's MCP configuration:
32
+
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "adshot": {
37
+ "command": "uvx",
38
+ "args": ["--from", "git+https://github.com/TopoRush/adshot", "adshot", "mcp"],
39
+ "env": { "ADSHOT_API_KEY": "your video provider key" }
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ The server offers seven tools: `init_project`, `get_storyboard`, `set_storyboard`, `estimate`, `render`, `status`, and `stitch`. They run the same commands described below, on a project folder you name by absolute path.
46
+
47
+ - `estimate` and `set_storyboard` return the price and spend nothing. They work without a key.
48
+ - `render` takes `approved_usd` and refuses to start if the current estimate is higher. Pass the total the user agreed to. It can never exceed `budget_usd` in `adshot.toml`, and no tool edits that file.
49
+ - `render` returns at once and works in the background. `status` shows progress. If the client closes mid-render, the saved task IDs let the next `render` resume the same jobs. A shot interrupted in the instant of submission is held as `needs_reconcile` and is not sent again.
50
+ - Resolving an uncertain submission (`run --reconcile`) and `abandon` stay on the command line, because each needs a person to check the provider's task history first.
51
+
52
+ Stitching needs FFmpeg on PATH, as in the command-line flow.
53
+
54
+ <!-- mcp-name: io.github.TopoRush/adshot -->
55
+
56
+ ## Make an ad
57
+
58
+ 1. Put a product image in the project. Write the rows yourself or have Claude Code, Codex, or OpenCode follow the agent instructions. For a reference ad, inspect the cuts and movement, then describe the shot sequence in the CSV. Use a product photo or an extracted still as the first frame where appropriate. [Agent skill](SKILL.md)
59
+ 2. Optionally, use the vision planner below. It sends the image and brief to the configured chat endpoint and replaces `storyboard.csv` after validating the reply. Save a copy first if you want to keep an earlier draft. The chat provider bills this call separately from the video estimate.
60
+ 3. Review the estimate and the rates in `adshot.toml`. Provide `ADSHOT_API_KEY` through your shell environment or secret manager when ready to render.
61
+ 4. Review the MP4s in `shots/`. Edit the rows that need a new take, estimate again, and stitch the approved shots.
62
+
63
+ ```sh
64
+ adshot plan --image product.jpg --brief "A warm, understated launch film for an amber perfume." --shots 4 --seconds 16
65
+ adshot estimate
66
+ adshot run --budget 5
67
+ adshot status
68
+
69
+ # After editing the two rows
70
+ adshot estimate --only S03,S04
71
+ adshot run --only S03,S04
72
+ adshot stitch --out ad.mp4
73
+ ```
74
+
75
+ `run` prints a quote and asks for confirmation. Use `--yes` after approving the quoted spend in an agent session. `--budget` overrides the project cap for this invocation. The cap applies to estimated **new video submissions** in that invocation. Provider rounding, adaptive dimensions, actual token usage, and unverified prices can affect the invoice.
76
+
77
+ If any new submission uses an unverified rate, review that rate and add `--accept-unverified-prices`. This approval is required even with `--yes`. Resuming or skipping a shot adds zero new spend.
78
+
79
+ Stitching requires an FFmpeg executable on PATH with H.264 and AAC encoders. It fits each shot onto the first shot's canvas, preserves proportions, pads silent sections and exports a 24 fps MP4 in storyboard order. An encoder error preserves the previous export.
80
+
81
+ ## Storyboard fields
82
+
83
+ Use UTF-8 CSV and quote any field containing commas, newlines, or quotation marks.
84
+
85
+ | Column | Meaning |
86
+ | --- | --- |
87
+ | `shot_id` | Stable, unique file stem such as `S03`. Use letters, digits, underscores, and hyphens. |
88
+ | `prompt` | A visible action, camera movement, and product details to preserve. |
89
+ | `seconds` | Positive whole seconds of output. Seedance accepts 4–15 seconds per shot; the planner drafts 4–6. |
90
+ | `image` | Optional local JPEG, PNG, WebP, GIF, or HTTPS first-frame URL. Relative paths resolve from the project. |
91
+ | `model`, `resolution`, `ratio` | Optional per-shot overrides. Empty fields inherit the project settings. |
92
+ | `notes` | Editorial notes. Changing notes or reordering rows adds no render cost. |
93
+
94
+ The signature covers the prompt, duration, first-frame content hash or URL, effective model, resolution, and ratio. Use a new URL when replacing the contents of a remote image at the same address. A successful revision moves the old MP4 to `shots/S03.v1.mp4`, then `.v2.mp4` and so on.
95
+
96
+ ## Providers, models, and prices
97
+
98
+ adshot defaults to OpenLux because one key covers several Chinese video models. The maintainers may receive a referral share from OpenLux for accounts opened through links in this repository. This never changes adshot's pricing logic or behavior, and any compatible provider works with one config line.
99
+
100
+ With the generated `base_url = ""`, changing one line to `provider = "ark"` selects Volcano Ark official. Alternatively, set `base_url` to your compatible service's HTTPS origin. Video and planner base URLs allow HTTP only on `localhost` and `127.0.0.1` for local testing. The video client appends `/api/v3/contents/generations/tasks`, reads `ADSHOT_API_KEY` from the environment, and uses Bearer authentication. Generation uses silent video and disables the watermark flag.
101
+
102
+ | Provider | Default API origin |
103
+ | --- | --- |
104
+ | OpenLux | `https://api.openlux.ai` |
105
+ | Volcano Ark | `https://ark.cn-beijing.volces.com` |
106
+
107
+ | Model ID | Use | Default USD per million tokens |
108
+ | --- | --- | ---: |
109
+ | `doubao-seedance-2-0-mini-260615` | Draft, up to 720p | 2.41, measured on OpenLux |
110
+ | `doubao-seedance-2-0-fast-260128` | Default, up to 720p | 3.61, measured on OpenLux |
111
+ | `doubao-seedance-2-0-260128` | Standard, supports 1080p | 8.00, unverified placeholder |
112
+ | `doubao-seedance-2-5-260628` | Pro, first-frame shots require `ratio = "adaptive"` | 12.00, unverified placeholder |
113
+
114
+ Choose a model with the `model` line in `adshot.toml`. Each price entry has an editable `usd_per_million` and `verified` flag. Set the entry's `base_url` to the endpoint whose rate you confirmed. A provider change makes the shipped OpenLux measurement unverified at the new endpoint. For a custom model, add a price entry under its exact model ID.
115
+
116
+ The video estimate uses `(input_video_seconds + output_seconds) × width × height × 24 / 1024`. Text and still-image inputs have zero input video seconds. The reference-ad workflow uses the source as creative guidance. Adaptive estimates use the larger supported pixel area for the selected resolution.
117
+
118
+ On November 19, 2026, an OpenLux Mini text-only call at 480p, 9:16, and four seconds reported **40,594 tokens**, cost **$0.098**, and took about **140 seconds**. Using the 496 × 864 pixel bucket, adshot estimates **40,176 tokens** and **$0.0968**.
119
+
120
+ On November 19, 2026, four OpenLux Fast shots at 720p and 9:16, each four seconds long with a first-frame image, used **87,300 tokens per shot**. The **$1.26** total charge gives a rounded rate of **$3.61 per million tokens**.
121
+
122
+ The planner uses `plan_model` (default `gpt-4o-mini`). Its default `plan_base_url` is `{base_url}/v1` for OpenLux and `{base_url}/api/v3` for Ark. Set `plan_base_url` explicitly to use another vision-capable chat service. The planner appends `/chat/completions` and reads `ADSHOT_PLAN_KEY` first, then `ADSHOT_API_KEY`. The video client reads only `ADSHOT_API_KEY`.
123
+
124
+ ## Resume and reconcile
125
+
126
+ Keep `manifest.json`, `.adshot/`, and `shots/` with the project. Use a local filesystem shared by the runners. Each shot has an exclusive claim, and the manifest records submission intent before the paid POST. The provider task ID is the next durable update after a successful response. Different processes can work on the same project with the configured concurrency limit.
127
+
128
+ | Status | What the next run does |
129
+ | --- | --- |
130
+ | `pending` | Quotes a new submission. |
131
+ | `done` | Skips the matching downloaded video at zero new cost. |
132
+ | `changed` | Quotes a replacement and keeps the previous video until the new download is ready. |
133
+ | `running` | Resumes the saved task or yields to its active owner. A missing local download with a saved ID can be recovered the same way. |
134
+ | `needs_reconcile` | Holds the shot for a provider-history check. |
135
+ | `failed` | The provider reported failure, cancellation, or expiry, or you abandoned the attempt. A subsequent run can quote a new attempt. |
136
+
137
+ After an interrupted poll or download, run `adshot run` again. It polls the original task and downloads the temporary video URL immediately on success. If the brief changed while a task was running, adshot recovers that version first. The next estimate prices your edit. Restore the original endpoint and its key before resuming a task from a different provider.
138
+
139
+ Ctrl+C stops new submissions. Requests already in flight can still incur a charge, and adshot saves any task IDs they return. Task polling retries network errors and HTTP 5xx after 1, 3, and 9 seconds. Each paid POST is sent once.
140
+
141
+ On a polling timeout, adshot prints the last provider status and keeps the task ID. Check the task in provider history. If it cannot finish, or if a completed shot's local file is missing and its download URL has expired, run `adshot abandon S03` and type `RETRY` (or use `--confirm RETRY`). This marks the attempt failed locally and preserves its task ID and recorded usage. The provider may still bill the original task. Review `adshot estimate --only S03` before submitting a replacement.
142
+
143
+ If a submit might have reached the provider but the receipt was lost, check the provider's task history and reconcile the affected shot.
144
+
145
+ ```sh
146
+ adshot run --reconcile S03
147
+ ```
148
+
149
+ Paste the matching task ID to recover it with zero new submissions. If you have checked the provider's history and authorize another charge, type `RETRY S03` at the prompt. adshot shows the new quote and enforces the cap. Even `--yes` requires an explicit reconciliation decision. If the provider history is inconclusive, leave the shot on hold.
150
+
151
+ `status` calculates spend from provider-reported usage and the rate saved for each attempt. It retains earlier revisions, marks unverified rates, and shows `+ unknown` when the provider has supplied no token count. The provider's billing record is authoritative.
152
+
153
+ ## Development
154
+
155
+ Install pytest in your development environment, then run `pytest`. HTTP tests use mocked responses. The process tests terminate an actual worker in the uncertain submission window and run competing workers against a local receipt store. Installing FFmpeg enables an additional offline encode/decode test.
156
+
157
+ Licensed under the Apache License, Version 2.0. [License text](LICENSE)
adshot-0.2.0/SKILL.md ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: adshot
3
+ description: Make or revise a short product ad from a product image, brief, or reference ad using adshot. Draft a CSV storyboard, quote the video cost, render approved shots, and stitch the reviewed cuts.
4
+ ---
5
+
6
+ # Produce a shot-by-shot ad
7
+
8
+ 1. **Inspect the source.** Read the brief and view the product image. Identify the pack shape, finish, label position, cap, and scale cues that must survive every cut. For a reference ad, inspect its pacing, framing, and transitions. Translate those observations into shot directions. The video endpoint accepts a still first frame.
9
+ 2. **Set up the project.** For a new project, run `adshot init <dir>` and enter that directory. For a revision, open its existing `storyboard.csv`, `adshot.toml`, and `adshot status`. Keep the existing shot IDs. Read the provider, model, resolution, rate verification flags, and per-run budget.
10
+ 3. **Write the storyboard.** Use the requested shot count and total duration. Four shots totaling 16 seconds are a practical default. Seedance accepts 4–15 whole seconds per shot; use 4–5 seconds for ad pacing and check the sum. Write UTF-8 CSV with the header below. Use a CSV writer for prompts containing commas. An agent can draft every row directly. If the user has authorized external chat planning, `adshot plan --image product.jpg --brief "..." --shots 4 --seconds 16` can generate a draft and replace the project CSV.
11
+
12
+ ```csv
13
+ shot_id,prompt,seconds,image,model,resolution,ratio,notes
14
+ ```
15
+
16
+ Give each shot one legible action. Specify framing, light direction, and one camera move or hold. For example, “Track along the beveled shoulder as a narrow reflection crosses the amber glass.” Anchor each product shot to the same bottle shape, cap, and label placement. Use a matching project image or HTTPS URL in `image` when a first frame helps. Keep captions, prices, and headlines in editorial notes for later compositing. Avoid asking the model to generate lettering. Leave optional overrides blank unless the shot needs them.
17
+
18
+ 4. **Get approval for the cost.** Run `adshot estimate`. Tell the user which shots will submit, which will resume or skip, the total new USD, and which rates are unverified. Ask them to confirm that estimate. If it exceeds the budget, revise the model, duration, resolution, or selected shots with the user and estimate again.
19
+ 5. **Render the approved selection.** Run `adshot run --yes` inside the project. For a partial approval, use the same IDs with both `adshot estimate --only S03,S04` and `adshot run --only S03,S04 --yes`. If a new submission uses an unverified rate, include `--accept-unverified-prices` once the user explicitly accepts that rate. Supply a user-approved cap with `--budget` when applicable. Read keys from the environment and keep them out of messages, files, and command arguments.
20
+ 6. **Review and revise.** Open each completed MP4. Check silhouette and label placement against the source, motion continuity across the cut, framing, and whether the intended action finishes within the allotted time. Edit only the rows with a specific defect. Run `adshot estimate` and `adshot run` again with approval for the changed spend. Prior successful takes remain in `shots/` as numbered versions.
21
+ 7. **Stitch and inspect.** Once `adshot status` shows the current rows as done, run `adshot stitch --out ad.mp4`. Play the export and check the opening, cut order, total running time, and closing hold. Return the path to the final MP4 and identify any shot still awaiting review.
22
+
23
+ ## Recovery
24
+
25
+ - **Missing key or unsupported settings.** Ask the user to set `ADSHOT_API_KEY` in the environment. For a separate chat account use `ADSHOT_PLAN_KEY`. Mini and Fast support up to 720p. Pro with a first frame needs `adaptive`. Re-estimate after a settings change.
26
+ - **Interrupted run with a task ID.** Re-run the command to poll and download the existing task. Keep the original provider selected until recovery finishes.
27
+ - **Unrecoverable task or expired download.** Check the last polling status and provider history. If the task cannot finish, or a completed shot has lost both its local video and its usable download URL, ask the user to confirm abandoning it. Run `adshot abandon S03 --confirm RETRY` with that confirmation, then quote the replacement.
28
+ - **Uncertain submission.** Show the affected shot and ask the user to check provider history. Use `adshot run --reconcile S03` with the confirmed matching ID. A fresh charge requires the user's explicit decision to type `RETRY S03`. Leave the shot on hold if the outcome is unclear.
29
+ - **Terminal provider failure.** Inspect the task in the provider dashboard, correct the row if needed, and quote a new attempt. Preserve the manifest and prior MP4s.
30
+ - **Stitch failure.** Verify that every row is done and FFmpeg is on PATH. Fix the local export problem and rerun `stitch`; it spends no video credits.
@@ -0,0 +1,5 @@
1
+ shot_id,prompt,seconds,image,model,resolution,ratio,notes
2
+ S01,"A thin shaft of morning light crosses a square amber-glass perfume bottle with a flat black cap and a small ivory label, standing on warm limestone. The light slides slowly across the glass until the right edge glows.",4,,,,,Opening silhouette
3
+ S02,"In a close overhead view a strip of bergamot peel curls beside the same square amber bottle on pale stone. A single droplet forms on the peel and falls. Keep the flat black cap and ivory label in place.",4,,,,,Scent cue
4
+ S03,"A hand lifts the flat black cap straight up from the square amber bottle and presses the black atomizer once. A fine plume hangs in the window light and drifts to the left. Frame in profile with the ivory label visible.",4,,,,,Cap and spray
5
+ S04,"Return to the square amber bottle with its flat black cap seated and ivory label facing forward. Push in slowly across pale limestone until the bottle fills the center of the frame. Hold on the last reflection.",4,,,,,Closing product hold
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "adshot"
7
+ version = "0.2.0"
8
+ description = "Storyboard, price, render, and revise product ads shot by shot."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ dependencies = ["mcp>=1.9", "tomli>=2; python_version < '3.11'"]
14
+
15
+ [project.scripts]
16
+ adshot = "adshot.cli:main"
17
+
18
+ [tool.setuptools]
19
+ package-dir = {"" = "src"}
20
+ packages = ["adshot"]
21
+ include-package-data = false
22
+
23
+ [tool.setuptools.package-data]
24
+ adshot = ["perfume.csv"]
25
+
26
+ [tool.setuptools.data-files]
27
+ "share/adshot" = ["SKILL.md"]
28
+ "share/adshot/examples/perfume" = ["examples/perfume/storyboard.csv"]
29
+
30
+ [tool.pytest.ini_options]
31
+ testpaths = ["tests"]
32
+ pythonpath = ["src"]
adshot-0.2.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Shot-by-shot video production."""
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ raise SystemExit(main())