H.264 comes in a variety of stream formats. One variation is called "Annex B".
(AUD)(SPS)(PPS)(I-Slice)(PPS)(P-Slice)(PPS)(P-Slice) ... (AUD)(SPS)(PPS)(I-Slice).
Typically you see SPS/PPS before each I frame and PPS before other slices.
Most decoders/muxers are happy with "Annex B" and the repetition of SPS/PPS.
Most decoders/muxers won't do anything meaningful if you change the format and SPS/PPS midstream.
Most decoders/muxers parse the first SPS/PPS as part of a setup process and ignore subsequent SPSs.
Some decoders/muxers prefer H.264 without the (AUD), start codes and SPS/PPS.
Then you have to feed SPS/PPS out of band as part of setting up the decoders/muxers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…