Given a spacetime with the line element
$$ds^2 = g_{\mu\nu}(x) \, dx^\mu dx^\nu$$
How can one extract the lagrangian?
I have seen the following formula used:
$$\mathcal{L} = \frac{1}{2} g_{\mu\nu}(x) \, \dot{x}^\mu \dot{x}^\nu$$
But I would like to know where this formula comes from?