@deepfish-ai/ffmpeg7-media-tools 1.0.0

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,679 @@
1
+ /**
2
+ * FFmpeg 媒体工具描述文件
3
+ * 包含所有功能的AI智能体描述信息
4
+ * @version 1.0.0
5
+ */
6
+
7
+ // 描述数组初始化
8
+ const descriptions = [];
9
+
10
+ // ============ AI 智能体描述部分 ============
11
+ // 以下描述供 AI 智能体读取,用于理解函数功能和参数结构
12
+
13
+ descriptions.push({
14
+ name: 'ffmpeg_checkFfmpegInstallation',
15
+ description: 'FFmpeg工具:检测ffmpeg是否安装和版本检测',
16
+ parameters: {
17
+ type: 'object',
18
+ properties: {
19
+ minVersion: {
20
+ type: 'string',
21
+ description: '最低要求的ffmpeg版本号(可选),例如"7.0"',
22
+ },
23
+ },
24
+ },
25
+ });
26
+
27
+ descriptions.push({
28
+ name: 'ffmpeg_convertVideoFormat',
29
+ description: 'FFmpeg工具:转换视频格式',
30
+ parameters: {
31
+ type: 'object',
32
+ properties: {
33
+ inputPath: {
34
+ type: 'string',
35
+ description: '输入视频文件路径',
36
+ },
37
+ outputPath: {
38
+ type: 'string',
39
+ description: '输出视频文件路径',
40
+ },
41
+ format: {
42
+ type: 'string',
43
+ description: '目标格式,如mp4、avi、mov、mkv等(可选)',
44
+ },
45
+ quality: {
46
+ type: 'string',
47
+ description: '视频质量参数(可选,默认为-crf 23)',
48
+ },
49
+ },
50
+ required: ['inputPath', 'outputPath'],
51
+ },
52
+ });
53
+
54
+ descriptions.push({
55
+ name: 'ffmpeg_extractAudioFromVideo',
56
+ description: 'FFmpeg工具:从视频中提取音频',
57
+ parameters: {
58
+ type: 'object',
59
+ properties: {
60
+ videoPath: {
61
+ type: 'string',
62
+ description: '输入视频文件路径',
63
+ },
64
+ audioPath: {
65
+ type: 'string',
66
+ description: '输出音频文件路径',
67
+ },
68
+ audioFormat: {
69
+ type: 'string',
70
+ description: '音频格式,如mp3、wav、aac等(可选,默认为mp3)',
71
+ },
72
+ },
73
+ required: ['videoPath', 'audioPath'],
74
+ },
75
+ });
76
+
77
+ descriptions.push({
78
+ name: 'ffmpeg_resizeVideo',
79
+ description: 'FFmpeg工具:调整视频尺寸',
80
+ parameters: {
81
+ type: 'object',
82
+ properties: {
83
+ inputPath: {
84
+ type: 'string',
85
+ description: '输入视频文件路径',
86
+ },
87
+ outputPath: {
88
+ type: 'string',
89
+ description: '输出视频文件路径',
90
+ },
91
+ width: {
92
+ type: 'number',
93
+ description: '目标宽度(像素)',
94
+ },
95
+ height: {
96
+ type: 'number',
97
+ description: '目标高度(像素)',
98
+ },
99
+ keepAspectRatio: {
100
+ type: 'boolean',
101
+ description: '是否保持宽高比(可选,默认为true)',
102
+ },
103
+ },
104
+ required: ['inputPath', 'outputPath', 'width', 'height'],
105
+ },
106
+ });
107
+
108
+ descriptions.push({
109
+ name: 'ffmpeg_trimVideo',
110
+ description: 'FFmpeg工具:剪切视频片段',
111
+ parameters: {
112
+ type: 'object',
113
+ properties: {
114
+ inputPath: {
115
+ type: 'string',
116
+ description: '输入视频文件路径',
117
+ },
118
+ outputPath: {
119
+ type: 'string',
120
+ description: '输出视频文件路径',
121
+ },
122
+ startTime: {
123
+ type: 'string',
124
+ description: '开始时间(格式:HH:MM:SS 或 秒数)',
125
+ },
126
+ duration: {
127
+ type: 'string',
128
+ description: '持续时间(格式:HH:MM:SS 或 秒数)',
129
+ },
130
+ },
131
+ required: ['inputPath', 'outputPath', 'startTime', 'duration'],
132
+ },
133
+ });
134
+
135
+ descriptions.push({
136
+ name: 'ffmpeg_mergeVideos',
137
+ description: 'FFmpeg工具:合并多个视频文件',
138
+ parameters: {
139
+ type: 'object',
140
+ properties: {
141
+ videoPaths: {
142
+ type: 'array',
143
+ description: '视频文件路径数组',
144
+ items: {
145
+ type: 'string',
146
+ },
147
+ },
148
+ outputPath: {
149
+ type: 'string',
150
+ description: '输出视频文件路径',
151
+ },
152
+ method: {
153
+ type: 'string',
154
+ description: '合并方法:concat(串联)或 overlay(叠加,可选,默认为concat)',
155
+ },
156
+ },
157
+ required: ['videoPaths', 'outputPath'],
158
+ },
159
+ });
160
+
161
+ descriptions.push({
162
+ name: 'ffmpeg_convertAudioFormat',
163
+ description: 'FFmpeg工具:转换音频格式',
164
+ parameters: {
165
+ type: 'object',
166
+ properties: {
167
+ inputPath: {
168
+ type: 'string',
169
+ description: '输入音频文件路径',
170
+ },
171
+ outputPath: {
172
+ type: 'string',
173
+ description: '输出音频文件路径',
174
+ },
175
+ format: {
176
+ type: 'string',
177
+ description: '目标格式,如mp3、wav、aac、flac等',
178
+ },
179
+ bitrate: {
180
+ type: 'string',
181
+ description: '比特率(可选,如128k、192k、256k等)',
182
+ },
183
+ },
184
+ required: ['inputPath', 'outputPath', 'format'],
185
+ },
186
+ });
187
+
188
+ descriptions.push({
189
+ name: 'ffmpeg_adjustAudioVolume',
190
+ description: 'FFmpeg工具:调整音频音量',
191
+ parameters: {
192
+ type: 'object',
193
+ properties: {
194
+ inputPath: {
195
+ type: 'string',
196
+ description: '输入音频文件路径',
197
+ },
198
+ outputPath: {
199
+ type: 'string',
200
+ description: '输出音频文件路径',
201
+ },
202
+ volume: {
203
+ type: 'number',
204
+ description: '音量倍数(如0.5为一半音量,2.0为两倍音量)',
205
+ },
206
+ },
207
+ required: ['inputPath', 'outputPath', 'volume'],
208
+ },
209
+ });
210
+
211
+ descriptions.push({
212
+ name: 'ffmpeg_addWatermark',
213
+ description: 'FFmpeg工具:添加水印',
214
+ parameters: {
215
+ type: 'object',
216
+ properties: {
217
+ inputPath: {
218
+ type: 'string',
219
+ description: '输入视频文件路径',
220
+ },
221
+ outputPath: {
222
+ type: 'string',
223
+ description: '输出视频文件路径',
224
+ },
225
+ watermarkPath: {
226
+ type: 'string',
227
+ description: '水印图片路径',
228
+ },
229
+ position: {
230
+ type: 'string',
231
+ description: '水印位置,如top-left、top-right、bottom-left、bottom-right、center(可选,默认为bottom-right)',
232
+ },
233
+ opacity: {
234
+ type: 'number',
235
+ description: '水印透明度,0-1之间(可选,默认为1)',
236
+ },
237
+ },
238
+ required: ['inputPath', 'outputPath', 'watermarkPath'],
239
+ },
240
+ });
241
+
242
+ descriptions.push({
243
+ name: 'ffmpeg_adjustBitrate',
244
+ description: 'FFmpeg工具:调整视频比特率',
245
+ parameters: {
246
+ type: 'object',
247
+ properties: {
248
+ inputPath: {
249
+ type: 'string',
250
+ description: '输入视频文件路径',
251
+ },
252
+ outputPath: {
253
+ type: 'string',
254
+ description: '输出视频文件路径',
255
+ },
256
+ bitrate: {
257
+ type: 'string',
258
+ description: '目标比特率,如1M、500k、2M等',
259
+ },
260
+ audioBitrate: {
261
+ type: 'string',
262
+ description: '音频比特率(可选)',
263
+ },
264
+ },
265
+ required: ['inputPath', 'outputPath', 'bitrate'],
266
+ },
267
+ });
268
+
269
+ descriptions.push({
270
+ name: 'ffmpeg_mergeVideoAudio',
271
+ description: 'FFmpeg工具:合并视频和音频',
272
+ parameters: {
273
+ type: 'object',
274
+ properties: {
275
+ videoPath: {
276
+ type: 'string',
277
+ description: '视频文件路径',
278
+ },
279
+ audioPath: {
280
+ type: 'string',
281
+ description: '音频文件路径',
282
+ },
283
+ outputPath: {
284
+ type: 'string',
285
+ description: '输出文件路径',
286
+ },
287
+ sync: {
288
+ type: 'boolean',
289
+ description: '是否同步音视频(可选,默认为true)',
290
+ },
291
+ },
292
+ required: ['videoPath', 'audioPath', 'outputPath'],
293
+ },
294
+ });
295
+
296
+ descriptions.push({
297
+ name: 'ffmpeg_extractVideoThumbnail',
298
+ description: 'FFmpeg工具:提取视频缩略图',
299
+ parameters: {
300
+ type: 'object',
301
+ properties: {
302
+ videoPath: {
303
+ type: 'string',
304
+ description: '输入视频文件路径',
305
+ },
306
+ outputPath: {
307
+ type: 'string',
308
+ description: '输出图片文件路径',
309
+ },
310
+ time: {
311
+ type: 'string',
312
+ description: '提取时间点(格式:HH:MM:SS 或 秒数,默认为00:00:01)',
313
+ },
314
+ size: {
315
+ type: 'string',
316
+ description: '缩略图尺寸(格式:宽x高,如320x240)',
317
+ },
318
+ },
319
+ required: ['videoPath', 'outputPath'],
320
+ },
321
+ });
322
+
323
+ descriptions.push({
324
+ name: 'ffmpeg_getMediaInfo',
325
+ description: 'FFmpeg工具:获取媒体文件信息',
326
+ parameters: {
327
+ type: 'object',
328
+ properties: {
329
+ mediaPath: {
330
+ type: 'string',
331
+ description: '媒体文件路径',
332
+ },
333
+ },
334
+ required: ['mediaPath'],
335
+ },
336
+ });
337
+
338
+ // ============ 新增函数描述 ============
339
+
340
+ descriptions.push({
341
+ "name": "ffmpeg_videoToGif",
342
+ "description": "FFmpeg工具:将视频转换为GIF动图",
343
+ "parameters": {
344
+ "type": "object",
345
+ "properties": {
346
+ "videoPath": {
347
+ "type": "string",
348
+ "description": "输入视频文件路径"
349
+ },
350
+ "outputPath": {
351
+ "type": "string",
352
+ "description": "输出GIF文件路径"
353
+ },
354
+ "startTime": {
355
+ "type": "string",
356
+ "description": "开始时间(格式:HH:MM:SS 或 秒数,默认为00:00:00)"
357
+ },
358
+ "duration": {
359
+ "type": "string",
360
+ "description": "持续时间(格式:HH:MM:SS 或 秒数,默认为全部)"
361
+ },
362
+ "fps": {
363
+ "type": "number",
364
+ "description": "帧率(默认为10)"
365
+ },
366
+ "width": {
367
+ "type": "number",
368
+ "description": "输出宽度(保持宽高比,高度自动计算)"
369
+ }
370
+ },
371
+ "required": [
372
+ "videoPath",
373
+ "outputPath"
374
+ ]
375
+ }
376
+ });
377
+
378
+ descriptions.push({
379
+ "name": "ffmpeg_cropVideo",
380
+ "description": "FFmpeg工具:裁剪视频区域",
381
+ "parameters": {
382
+ "type": "object",
383
+ "properties": {
384
+ "videoPath": {
385
+ "type": "string",
386
+ "description": "输入视频文件路径"
387
+ },
388
+ "outputPath": {
389
+ "type": "string",
390
+ "description": "输出视频文件路径"
391
+ },
392
+ "x": {
393
+ "type": "number",
394
+ "description": "起始X坐标(像素)"
395
+ },
396
+ "y": {
397
+ "type": "number",
398
+ "description": "起始Y坐标(像素)"
399
+ },
400
+ "width": {
401
+ "type": "number",
402
+ "description": "裁剪宽度(像素)"
403
+ },
404
+ "height": {
405
+ "type": "number",
406
+ "description": "裁剪高度(像素)"
407
+ }
408
+ },
409
+ "required": [
410
+ "videoPath",
411
+ "outputPath",
412
+ "x",
413
+ "y",
414
+ "width",
415
+ "height"
416
+ ]
417
+ }
418
+ });
419
+
420
+ descriptions.push({
421
+ "name": "ffmpeg_rotateVideo",
422
+ "description": "FFmpeg工具:旋转视频",
423
+ "parameters": {
424
+ "type": "object",
425
+ "properties": {
426
+ "videoPath": {
427
+ "type": "string",
428
+ "description": "输入视频文件路径"
429
+ },
430
+ "outputPath": {
431
+ "type": "string",
432
+ "description": "输出视频文件路径"
433
+ },
434
+ "angle": {
435
+ "type": "string",
436
+ "description": "旋转角度(90, 180, 270, 或 transpose参数)"
437
+ }
438
+ },
439
+ "required": [
440
+ "videoPath",
441
+ "outputPath",
442
+ "angle"
443
+ ]
444
+ }
445
+ });
446
+
447
+ descriptions.push({
448
+ "name": "ffmpeg_changeVideoSpeed",
449
+ "description": "FFmpeg工具:改变视频播放速度",
450
+ "parameters": {
451
+ "type": "object",
452
+ "properties": {
453
+ "videoPath": {
454
+ "type": "string",
455
+ "description": "输入视频文件路径"
456
+ },
457
+ "outputPath": {
458
+ "type": "string",
459
+ "description": "输出视频文件路径"
460
+ },
461
+ "speed": {
462
+ "type": "number",
463
+ "description": "速度倍数(0.5表示慢放一半,2.0表示快放一倍)"
464
+ }
465
+ },
466
+ "required": [
467
+ "videoPath",
468
+ "outputPath",
469
+ "speed"
470
+ ]
471
+ }
472
+ });
473
+
474
+ descriptions.push({
475
+ "name": "ffmpeg_addSubtitles",
476
+ "description": "FFmpeg工具:添加字幕到视频",
477
+ "parameters": {
478
+ "type": "object",
479
+ "properties": {
480
+ "videoPath": {
481
+ "type": "string",
482
+ "description": "输入视频文件路径"
483
+ },
484
+ "subtitlePath": {
485
+ "type": "string",
486
+ "description": "字幕文件路径(支持srt, ass等格式)"
487
+ },
488
+ "outputPath": {
489
+ "type": "string",
490
+ "description": "输出视频文件路径"
491
+ },
492
+ "encoding": {
493
+ "type": "string",
494
+ "description": "字幕编码(默认为UTF-8)"
495
+ }
496
+ },
497
+ "required": [
498
+ "videoPath",
499
+ "subtitlePath",
500
+ "outputPath"
501
+ ]
502
+ }
503
+ });
504
+
505
+ descriptions.push({
506
+ "name": "ffmpeg_extractVideoFrames",
507
+ "description": "FFmpeg工具:提取视频帧为图片序列",
508
+ "parameters": {
509
+ "type": "object",
510
+ "properties": {
511
+ "videoPath": {
512
+ "type": "string",
513
+ "description": "输入视频文件路径"
514
+ },
515
+ "outputDir": {
516
+ "type": "string",
517
+ "description": "输出目录路径"
518
+ },
519
+ "fps": {
520
+ "type": "number",
521
+ "description": "每秒提取帧数(默认为1)"
522
+ },
523
+ "format": {
524
+ "type": "string",
525
+ "description": "输出图片格式(jpg, png等,默认为jpg)"
526
+ },
527
+ "startTime": {
528
+ "type": "string",
529
+ "description": "开始时间(格式:HH:MM:SS)"
530
+ },
531
+ "duration": {
532
+ "type": "string",
533
+ "description": "持续时间(格式:HH:MM:SS)"
534
+ }
535
+ },
536
+ "required": [
537
+ "videoPath",
538
+ "outputDir"
539
+ ]
540
+ }
541
+ });
542
+
543
+ descriptions.push({
544
+ "name": "ffmpeg_concatVideos",
545
+ "description": "FFmpeg工具:拼接多个视频文件(使用concat demuxer)",
546
+ "parameters": {
547
+ "type": "object",
548
+ "properties": {
549
+ "videoPaths": {
550
+ "type": "array",
551
+ "description": "视频文件路径数组"
552
+ },
553
+ "outputPath": {
554
+ "type": "string",
555
+ "description": "输出视频文件路径"
556
+ },
557
+ "transition": {
558
+ "type": "string",
559
+ "description": "转场效果(none, fade等,可选)"
560
+ }
561
+ },
562
+ "required": [
563
+ "videoPaths",
564
+ "outputPath"
565
+ ]
566
+ }
567
+ });
568
+
569
+ descriptions.push({
570
+ "name": "ffmpeg_mixAudios",
571
+ "description": "FFmpeg工具:混合多个音频文件",
572
+ "parameters": {
573
+ "type": "object",
574
+ "properties": {
575
+ "audioPaths": {
576
+ "type": "array",
577
+ "description": "音频文件路径数组"
578
+ },
579
+ "outputPath": {
580
+ "type": "string",
581
+ "description": "输出音频文件路径"
582
+ },
583
+ "volumes": {
584
+ "type": "array",
585
+ "description": "各音频音量数组(如[1.0, 0.5])"
586
+ }
587
+ },
588
+ "required": [
589
+ "audioPaths",
590
+ "outputPath"
591
+ ]
592
+ }
593
+ });
594
+
595
+ descriptions.push({
596
+ "name": "ffmpeg_compressVideo",
597
+ "description": "FFmpeg工具:压缩视频(调整CRF)",
598
+ "parameters": {
599
+ "type": "object",
600
+ "properties": {
601
+ "videoPath": {
602
+ "type": "string",
603
+ "description": "输入视频文件路径"
604
+ },
605
+ "outputPath": {
606
+ "type": "string",
607
+ "description": "输出视频文件路径"
608
+ },
609
+ "crf": {
610
+ "type": "number",
611
+ "description": "CRF值(0-51,越小质量越高,默认为23)"
612
+ },
613
+ "preset": {
614
+ "type": "string",
615
+ "description": "编码预设(ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow,默认为medium)"
616
+ }
617
+ },
618
+ "required": [
619
+ "videoPath",
620
+ "outputPath"
621
+ ]
622
+ }
623
+ });
624
+
625
+ descriptions.push({
626
+ "name": "ffmpeg_addTextOverlay",
627
+ "description": "FFmpeg工具:添加文本叠加到视频",
628
+ "parameters": {
629
+ "type": "object",
630
+ "properties": {
631
+ "videoPath": {
632
+ "type": "string",
633
+ "description": "输入视频文件路径"
634
+ },
635
+ "outputPath": {
636
+ "type": "string",
637
+ "description": "输出视频文件路径"
638
+ },
639
+ "text": {
640
+ "type": "string",
641
+ "description": "要叠加的文本"
642
+ },
643
+ "x": {
644
+ "type": "number",
645
+ "description": "文本X坐标(像素)"
646
+ },
647
+ "y": {
648
+ "type": "number",
649
+ "description": "文本Y坐标(像素)"
650
+ },
651
+ "fontSize": {
652
+ "type": "number",
653
+ "description": "字体大小(默认为24)"
654
+ },
655
+ "fontColor": {
656
+ "type": "string",
657
+ "description": "字体颜色(默认为white)"
658
+ },
659
+ "startTime": {
660
+ "type": "string",
661
+ "description": "开始显示时间(格式:HH:MM:SS)"
662
+ },
663
+ "duration": {
664
+ "type": "string",
665
+ "description": "显示持续时间(格式:HH:MM:SS)"
666
+ }
667
+ },
668
+ "required": [
669
+ "videoPath",
670
+ "outputPath",
671
+ "text"
672
+ ]
673
+ }
674
+ });
675
+
676
+
677
+
678
+ // ============ 模块导出 ============
679
+ module.exports = descriptions;