avasset

Loop AVMutableCompositionTrack

六眼飞鱼酱① 提交于 2021-02-17 17:27:29
问题 I have got two audio tracks on me that I combine with one another like this: AVMutableComposition *composition = [[AVMutableComposition alloc] init]; AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; [compositionAudioTrack setPreferredVolume:1.0]; AVAsset *avAsset = [AVURLAsset URLAssetWithURL:originalContentURL options:nil]; AVAssetTrack *clipAudioTrack = [[avAsset tracksWithMediaType

Loop AVMutableCompositionTrack

跟風遠走 提交于 2021-02-17 17:23:44
问题 I have got two audio tracks on me that I combine with one another like this: AVMutableComposition *composition = [[AVMutableComposition alloc] init]; AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; [compositionAudioTrack setPreferredVolume:1.0]; AVAsset *avAsset = [AVURLAsset URLAssetWithURL:originalContentURL options:nil]; AVAssetTrack *clipAudioTrack = [[avAsset tracksWithMediaType

Loop AVMutableCompositionTrack

南笙酒味 提交于 2021-02-17 17:22:07
问题 I have got two audio tracks on me that I combine with one another like this: AVMutableComposition *composition = [[AVMutableComposition alloc] init]; AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; [compositionAudioTrack setPreferredVolume:1.0]; AVAsset *avAsset = [AVURLAsset URLAssetWithURL:originalContentURL options:nil]; AVAssetTrack *clipAudioTrack = [[avAsset tracksWithMediaType

Get the accurate duration of a video

爷,独闯天下 提交于 2021-01-18 05:01:37
问题 I'm making a player and I want to list all files and in front of all files I want to present the duration of the video. The only problem is that I'm not getting the right video duration, sometimes it return a duration completely wrong. I've tried the below solution: let asset = AVAsset(url: "video.mp4") let duration = asset.duration.seconds So that it, the time sometimes give a value sometimes another. if someone know a possible solution I'm glad to heard. I have update the code using one

Swift -check if url asset has sound

我与影子孤独终老i 提交于 2020-12-15 07:17:10
问题 My screen cracked and my phone has no sound capabilities. I recorded a video using the camera. When I select the video url from didFinishPickingMediaWithInfo I tried to check if the video has sound or not but player.currentItem?.asset.tracks says the video does have sound (the device and recorded video definitely has no sound). func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { // ... guard let url =

Video with no audio crashes app on AVMutableComposition()

六月ゝ 毕业季﹏ 提交于 2020-12-12 06:07:16
问题 My app takes a video from a URL and allows you to add text to it, etc. It seems to crash when the video doesn't have any audio to begin with, can't seem to figure this out. This is what I have when the video is being composed: let asset = AVAsset(url: URL(string: self.videoURL)!) let mixComposition = AVMutableComposition() let videoTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid) try! videoTrack?.insertTimeRange(CMTimeRangeMake

Swift Merge AVasset-Videos array

狂风中的少年 提交于 2020-01-22 12:57:10
问题 I want to merge the AVAsset- arrayVideos into one single video and save it on camera roll. Raywenderlich.com has a great tutorial where two videos are merged into one. I've created the following code, however the video that I get after exporting to camera roll includes only the first and the last video from the array (excluding the rest of the videos in the middle of arrayVideos ). Am I missing something here? var arrayVideos = [AVAsset]() //Videos Array var atTimeM: CMTime = CMTimeMake(0, 0)

Swift Merge AVasset-Videos array

▼魔方 西西 提交于 2020-01-22 12:57:09
问题 I want to merge the AVAsset- arrayVideos into one single video and save it on camera roll. Raywenderlich.com has a great tutorial where two videos are merged into one. I've created the following code, however the video that I get after exporting to camera roll includes only the first and the last video from the array (excluding the rest of the videos in the middle of arrayVideos ). Am I missing something here? var arrayVideos = [AVAsset]() //Videos Array var atTimeM: CMTime = CMTimeMake(0, 0)