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

Using "Vine-like" mode, each clip is missing the front ~0.25s of audio #171

Open
nickkruge opened this issue Apr 9, 2019 · 9 comments
Open
Labels

Comments

@nickkruge
Copy link

swift4.2 branch, latest
devices tried: iphone x, xs, xs+ running 12.1

When recording using the default settings two issues happen. The video starts out sharp, then turns pixelated at around 0.2s, then the audio pops in at about 0.25s. It is silent before it pops in.

I've looked inside the temp directory and the problem is happening at the individual clip level.
I've checked similar issues here on github and none seem to match exactly.

Here is a clip showing the issue: https://youtu.be/gDTwWR2Z4mU
I am making a sound the entire time, and you can hear how it cuts in and out. The pixelated problem may not come across as well since it is being re-encoded but you can clearly see that there is a snapped difference between the very start of a clip and short while later.

Initializing:

camera.videoDelegate = self
camera.videoConfiguration.maximumCaptureDuration = Helpers.cmTime(seconds: maxRecordingTime)
camera.captureMode = .video

do {
        try camera.start()
} catch {
        showPassiveError(message: "Unable to start camera \(error.localizedDescription)")
}

Starting and stopping:

camera.record()
camera.pause()

Exporting:

session.mergeClips(usingPreset: AVAssetExportPresetHighestQuality) { (url, error) in
                if let url = url {
                    // Do stuff
                } else if let error = error {
                    self.showPassiveError(message: "Error exporting \(error.localizedDescription)")
                }
            }
@piemonte piemonte added the bug label Apr 10, 2019
@pribeh
Copy link

pribeh commented Apr 18, 2019

Experiencing the audio issue as well. 0.15.2, Swift 5, on iPhone 6s running 12.2.

@UlanNurmatov
Copy link

Hi nickkruge,

Did you find any solution?

@nickkruge
Copy link
Author

nickkruge commented Jul 1, 2019 via email

@CameraPost
Copy link

@nickkruge would you be open to sharing the code for making a camera from scratch that allows for merging clips? also experiencing the pixelation and sound delay -- plus an issue maybe not directly related where some portion at the end of what is supposed to be recording is not actually recorded when pressing to stop recording. thanks!!

@piemonte
Copy link
Contributor

piemonte commented Dec 4, 2019

please verify with 0.16.1

@naturalui
Copy link

naturalui commented May 14, 2020

@piemonte I have tested this on 0.16.3 and still having issues with audio. It seems like the first part of audio is always missing. Maybe this has to do with when the audio is getting initialized when recordings start.

@tkohout Did your fix help with this? maybe good place to start looking for the bug.

Here are two sample clips (the sine tone is playing the whole time).
samples_audio_bug.zip

Ref: #216
Ref: #116

@naturalui
Copy link

naturalui commented May 14, 2020

Code: master (0.16.3)
Devices tried: iPhoneX and iPhone11ProMax

Small update that may help root cause:

I noticed when you toggle between the front and rear cameras once, the audio lag seems to get better. Not sure exactly what this means but maybe a hint towards the issue.

audio_bug_2.zip

Attached is zip with 4 samples, 0/1.mp4 are captured from fresh session start and 2/3.mp4 are captured after toggling the camera (.back to .front > .front to .back) using NextLevel.shared.flipCaptureDevicePosition()

As we can see in waveforms below it is consistently better after toggling the DevicePosition.

From Clean Session Start:

image
image

After Flipping to front camera and then back to the rear camera:

image
image

Notice the gap from the starting point to when audio comes in is much smaller.

@piemonte
Copy link
Contributor

@naturalui thanks so much 🙌

@dstuecken
Copy link

dstuecken commented Mar 17, 2021

Did you guys find any solution to this issue? I am experiencing the same issue.

Flipping the camera back and forth does not sound like an ideal solution. :)

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

No branches or pull requests

7 participants