10sec video is saved as 1sec video

Im not sure if we understand each other. Here we see a peace of code, which checks, if frmae buffer is not false - put data into a file. Otherwise if something went wrong - break the loop.

I did what you said and got some exceptions (panic)