Don't export from AE as H.264. The Adobe Media Encoder (and probably Handbrake) will get you better results. Does Handbrake do multipass encoding?
Your composition should already be matching the settings of your footage (in most cases).
The animation codec is mathematically lossless. This means that every single pixel is the exact same once rendered as it was in the AE composition. If you took that file and rendered it again as the animation codec, it would still be the same. No matter how many generations you go through, there will never be quality loss because it is lossless. This is why lossless codecs are ideal for intermediate files.
Another good intermediate codec is Quicktime with the PNG codec. At high quality settings, it is also mathematically lossless, but in many cases the file size is smaller than the Animation codec.
If you are using GPU enhances ray-traced rendering it is always best to go to a good digital intermediate and then compress for delivery in the Adobe Media Encoder using one of the presets. If you have specific data rates you are trying to hit you can modify the data rate in AME.
If you do not have any ray-traced comps in your project then you can render an AE comp directly in the Adobe Media Encoder. This is the way I work most of the time. If I need several different delivery formats the I'll render a DI and export the variants in AME.
Cheers guys My video does contain ray traced comps, so i'll be going down the route of rendering to the Animation codec as an intermediate, then setting compression parameters in Adobe Media encoder.