@hadialmarzooq/agent-media-ffmpeg 0.1.0 → 0.1.1
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.
- package/README.md +92 -0
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @hadialmarzooq/agent-media-ffmpeg
|
|
2
|
+
|
|
3
|
+
Safe FFmpeg execution, progress reporting, and verified media workflows for software agents.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
The FFmpeg backend for [Agent Media](https://github.com/HadiAlMarzooq/agent-media). Compiles semantic Media IR plans into deterministic FFmpeg invocations, executes them with progress reporting, and inspects outputs for verification.
|
|
8
|
+
|
|
9
|
+
### Five high-level workflows
|
|
10
|
+
|
|
11
|
+
All workflows share the same contract: **inspect → plan → serialize → execute → verify**. Each returns `{ source, plan, serializedPlan, output, verification }`.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
makeVertical,
|
|
16
|
+
optimizeForWeb,
|
|
17
|
+
normalize,
|
|
18
|
+
extractAudio,
|
|
19
|
+
extractFrame,
|
|
20
|
+
} from '@hadialmarzooq/agent-media-ffmpeg';
|
|
21
|
+
|
|
22
|
+
// 9:16 vertical, H.264/yuv420p, faststart, size-constrained
|
|
23
|
+
const vertical = await makeVertical({
|
|
24
|
+
input: 'demo.mp4',
|
|
25
|
+
output: 'vertical.mp4',
|
|
26
|
+
maxSizeMB: 25,
|
|
27
|
+
onProgress: ({ phase, percent }) => console.error(`${phase}: ${percent}%`),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Web-optimized: balanced quality, H.264, faststart
|
|
31
|
+
const web = await optimizeForWeb({
|
|
32
|
+
input: 'demo.mp4',
|
|
33
|
+
output: 'web.mp4',
|
|
34
|
+
maxSizeMB: 10,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Normalized high-compatibility copy
|
|
38
|
+
const norm = await normalize({ input: 'demo.mp4', output: 'normalized.mp4' });
|
|
39
|
+
|
|
40
|
+
// Extract audio
|
|
41
|
+
const audio = await extractAudio({ input: 'demo.mp4', output: 'audio.m4a' });
|
|
42
|
+
|
|
43
|
+
// Extract a still frame
|
|
44
|
+
const frame = await extractFrame({ input: 'demo.mp4', output: 'frame.jpg', atSeconds: 2 });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Explicit plan and replay
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { inspectMedia, executePlan, getCapabilities } from '@hadialmarzooq/agent-media-ffmpeg';
|
|
51
|
+
import { planMedia, serializePlan, parsePlan, verifyMedia } from '@hadialmarzooq/agent-media-core';
|
|
52
|
+
|
|
53
|
+
const source = await inspectMedia('demo.mp4');
|
|
54
|
+
const plan = planMedia({
|
|
55
|
+
source,
|
|
56
|
+
capabilities: await getCapabilities(),
|
|
57
|
+
goals: { aspectRatio: '9:16', compatibility: 'high', maxSizeMB: 25 },
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Save and replay
|
|
61
|
+
const json = serializePlan(plan);
|
|
62
|
+
const replayed = parsePlan(json);
|
|
63
|
+
const result = await executePlan(replayed, { output: 'vertical.mp4' });
|
|
64
|
+
const output = await inspectMedia(result.output);
|
|
65
|
+
const report = verifyMedia(output, replayed.expectations);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install @hadialmarzooq/agent-media-core @hadialmarzooq/agent-media-ffmpeg
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Prerequisites: Node.js 22+, `ffmpeg` and `ffprobe` on `PATH`.
|
|
75
|
+
|
|
76
|
+
## Safety
|
|
77
|
+
|
|
78
|
+
- Rejects source overwrite, output collisions, and directory escape
|
|
79
|
+
- Cancellation and timeout controls with partial cleanup
|
|
80
|
+
- Concatenation preflight rejects incompatible streams before execution
|
|
81
|
+
- Progress is monotonic and isolated — UI callbacks can't change execution semantics
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
- [Full docs](https://github.com/HadiAlMarzooq/agent-media/tree/main/docs)
|
|
86
|
+
- [Workflows](https://github.com/HadiAlMarzooq/agent-media/blob/main/docs/workflows.md)
|
|
87
|
+
- [API reference](https://github.com/HadiAlMarzooq/agent-media/blob/main/docs/api.md)
|
|
88
|
+
- [Reliability](https://github.com/HadiAlMarzooq/agent-media/blob/main/docs/reliability.md)
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadialmarzooq/agent-media-ffmpeg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Safe FFmpeg execution, progress, and verified media workflows for software agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"media",
|
|
@@ -32,13 +32,15 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
36
38
|
],
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@hadialmarzooq/agent-media-core": "0.1.
|
|
43
|
+
"@hadialmarzooq/agent-media-core": "0.1.1"
|
|
42
44
|
},
|
|
43
45
|
"scripts": {
|
|
44
46
|
"build": "tsup src/index.ts --format esm --dts",
|