1

I need to make a video file from thousands of images generated by code. I cannot put those images into an array because they are too many--a 30second-long video would consist of 1800 imgae frames. And I don't get all images at once.

To get each image, it first triggers Javascript fucntion in WebView asking if a video frame,which is UIImage, should be generated. if Yes, my code makes UIImage for a video frame one at a time. and the app does other things and at some point it asks webview again for a permission to generate another image. it does this for a thousand times and more.

If Delegate gets a message that says No, the last image was a final video frame so a complete video file should be made at this point and saved to Document directory.

How should I do this? Objective C solutions would be acceptable too. thank you in advance

//ask webview if another video frame should be made
func askWebView() {
webView?.evaluateJavaScript("Ask JS function",completionHandler:nil)
}

Delegate

//Delegate method
func userContentController(userContentController:WKUserContentController,didReceiveScriptMessage message:WKScriptMessage){
    let body:String = message.body as! String
    if body == "makeAFrame" {
       let videoFrame = self.makeImage()
       //should asseble video frames
    } else {
    //No,nomore video frame. write a complete video file to Document directory
}

Generating an UIImage for a video frame

func makeImage() -> UIImage {
 //make an image and return it
}
Kyle KIM
  • 1,384
  • 2
  • 15
  • 31
  • 1
    this may help you: http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie – maddy Oct 21 '15 at 05:34

0 Answers0