Compute Speed of Spheres in 3D animation
I'd use the euclidean distance between two 3D positions. Velocity is distance over time. Time is a single frame in this case.

$$\sqrt{(x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2}$$

If you only move the camera, it is simply that frame of reference that moves, so all spheres have a relative velocity equal to the camera's velocity.