My guess its the gas valve failing. The thermostat that senses the heat of the water is telling the valve to turn off as soon as it beings to see the hot water being developed. When this happens the gas valve (part with red knob on front) turns off and the remaining gas in the valve and pipe leading to where the flame is located burns off. This explains the reason why it begins to get smaller.
To remove this you need to drain the entire heater and unscrew the valve from the tank. This oftentimes leads to failure. The cost can be as much as new heater. If its under warranty, contact the manufacture of the unit to see if its covered. Most likely not. Normal warranties on hot water heaters only cover the valves and parts for the first year, After that they prorate the tank from leaks.
if this is a newer unit (you light pilot w/ button), it could be something as simple as the intake screen being clogged. The newer units have sealed combustion chambers and the only way for flame to breathe is a screen below the combustion chamber. If it is an older unit, (you light the pilot manually with match), it will likely be the gas valve as Woodbridge said.
Thank you Plumber26 it is a newer heater and the blocked intake.