I am not sure of my answer. The explanation at the end of it.*
Yes. The number of frames should not change. With one possible exception, I know of.
First of all, normally a compressor takes some steps.
Grab a keyframe
Compares the difference between groups of pixels and if the difference is below one defined parameter it uses the same data to render them.
And now compares the difference between adjacent frames and again, if the difference is below a threshold it uses the same data, using the keyframe as a reference to be compared with.
If the keyframe fails to load you see the glitches, where the image is smushed because you are seeing the "differences" of the frame, but with an incorrect reference image.
The exception is that some programs need to round the number of frames after a keyframe. Let us imagine you defined a keyframe every 10 frames for easy calculations.
Now your clip needs to have 105 frames. Some programs will render the exact number of frames, but some programs could try to render the full "group" of frames attached to the previous keyframe, trying to render 109 frames, or some other could try to end in a keyframe, 110 on this case.
- I am not sure about my answer because, although it as happened to me on some programs, I can not recall that it was specifically using the h264 codec.