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

Black Frames in beginning of saved videos #6

Open
aferriss opened this issue Oct 14, 2017 · 6 comments
Open

Black Frames in beginning of saved videos #6

aferriss opened this issue Oct 14, 2017 · 6 comments

Comments

@aferriss
Copy link

Like the title says, I get about a second of black frames at the beginning of every video. There is some chatter about this elsewhere here, here, here

I don't remember noticing this issue until audio recording was added in. Perhaps it has something to do with the audio buffers being added before the video is ready, as one of the threads above suggests.

It may be a separate issue, but also possibly related. I've noticed that the recorded framerate is a bit variable. It usually comes out to be something like 28.2 or 28.76, but never an even 29.97 (or 30). Wonder if you've noticed this as well?

@TiborUdvari
Copy link

I only noticed a black frame on the start of the video when looping the saved video with ofxiOSVideoPlayer the recording in itself seems to be fine on my part.

@TiborUdvari
Copy link

Correction, this seems to happen as well, when I do not set the fps of the recording. Setting the FPS makes the video start as expected but does not sync up with the microphone as stated in #8

@TiborUdvari
Copy link

TiborUdvari commented Oct 28, 2017

I might understand the bug now, in VideoWriter.m, when this line is being called:

    [self.assetWriter startSessionAtSourceTime:firstAudioTimeStamp];

It starts the recording, but here the microphone input starts before the video recording, thus recording some empty frames with the audio. It might make more sense to track the first video frame for most use cases and discard the audio or have the recording start when everything is ready.

As a quick hack what I did was to just add some extra time before actually starting the recording

    CMTime wait = CMTimeMake(3, 3);
    [self.assetWriter startSessionAtSourceTime:CMTimeAdd(firstAudioTimeStamp, wait)];

@julapy
Copy link
Owner

julapy commented Nov 8, 2017

hey guys,
these issues are being caused by the addition of audio recording.

ive recently been using another iOS video recording library with unity which does the video and audio separately and then mixes them together as a final step, once recording has finished. im getting good results and thinking it would be good to update into ofxiOSVideoWriter with the same code.

as always, pretty flat out with other work so not sure when i can get this done.

alternatively, if either of you want to help, i can give you instructions on to implement.

cheers.

@TiborUdvari
Copy link

I would like to help, but timewise it is the same for me. I think it would be useful to have the info, if I have the time I can make a pull request.

@trentbrooks
Copy link
Collaborator

Thank you for the advice and links- very helpful. I've updated the writer to start after the first video frame, this seems to have fixed the issue. 9f477bc

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

No branches or pull requests

4 participants