Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Swift中使用GPUImage将图像添加到视频_Ios_Swift_Swift2_Gpuimage - Fatal编程技术网

Ios 如何在Swift中使用GPUImage将图像添加到视频

Ios 如何在Swift中使用GPUImage将图像添加到视频,ios,swift,swift2,gpuimage,Ios,Swift,Swift2,Gpuimage,我有一些代码可以使用GPUImage将图像添加到视频中,但不知怎么的,它并不像我想的那样工作。我已经找到了一些解决方案,但仍然存在这个问题。 我试图在重新编码完成后合并图像。现在输出的只是一个视频,没有图像。 这是我的密码 override func viewDidLoad(){ super.viewDidLoad setupCamera() } func setupCamera(){ let myBoundSize: CGSize = UIScreen.mainScre

我有一些代码可以使用GPUImage将图像添加到视频中,但不知怎么的,它并不像我想的那样工作。我已经找到了一些解决方案,但仍然存在这个问题。
我试图在重新编码完成后合并图像。现在输出的只是一个视频,没有图像。
这是我的密码

override func viewDidLoad(){
   super.viewDidLoad

   setupCamera()
}

func setupCamera(){
    let myBoundSize: CGSize = UIScreen.mainScreen().bounds.size

    cameraSubPreview = GPUImageView(frame: CGRectMake(0, 0, myBoundSize.width, myBoundSize.height))
    cameraInput = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPreset1280x720, cameraPosition: .Front)
    cameraInput.horizontallyMirrorFrontFacingCamera = true
    cameraInput.outputImageOrientation = .Portrait

    cameraInput.addTarget(mainVideoFilter)

    mainVideoFilter.addTarget(cameraSubPreview)
    cameraPreview.addSubview(cameraSubPreview)
    cameraInput.startCameraCapture()
}

func setupFilter(){
     let logoImageForGPU = GPUImagePicture(image: logoImageView.image)

     logoImageForGPU.addTarget(transformFilter)
     logoImageForGPU.processImage()

     // apply transform to filter
     let tx: CGFloat = logoImageView.frame.size.width
     let ty: CGFloat = logoImageView.frame.size.height
     print("tx and ty: \(tx), \(ty)")
     let t: CGAffineTransform = CGAffineTransformMakeScale(tx, ty);
     transformFilter.affineTransform = t

    transformFilter.addTarget(mainVideoFilter, atTextureLocation: 1)
}

func startRecordingVideo(sender: AnyObject) {
        if(sender.state == UIGestureRecognizerState.Began) {
            if !self.isRecording {

            setupFilter()

            let ud = NSUserDefaults.standardUserDefaults()
            var IntForFilePath : Int? = ud.objectForKey("IntForFilePath") as? Int
            if IntForFilePath == nil{
                IntForFilePath = 10000
            }

            let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
            let documentsDirectory = paths[0]
            IntForFilePath = IntForFilePath! + 1
            let filePath : String? = "\(documentsDirectory)/temp\(IntForFilePath!).mp4"
            ud.setObject(IntForFilePath, forKey: "IntForFilePath")
            // URL.
            let fileURL : NSURL = NSURL(fileURLWithPath: filePath!)

            //print(filePath)
            self.delegate.filePathForVideo = filePath!

            movieWriter = GPUImageMovieWriter(movieURL: fileURL, size: CGSize(width: 480, height: 800))
            movieWriter.shouldPassthroughAudio = true
            //cameraInput.addTarget(stillImageFilter)
            //print("sif: \()")
            stillImageFilter.addTarget(movieWriter)
            cameraInput.audioEncodingTarget = movieWriter

            // start recording
            movieWriter.startRecording()

            circle.hidden = false
            drawCircleAnimation("strokeEnd", animeName: "updateGageAnimation", fromValue: 0.0, toValue: 1.0, duration: 10.0, repeat: 1, flag: false)

            self.isRecording = true
        }
    } else if (sender.state == UIGestureRecognizerState.Ended) {
        if self.isRecording {
            //stop recording
            movieWriter.finishRecording()

            stopCircleAnimation()
            self.isRecording = false

            self.moveToVideoSaveView()
        }
    }
}
如果你有什么办法可以解决这个问题,请告诉我
提前谢谢