node.js - Concat 视频使用 cloudinary 和 firestore
问题描述
我正在将短视频上传到 Cloudinary 并将数据存储在 Firestore 中。当它们上传时,我想显示它们全部连接在一起的预览视频。
我尝试使用 *ngFor 循环和追加数组并没有成功。我是新手,需要帮助。如何在 Firestore 中使用云变换叠加连接视频?
component.ts
name = 'Angular 6';
data: any[] = [];
cloudName = '...........';
Video_id;
res;
private videosCollection: AngularFirestoreCollection<Video>;
videos: Observable<Video[]>;
loading: any;
constructor(private af: AngularFirestore) {
this.getvideos();
}
ngOnInit() {
//this.getvideos();
}
` uploader: CloudinaryUploader = new CloudinaryUploader(
new CloudinaryOptions({
cloudName: this.cloudName,
uploadPreset: 'xz78fi2p'
})
);
upload() {
this.loading = true;
this.uploader.uploadAll();
this.uploader.onSuccessItem = (item: any, response: string, status:
number, headers: any): any => {
this.res = JSON.parse(response);
this.loading = false;
this.Video_id = this.res.public_id;
console.log(this.res);
this.videosCollection.add(this.res)
}
this.uploader.onErrorItem = function (fileItem, response, status,
headers) {
console.info('onErrorItem', fileItem, response, status, headers)
};
}
getvideos() {
this.videosCollection = this.af.collection<Video>('cloudinaryupload');
this.videos = this.videosCollection.valueChanges();
}
snapshotToArray(snapshot) {
var returnArr = [];
snapshot.forEach(function (childSnapshot) {
var item = childSnapshot.val();
item.key = childSnapshot.key;
returnArr.push(item);
});
return returnArr;
};
}
component.html
<cl-video public-id="efmiqwpebinzc400ay7i" controls>
<cl-transformation width="300" height="200" crop="fill">
</cl-transformation>
<cl-transformation *ngFor="let Videos of videos | async"
attr.overlay="video:{{Videos.public_id}}" flags="splice" width="300"
height="200">
</cl-transformation>
</cl-video> `
解决方案
Cloudinary 支持使用overlay video 参数(l_video: in URLs)拼接视频 例如:https ://res.cloudinary.com/demo/video/upload/w_300,h_200,c_fill/l_video:dog,fl_splice,w_300 ,h_200,c_fill/kitten_fighting.mp4
您可以在上传视频后操作 URL 并稍后添加叠加层,也可以在上传时直接执行此操作。
推荐阅读
- tensorflow - 如何在 tf-keras 中定义具有多输出的自定义损失函数?
- excel - 用 vba 重写了一个文本文件
- reactjs - 将默认域添加到正在注册的电子邮件
- cqrs - 您如何确保应用事件以读取模型?
- ios - 在 Xcode 中录制 UI 测试,但录制按钮不执行任何操作
- c#-4.0 - 在 c# 中调用 noteStore.findNotesMetadata() 时 filter.Words 不起作用
- python - 有没有一种快速的方法可以将 4D 数组的一个轴乘以与该轴相同长度的向量中的元素?
- c# - 使用投影在 Automapper 配置文件中进行本地化
- python - 将 json 文件从文件夹转换为 csv 格式
- python - 如何在 AWS Lambda 中读取上传的 excel 文件?