收藏
回答

wx.saveVideoToPhotosAlbum IOS 报错fail inalid video?

this.mediaContainer.extractDataSource({
    source: url,
					success: (res) => {
						uni.showLoading({
							title: '正在下载...',
							mask: true
						})
						let mediaTrack = null;
						let audioTrack = null;
						for (let i = 0; i < res.tracks.length; i++) {
							if (res.tracks[i].kind == 'video') {
								mediaTrack = res.tracks[i];
							}
							if (res.tracks[i].kind == 'audio') {
								audioTrack = res.tracks[i];
							}
						}
						this.mediaContainer.addTrack(mediaTrack); //将视频轨道加入到待合成容器中
						this.mediaContainer.addTrack(audioTrack); // 将音频轨道加入到待合成容器中
						// 导出合成容器中的音频和视频
						this.mediaContainer.export({
							success: (data) => {
								let {
									tempFilePath
								} = data;
								this.src = tempFilePath;
								uni.hideLoading()
								this.mediaContainer.removeTrack(mediaTrack)
								this.mediaContainer.removeTrack(audioTrack)
								// 保存到本地
								wx.saveVideoToPhotosAlbum({
									filePath: tempFilePath,
									success(result) {
										console.log(result, "保存成功");
									},
									fail(err) {
										console.log(err, "保存失败");
									}
								})
							},
							fail: (err) => {
								uni.hideLoading();
								this.showtt('下载失败')
							}
						});


					},
					fail: (err) => {
						console.log(err, "视频源分离失败");
					}
				});
回答关注问题邀请回答
收藏
登录 后发表内容