Try a low-pass RC filter, which is a series resistor followed by a capacitor to ground. You will probably want to put a unity-gain opamp buffer amplifier before the filter, and maybe after the filter, depending on the rest of the circuit. You might find that you need more filtering, either with additional stages or by using a higher-order active filter. You could download TI.com's Filterpro software for that. I suggest simulating your circuit in LTspice. The filter components' values will depend on how fast you want the output to be able to track changes in the average's value and how smooth you want the output to be, as well as the range of input properties that the circuit needs to handle, such as repetition rate, pulse width, and amplitude.