284 questions
2
votes
1
answer
87
views
Properly merge mp4 segments from AVAssetWritter using AVMutableComposition
I have trouble with merging segments that comes from live recording via AVCaptureSession. During capturing AVAssetWritter is using its delegate to dump segments to disk. I'm using this delegate ...
2
votes
2
answers
282
views
How to make custom video track for the AVComposition
I am trying to achieve an animated gradient effect that changes values over time based on the current seconds. I am also using AVPlayer and AVMutableVideoComposition along with custom instruction and ...
0
votes
1
answer
122
views
Using Custom Video Compositor Class rotates the video
I'm building a subtitle generator. I have a subtitle layer which has all the implementations for the subtitles such as animations, styling, etc.
When I'm exporting the video, the video is rotated to ...
1
vote
1
answer
103
views
Transform Issue Merging Videos with AVMutableComposition
I have an AVURLAsset array. It contains videos that have been taken with the back camera, front camera (not mirrored), images turned into a video. All in portrait orientation.
I created a function to ...
2
votes
1
answer
208
views
Merging Videos with Overlayed Text
In Swift for iOS, I have an array of AVURLAsset. I pass it through a function to stitch/merge the video assets together into one final video. For each sub-video, my goal is to overlay text centered in ...
0
votes
0
answers
50
views
Text overlays of composed video doesn’t match UI
I have a SwiftUI view on top of a video view, which has a standard size, full width, and almost full height (always portrait). The video's ratio varies. The SwiftUI view has a Text that the user can ...
0
votes
1
answer
567
views
In Swift, how do you remove background from a video?
I'm playing with SwiftUI and have an intro video playing, but wondering how I can remove the background of a video so it will appear transparent
If I replace the AVPlayerItem it does display and plays ...
0
votes
0
answers
80
views
Cropping Video from scrollview swift
I would like to implement functionality like below. i have used scrollView and based on zoom scale I tried to crop video but didn’t able to get same result. Can any one help me with this?
Link for ...
0
votes
1
answer
545
views
Merging video with original orientation
I have a link I can DM for a minimum working example!
Recording Videos
For recording, the AVCaptureConnection for an AVCaptureSession, I set isVideoMirrored to true when using the front camera and ...
0
votes
1
answer
116
views
AVMutableComposition goes silent every once in a while
I'm trying to create a an audio loop in Swift and it works very well 9/10 times. But then suddenly, the 10th time (or so) the insertTimeRange function seems to fail in some way.
I can see that the ...
0
votes
0
answers
671
views
AVFoundationErrorDomain Code=-11829 "Cannot Open" | NSOSStatusErrorDomain Code=-12848 | NSLocalizedDescription=Cannot Open, NSError=0x60000121cdb0
I get this error when I record a video on my iPhone and then try to upload the file to my application and create an AVMutableComposition. It does not work both on my iPhone and the simulator.
private ...
2
votes
0
answers
438
views
loadInPlaceFileRepresentation vs loadFileRepresentation
I have an app where users upload videos and then I create clips from the video using AVMutableComposition. I don't fully understand the difference between loadInPlaceFileRepresentation and ...
1
vote
0
answers
444
views
Play video synthesized by AVMutableComposition in AVPlayer with error
I am creating an IOS video editing tool by AVMutableComposition.
If I combine multiple videos in a single video mutabletrack, it works fine. However, when I create mutabletrack per video and ...
1
vote
1
answer
979
views
AVMutableComposition -How to Merge Multiple Audio Recordings with 1 Video Recording
I have several audio clips that I recorded with an AVAudioRecorder over a video. Using a AVMutableComposition I want to merge the audio assets with the video at the times the audio was recorded. For ...
0
votes
0
answers
775
views
how to get video and audio from MKV? (swift)
i want to convert MKV (Matroska) to MP4 in swift
when i add a file with MKV format my code break in line 8 , what should i do to fix that?
this is my code:
let composition = AVMutableComposition() ...
1
vote
1
answer
836
views
Swift -AVMutableVideoCompositionLayerInstruction Misalignment when Merging Videos
I followed the Ray Wenderlich to merge videos. The finished result is 1 merged video where portrait videos are at the top of the screen and landscape videos are at the bottom of the screen. In the ...
1
vote
1
answer
222
views
Swift AVAssetTrack not merging properly
Attempting to merge multiple videos with AVMutableComposition, the tracks are gathering correctly in the avassettrack. However, they simply overlap and only the second video is displayed. Also the ...
0
votes
1
answer
304
views
audio file plays fine but can't add in AVMutableVideoComposition
i'm trying to add audio file selected with MPMediaPickerController to video with AVMutableVideoComposition, but it gives error and doesn't work.
picking audio like this :
func mediaPicker(_ ...
1
vote
1
answer
1k
views
Portrait video rendered as landscape after exporting with AVMutableVideoComposition
hello i'm combining two videos with AVMutableVideoComposition() and it works good with landscape videos and portrait videos downloaded from youtube but when try portrait video recorded in iPhone or ...
0
votes
0
answers
280
views
AVMutableComposition has slightly different duration than saved m4a file when using AVAssetExportSession
I'm adding an an m4a audio file from the file system, loaded via an AVURLAsset, into an AVMutableComposition. If the loaded asset has a duration of 1s, adding it to the AVMutableComposition results in ...
3
votes
1
answer
224
views
AVMutableComposition output freezes at the last frame of the first video
I am trying to merge multiple clips(videos) into one using AVMutableCompositions, I have successfully done this as well as rotating and translating each instruction, however, there is still one issue ...
1
vote
1
answer
624
views
How to combine (hstack) multiple videos side by side with AVMutableVideoComposition?
I'm trying to combine 3 videos into single video where videos are cropped and put side by side in hstack.
Here is my current solution which puts only the first video 3 times (repeating) side by side. ...
1
vote
0
answers
430
views
How to combine multiple videos with AVMutableComposition without loosing audio sync?
I'm trying to write video exporter which can combine N videos and place them side by side. Below example is with 3 videos.
Videos are recorded WebRTC streams of speakers, and each has a bit different ...
0
votes
0
answers
116
views
How to trim out multiple time-points in an AVAsset (Swift)?
I am working on a video editor app, where based on some processing, I have an array of samples/time-points to remove from the video clip. For example,
timePoints = [0 8.2 15.5 20.6...]. //seconds
I ...
1
vote
1
answer
1k
views
Change volume of audio track within AVMutableComposition
I'm trying to merge a pre-existing video with a newly recorded audio voiceover track. User can set the relative sound volume for the two audio tracks (audio belonging to video, and new audio).
This ...
1
vote
1
answer
372
views
AVMutableVideoCompositionLayerInstruction setCropRectangle with ROTATED rectangle not working as expected
I have a video that is placed at the origin of the screen, no rotation, as seen in this picture
(ignore the background):
No crop rectangle
I apply a basic rectangle (no rotation for now) crop with ...
0
votes
1
answer
185
views
How to play a 60fps video at half speed with Swift & AVMutableComposition and AVPlayer on MacOS
I am adding 60fps video files to an AVMutableComposition and I am wondering if its possible to play that composition back at half speed.
This is where its adding to the video track
do {
try ...
4
votes
1
answer
704
views
Trouble applying scaleTimeRange on multiple videos in a AVMutableComposition video
I am attempting to merge videos with scaleTimeRanges (to make them slo-mo or speed-up); however, it is not working as desired. Only the first video has the timerange effect... not all of them.
The ...
1
vote
0
answers
957
views
Adding image on video with AVMutableComposition - Swift - Programmatically
I want to add a Image over a video and in order to do so I follow this tutorial:
The code I implemented is this:
func addViewToVideo(fromVideoAt videoURL: URL, withView: UIView, completion: @escaping (...
0
votes
2
answers
1k
views
AVAssetExportSession.exportAsynchronously does not make progress
Extended AVMutableComposition so that it can be exported.
However, even a 1-second video does not progress at all when export is performed.
I tried to print out the progress, and found that it didn't ...
3
votes
1
answer
991
views
AVExportSession exporting video super slow
I am trying to simply increase the speed of my exporting of my merged video.
Here is the code: //from my extensive research online and on SO, I have pretty much come down to the preset PassThrough ...
2
votes
1
answer
1k
views
Make AVMutableComposition with image (aspect fill) and video in aspect fit
I am attempting to make a new video using an image that will always be size: CGSize(375, 667), but with a video that will be different sizes, and with the contentMode of .`aspectFit'. The problem is ...
0
votes
0
answers
176
views
AVMutableComposition not showing frames on simulator but works fine on device
Following is a simple two video merging code using AVFoundation's AVMutableComposition. I use two different mutable tracks for two videos and manage their layer opacity according to time:
import UIKit
...
0
votes
1
answer
678
views
Merge multiple video assets with correct orientation swift
I am simply trying to stitch together (merge) an array of videos (with correct original orientations), and it works HOWEVER with incorrect orientation of some videos. For example with the current ...
1
vote
0
answers
453
views
How to save AVMutableComposition (directly) without AVMutableVideoComposition to camera roll/gallery/photos - Swift 5
I am one step away from finishing my first original app so I'm quite desperate for an answer.
I have created an AVMutableComposition (not AVMutableVideoComposition) that combines multiple clips. All ...
2
votes
1
answer
1k
views
How do I export a video with a transparent background (alpha channel)
I have a video I'm overlaying on top of another video, where the overlay video has a transparent background. I'm doing this with AVMutableComposition where I just add the tracks and it works great; ...
0
votes
1
answer
728
views
How to pass AVMutableComposition to AVAssetWriter
Right now I get a url from a AVMixComposition using AVExportSession. HighestQuality looks great but the file size is too big, a 15 sec video is 27 mb. MediumQuality looks horrible but the file size is ...
0
votes
0
answers
426
views
Clips in AVMutableComposition have gap between them
I'm adding three clips to an AVMutableComposition like this...
let asset = AVURLAsset(url: url, options: [ AVURLAssetPreferPreciseDurationAndTimingKey : true ])
let track = composition....
0
votes
1
answer
128
views
Do all following tracks need to be updated in a mutable composition if a track is removed?
To add a time range to an AVMutableCompositionTrack you have to specify the start time in the track (at:)...
try track?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero,
...
0
votes
2
answers
215
views
AVURLAsset returning empty array-Trying to Concatenate two files
I'm trying to concatenate two (multiple) audio files. I found a relevant post and solution at Concatenate Two Audio Files Swift
Here's the solution:
func mergeAudioFiles(audioFileUrls: NSArray) {
...
2
votes
0
answers
625
views
Merge two videos on top of each other
I am trying to merge two videos so that second video is on top of other video. My second video has transparent background so my desired outcome looks like this :
However i cannot see second video in ...
0
votes
1
answer
442
views
Merging videos with AVMutableComposition
I am trying to merge two videos together using AVMutableComposition
After scaling the video's i am not finding a way to crop the video or get rid of the part of the video that is marked red.
I tried ...
3
votes
1
answer
323
views
What is the best way to draw custom timestamp text over a video with AVFoundation?
I've got an AVMutableVideoComposition that I'm exporting with AVAssetExportSession and I'm trying to overlay a custom timestamp that updates every second on top of it. Should I be using AVAssetWriter, ...
1
vote
0
answers
229
views
iOS - AVAsynchronousCIImageFilteringRequest source image is empty
I use AVMutableVideoComposition(asset:applyingCIFiltersWithHandler:) to apply CIFilter for each frame. Here is my code:
let mainTrackAsset = AVAsset(url: url)
let mainCompositionWithFilter = ...
2
votes
1
answer
450
views
Silence is not adding on end of an audio file
I'm working on a demo of how to add extra silence audio at the end of a given audio file.
here my audio file length is 29 sec. & I'm adding 11-sec silence.
so, final output audio length will be ...
1
vote
1
answer
612
views
Merging audio tracks in a single track using AVMutableComposition
I'm dealing with an app that should be able to mix multiple video and audio clips in a single movie file (.mp4).
At the momento the resulting movie has one video track, that is the concatenation of ...
1
vote
0
answers
563
views
Add watermark image to video via AVMutableComposition, exported video size much larger than original
I have a 30 seconds video clip (1280*720, size around 3MB, *.MP4) and a logo image(4KB, JPG). I've managed to add the watermark and exported video using the following code, but the problem is:
The ...
2
votes
0
answers
119
views
Swift 4 AVMutableComposition animations
I am trying to display an image over top of a video for the first few seconds only. I am adding an image to a CALayer and then attempting to hide it using CABasicAnimation. I have tried a few ...
4
votes
1
answer
1k
views
How do I merge 2 videos with a fade transition?
I'm trying two merge 2 videos with a 2 second overlap. In this overlap I'd like to fade the second video in (or fade the first one out to reveal the second, either one would be great).
The first ...
4
votes
1
answer
287
views
AVFoundation -Videos merge but only last video plays
I have an array of [AVAsset](). Whenever I record different videos at different durations the below code merges all the durations into 1 video but it will only play the last video in a loop.
For eg. ...