W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
剪輯精彩的視頻片段。
屬性 | 類型 | 默認值 | 是否必填 | 說明 | 支持版本 |
---|---|---|---|---|---|
path | string | 是 | path 的值為停止錄屏拿到的視頻地址 | ||
timeRange | Array | 否 | 裁剪的范圍,用法含義與recordClip 中的timeRange ,完全相同,只是記錄時相對的當(dāng)前時刻規(guī)定為錄屏結(jié)束時刻 | 1.13.9 | |
clipRange | Array | 否 | 指定要裁剪的范圍,數(shù)組中每一項為調(diào)用 recordClip 得到返回值 | 1.20.0 | |
success | function | 否 | 剪輯成功的回調(diào)函數(shù) | ||
fail | function | 否 | 剪輯失敗的回調(diào)函數(shù) |
clipRange 詳細說明
success返回對象參數(shù)的擴展屬性:
名稱 | 數(shù)據(jù)類型 | 描述 |
---|---|---|
videoPath | string | 剪輯的視頻地址 |
簡單裁剪,生成最后 10 秒的視頻
const recorder = tt.getGameRecorderManager();
recorder.start({ duration: 60 });
recorder.clipVideo({
path: res.videoPath,
timeRange: [10, 0]
success(res){
console.log(res.videoPath); // 生成最后10秒的視頻
},
fail(e) {
console.error(e)
}
})
結(jié)合 recordClip,順序拼接剪輯
const recorder = tt.getGameRecorderManager();
recorder.start({ duration: 60 });
// start 之后 5 秒調(diào)用
recorder.recordClip({
timeRange: [5, 0]
});
recorder.onStop(res => {
recorder.clipVideo({
path: res.videoPath,
timeRange: [10, 0],
success(res) {
// 由開始5秒 +最后10秒 拼接合成的視頻
console.log(res.videoPath);
},
fail(e) {
console.error(e);
}
});
});
自定義拼接順序
const recorder = tt.getGameRecorderManager();
const clipIndexList = []; // 剪輯索引列表
// 監(jiān)聽錄屏結(jié)束事件
recorder.onStop(res => {
// 對錄制完成的視頻進行剪輯
recorder.clipVideo({
path: res.videoPath,
clipRange: clipIndexList.reverse(), // 倒序拼接
success(res) {
console.log(res.videoPath); // 生成 最后10秒 + 開始5秒 的視頻
},
fail(e) {
console.error(e);
}
});
});
recorder.start({
duration: 30
});
// 錄屏開始 5秒后執(zhí)行,記錄 5s 之前到當(dāng)前時刻的剪輯時間
recorder.recordClip({
timeRange: [5, 0],
success(res) {
clipIndexList.push(res.index);
}
});
// stop 之前調(diào)用表示裁剪錄屏中的最后10s
recorder.recordClip({
timeRange: [10, 0],
success(res) {
clipIndexList.push(res.index);
recorder.stop();
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: