Your frog is shedding... it is perfectly normal. They move their bodies in uncomfortable looking positions to stretch and remove the skin. He was opening his mouth to eat the shed skin. My frogs do this everyday.
I agree with Julia, it looks horrible but it is fine.