Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error merging videos that have been generated from images with no audio #63

Open
rtvanals opened this issue Nov 22, 2019 · 4 comments
Open

Comments

@rtvanals
Copy link

rtvanals commented Nov 22, 2019

I'm generating a handful of videos from images using this:

    static func makeVideo(image: UIImage, success: ((URL) -> Void)?, failure: ((Error) -> Void)?) {
        VideoGenerator.shouldOptimiseImageForVideo = true
        VideoGenerator.fileName = UUID().uuidString
        VideoGenerator.videoDurationInSeconds = 3

        VideoGenerator.current.generate(withImages: [image], andAudios: [], andType: .single, { _ in

        }, success: { url in
            success?(url)
        }) { error in
            failure?(error)
        }
    }

Then, when I try to merge the videos with this method:

    static func mergeVideos(urls: [URL], success: @escaping ((URL) -> Void), failure: @escaping ((Error) -> Void)) {
        VideoGenerator.presetName = AVAssetExportPresetPassthrough
        VideoGenerator.fileName = UUID().uuidString
        VideoGenerator.mergeMovies(videoURLs: urls, success: success, failure: failure)
    }

where I pass the file URLs of the generated videos, I get the following error:

Error Domain=AVFoundationErrorDomain Code=-11838 "Operation Stopped" UserInfo={NSLocalizedFailureReason=The operation is not supported for this media., NSLocalizedDescription=Operation Stopped, NSUnderlyingError=0x6000010fc900 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}}

If I add an audio file to the VideoGenerator.current.generate method, I can merge them without any issue. Here is the updated makeVideo method that works:

    static func makeVideo(image: UIImage, success: ((URL) -> Void)?, failure: ((Error) -> Void)?) {
        guard let audioURL = Bundle.main.url(forResource: "audio" , withExtension: "mp3") else {
            let err = NSError(domain: "VideoGenDomain", code: 10001, userInfo: [NSLocalizedDescriptionKey : "Unable to find audio file"])
            failure?(err)
            return
        }
        
        VideoGenerator.shouldOptimiseImageForVideo = true
        VideoGenerator.fileName = UUID().uuidString
        VideoGenerator.videoDurationInSeconds = 3
        
        VideoGenerator.current.generate(withImages: [image], andAudios: [audioURL], andType: .single, { _ in

        }, success: { url in
            success?(url)
        }) { error in
            failure?(error)
        }
    }
@tgeorgieva
Copy link
Collaborator

tgeorgieva commented Nov 22, 2019

@rtvanals The merge video functionality doesn't support videos without audio.

@hezhez
Copy link

hezhez commented Feb 19, 2020

Hi @tgeorgieva, merging videos without sound is going to be possible ahead ? or is there any other option for that ? it is really necessary for my project :)

@tgeorgieva
Copy link
Collaborator

@hezhez At the moment, I don’t have any plans to implement this. But you can easily fork the project and use it as a starting point for your solution.

@hezhez
Copy link

hezhez commented Feb 19, 2020

@tgeorgieva Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants