I don't understand these four lines.  I can't see why you'd combine withe width and height like this.  top and left will only both be 0 if the aspect ratio is square.  So one of the two is going to be positive.  But width and height are both >= the screen dimensions, so it seems to me that the viewfinder must not be centered on the screen.

Maybe the CSS rotation changes this somehow...

I'd elther like this math to be changed, commented, or make more explicit by breaking it down into steps, please.