使用Editly生成视频时音频缺失问题求助
Editly生成视频无音频的修复方案
你遇到的问题是因为错误地将音频作为clip的layer类型添加,Editly的音频配置不包含在layers数组中,需要单独设置。
修正方案1:为单个Clip配置音频
直接在对应clip对象中添加audio字段,指定音频文件路径:
const editlySpec = { "width": 1080, "height": 1920, "outPath": "./output-video.mp4", "clips": [ { "duration": 4, "audio": "./sample-audio-4-sec.mp3", // 在此处配置clip的音频 "layers": [ { "type": "video", "path": "./exam-preparation-video-1.mp4", }, { "type": "title", "text": "Your Text Here", "position": "center", "scale": 1.0, } ], }, ], };
修正方案2:全局音频轨道(适合多Clip共享音频)
如果需要为整个视频添加统一音频,使用根级的audioTracks数组配置:
const editlySpec = { "width": 1080, "height": 1920, "outPath": "./output-video.mp4", "audioTracks": [ { "path": "./sample-audio-4-sec.mp3", "offset": 0 // 可选:设置音频开始播放的时间偏移(单位秒) } ], "clips": [ { "duration": 4, "layers": [ { "type": "video", "path": "./exam-preparation-video-1.mp4", "mute": true // 可选:如果原视频自带音频,可添加此属性静音原视频 }, { "type": "title", "text": "Your Text Here", "position": "center", "scale": 1.0, } ], }, ], };
额外检查项
- 确认音频文件路径正确,文件未损坏且格式为Editly支持的类型(如MP3、WAV)
- 若原视频自带音频,可在video层添加
mute: true避免音频冲突
内容的提问来源于stack exchange,提问作者Shadab
相关产品推荐
相关产品推荐

