swift-video-generator icon indicating copy to clipboard operation
swift-video-generator copied to clipboard

Crash on generating video from photos & audio.

Open naresh-kumar-ios opened this issue 4 years ago • 2 comments

I am facing one crash of array index out of range while creating the video from one audio & multiple images.

@IBAction func proccedButtonHandler(sender: UIButton) { if let audioURL4 = Bundle.main.url(forResource: "Barish2" , withExtension: "mp3") { VideoGenerator.current.generate(withImages: self.images ?? [], andAudios: [audioURL4], andType: .singleAudioMultipleImage) { (progress) in print(progress) } outcome: { (result) in switch (result) { case .success(let url): print("URL: ", url)

            case .failure(let error):
                print(error)
            }
        }

    } else {
        print("Mising audio file")
    }
}

Crash line is: Line: 178: imageForVideo = VideoGenerator.current.images[frameCount] File: VideoGenerator.swift

Screen Shot: Screenshot 2021-05-06 at 3 27 23 PM

And the Crash Logs are:

<NSProgress: 0x280a881e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0833 / Completed: 1 of 12
<NSProgress: 0x280a881e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.1667 / Completed: 2 of 12
<NSProgress: 0x280a881e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.2500 / Completed: 3 of 12
<NSProgress: 0x280a881e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.3333 / Completed: 4 of 12
Images set 0 <NSProgress: 0x280a881e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.4167 / Completed: 5 of 12
Fatal error: Index out of range: file Swift/ContiguousArrayBuffer.swift, line 444 VideoGenerator: AVAssetWriterInputPixelBufferAdapter failed to append pixel buffer Images set 0 VideoGenerator: AVAssetWriterInputPixelBufferAdapter failed to append pixel buffer 2021-05-06 15:27:12.239465+0530 VideoMaker[1852:157203] Fatal error: Index out of range: file Swift/ContiguousArrayBuffer.swift, line 444

naresh-kumar-ios avatar May 06 '21 09:05 naresh-kumar-ios

What I observed is, the VideoGenerator.current.images are setting to 0. I am not able to find why the sent images are relinquished.

naresh-kumar-ios avatar May 06 '21 10:05 naresh-kumar-ios

Hi @Naresh6885 Please check your audio file is proper or not in my case audio file was not proper so that's why I was getting this crash

Please check the size of audio file

Shahrukhpatel007 avatar Nov 02 '21 16:11 Shahrukhpatel007