rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

Auto video stabilization introduces latency and chopped video frames when ending segment writing. #217

Open xezero opened 8 years ago

xezero commented 8 years ago

Took me a few days to hunt this one down but with the preferred stabilization video mode defaulted to auto, I was noticing chopped video frames when ending a segment, which seems to make sense according to Apple's documentation for the stabilization modes. We're essentially hard stopping the AVAssetWriter from writing additional samples without accounting for the latency of the stabilization for more incoming samples. After turning it off, I no longer get chopped video frames.

videoConnection.preferredVideoStabilizationMode = AVCaptureVideoStabilizationModeOff; videoConnection.enablesVideoStabilizationWhenAvailable = NO;

I haven't figured out a way to figure out the latency of the stabilization yet to account for more sample buffers...

xezero commented 8 years ago

In the meantime, would you be able to expose the device/video connection properties like preferredVideoStabilizationMode, enablesVideoStabilizationWhenAvailable, smoothAutoFocusEnabled, etc? Doesn't look like there's an easy way to set/persist them without iterating through the video output's connections and even then SCRecorder calls reconfigureDevice depending on the application state and resets the values.