Skip to content

Is there a way to record a video without a quick flash on the screen when starting and stopping the recording? #137

Open

Description

@EriFisher

Hello,
I am making a motion detector app that records when ever motion is detected and stops when no motion is detected. It would be perfect if I didn't have this problem where when ever i record and stop recording the screen flashes, therefore making an infinite loop of recordings unfortunately. However when it is not recording it works perfectly at detecting motion and knows when to record or not. I noticed this flash happening in the video recorder example too. Would anyone know a way to prevent this minor thing from happening?

Activity

  1. changed the title [-]Is there a way to record a video without it making a quick flash on the screen when starting and stopping the recording?[/-] [+]Is there a way to record a video without a quick flash on the screen when starting and stopping the recording?[/+] on Mar 24, 2017
  2. garsdle commented on Apr 13, 2017

    @garsdle

    Are you trying to make something like this?

  3. patthehuman commented on Apr 13, 2017

    @patthehuman

    I am getting the same issue when I start recording, the screen flashes. When I stop recording, the screen flashes again.

  4. bevbomb commented on Apr 19, 2017

    @bevbomb

    I've been testing out a basic filter with recording and I'm seeing the same issue, it looks to be a focus issue because at the start of most my test videos I have a low lit dark video which fades back to the normal brightness

  5. eliot1019 commented on May 25, 2017

    @eliot1019

    Would greatly appreciate it if anyone who solved this problem could share their solution.

  6. bevbomb commented on May 25, 2017

    @bevbomb

    @eliot1019 I couldn't find a fix for this Unfortunately. I had to go back to the original GPUImage

  7. EriFisher commented on May 25, 2017

    @EriFisher
    Author

    The fix for my motion recording was to use a timer. I think in your situations that don't seem as much motion based, just the flash is on everything is to cut out the beginning of every recording, which I believe you probably can do this losslessly. Just put label on the screen like when you first start recording, "ready" then after one second change it to " Recording" on the screen. That way you let the user know what is usable. I noticed this flash on every swift based camera framework, so it might be something with swift rather than GPUimage2. I also saw the flash on apps like MSQRD.

  8. ShivaHuang commented on May 30, 2017

    @ShivaHuang
    Contributor

    Hi @SoundandStuff, what kind of flash do you mean? Some white frames at the beginning and the end? Or black frames?

    I found the similar issue which occurred on the old GPUImage, and fortunately @zmzhuai found a solution. (BradLarson/GPUImage#2410)

    I've fix the issue based on @zmzhuai's work and created a PR (#161), maybe you can give it a try?

  9. ivanvelkov commented on Aug 31, 2017

    @ivanvelkov

    We experienced the same issue when we had the camera working but not recording. Once we wanted to record we:

    • created an instance of MovieOutput
    • set camera.audioEncodingTarget = movieOutput
    • started recording via movie.start()
      However the initialization processes caused a quick flash, we believe was caused by the setter of the audioEncodingTarget and specifically
    • removeAudioInputsAndOutputs()
    • addAudioInputsAndOutputs()
      So what we ended up doing is-
      camera.delegate = self;
      where self implements AudioEncodingTarget and inside the public func processAudioBuffer(_ sampleBuffer:CMSampleBuffer) method we invoke movieOutput.processAudioBuffer(sampleBuffer)
      That way the MovieOutput always receives the audio and video buffers and when the recording is started there is no initializations needed
  10. joshbernfeld commented on Nov 21, 2017

    @joshbernfeld

    The problem here is that the audio inputs and outputs are being recreated each time you start and stop a video. Going off the SimpleVideoRecorder example, the solution I found was to expose addAudioInputsAndOutputs() on the Camera, and call that function right after you setup your Camera.

    do {
        try self.camera?.addAudioInputsAndOutputs()
    } catch {
        print("Could not initialize audio inputs and outputs: \(error)")
    }
    

    Lastly, the most important thing is to not allow your Camera's audio inputs and outputs to be destroyed when you set self.camera.audioEncodingTarget = nil after finishing recording. You can prevent this from happening by commenting out self.removeAudioInputsAndOuputs() in the setter

    public var audioEncodingTarget:AudioEncodingTarget? {
        didSet {
            guard let audioEncodingTarget = audioEncodingTarget else {
                //This line below commented out
                //self.removeAudioInputsAndOutputs()
                return
            }
            do {
                try self.addAudioInputsAndOutputs()
                audioEncodingTarget.activateAudioTrack()
            } catch {
                fatalError("ERROR: Could not connect audio target with error: \(error)")
            }
        }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions