-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinput-info.ts
More file actions
75 lines (66 loc) · 2.43 KB
/
input-info.ts
File metadata and controls
75 lines (66 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Command } from '@cliffy/command';
import { handleCommandError } from '@/lib/errors.ts';
import { createAuthenticatedMuxClient } from '@/lib/mux.ts';
interface InputInfoOptions {
json?: boolean;
}
export const inputInfoCommand = new Command()
.description('Get input track and file details for a Mux video asset')
.arguments('<asset-id:string>')
.option('--json', 'Output JSON instead of pretty format')
.action(async (options: InputInfoOptions, assetId: string) => {
try {
const mux = await createAuthenticatedMuxClient();
const inputInfo = await mux.video.assets.retrieveInputInfo(assetId);
if (options.json) {
console.log(JSON.stringify(inputInfo, null, 2));
} else {
if (inputInfo.length === 0) {
console.log('No input info available for this asset.');
return;
}
for (let i = 0; i < inputInfo.length; i++) {
const info = inputInfo[i];
console.log(`Input ${i + 1}:`);
if (info.file) {
if (info.file.container_format) {
console.log(` Container: ${info.file.container_format}`);
}
if (info.file.tracks && info.file.tracks.length > 0) {
console.log(' Tracks:');
for (const track of info.file.tracks) {
const parts = [` - ${track.type}`];
if (track.encoding) {
parts.push(`(${track.encoding})`);
}
if (track.width && track.height) {
parts.push(`${track.width}x${track.height}`);
}
if (track.frame_rate) {
parts.push(`${track.frame_rate}fps`);
}
if (track.duration) {
parts.push(`${track.duration.toFixed(2)}s`);
}
if (track.channels) {
parts.push(`${track.channels}ch`);
}
if (track.sample_rate) {
parts.push(`${track.sample_rate}Hz`);
}
console.log(parts.join(' '));
}
}
}
if (info.settings) {
console.log(` Settings: ${JSON.stringify(info.settings)}`);
}
if (i < inputInfo.length - 1) {
console.log('');
}
}
}
} catch (error) {
await handleCommandError(error, 'assets', 'input-info', options);
}
});