ofxiOSVideoWriter
ofxiOSVideoWriter copied to clipboard
Black Frames in beginning of saved videos
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?
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.
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
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)];
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.
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.
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. https://github.com/julapy/ofxiOSVideoWriter/commit/9f477bc1c56a477c13630530870d2bd9b8fae710