mp4box v2.2.1
```
mp4box -add video.h264 -new video.mp4
```
if the video stream video.h264 contains additional PPS in the middle of the file, mp4box adds a new `avc1` and `avcC` atom with the updated list of PPS. Here is the dump of video.mp4
```
'ftyp' 0x0 [0x1C] Major Brand: 'isom', Minor Version: 0x1
  Compatible brands: 'isom', 'avc1', 'iso6'
'moov' 0x1C [0xBD527] 
  'mvhd' 0x24 [0x6C] Movie Header: Time scale 600, Duration 1462100 (2436.83 sec)
    Rate 1, Volume 1
    Creating time: 2023/05/19 10:25:20
    Modification time: 2023/05/19 10:25:20
    Next Track ID: 2
  'iods' 0x90 [0x15] 
    Unprocessed 0xD bytes 00 00 00 00 10 07 00 4F FF FF FF 7F FF
  'trak' 0xA5 [0xBD424] 
    'tkhd' 0xAD [0x5C] Track #1, Duration 1462100
      Resolution: 3840x2160
      Creating time: 2023/05/19 10:25:20
      Modification time: 2023/05/19 10:25:38
    'edts' 0x109 [0x24] 
      Unprocessed 0x1C bytes
    'mdia' 0x12D [0xBD39C] 
      'mdhd' 0x135 [0x20] Media Header: Time scale 30000, Duration 73106033 (2436.87 sec)
        Creating time: 2023/05/19 10:25:20
        Modification time: 2023/05/19 10:25:38
      'hdlr' 0x155 [0x47] Component Type: {0000}, Subtype: 'vide', "?@GPAC2.2.1-rev0-gb34e3851-relea"
      'minf' 0x19C [0xBD32D] 
        'vmhd' 0x1A4 [0x14] 
        'dinf' 0x1B8 [0x24] 
          'dref' 0x1C0 [0x1C] 
            'url ' 0x1D0 [0xC] 
              Unprocessed 0x4 bytes 00 00 00 01
        'stbl' 0x1DC [0xBD2ED] 
          'stsd' 0x1E4 [0x9D0] 
            'avc1' 0x1F4 [0x13D] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x24A [0xB0] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}
              'pasp' 0x2FA [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x30A [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
              'btrt' 0x31D [0x14] 
                Unprocessed 0xC bytes 00 16 80 82 05 66 1B 68 03 48 1D 08
            'avc1' 0x331 [0x193] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x387 [0x11A] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}
              'pasp' 0x4A1 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x4B1 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x4C4 [0x1FB] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x51A [0x182] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}
              'pasp' 0x69C [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x6AC [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x6BF [0x269] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x715 [0x1F0] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}, PPS4{sps=0}
              'pasp' 0x905 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x915 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x928 [0x28C] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x97E [0x213] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}, PPS4{sps=0}, PPS0{sps=0}
              'pasp' 0xB91 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0xBA1 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
          'stts' 0xBB4 [0x18] Time-to-Sample[1] (#: Count * Duration):
            ...
```
Some demuxers read only the first `avcC`, so the part of the video stream is unplayable because references to a missing PPS.
Note 1: Only first `avc1` contains `btrt`.
Note 2: I also see the following warning in the output `[AVC|H264] xPS changed but could not flush frames before signaling state change !`.
The same behavior for HEVC and `hvc1`/`hvcC`.
Multiple avc1/avcC and hvc1/hvcC atoms inside a single track
This is a GitHub Issue
repo:gpac
owner:gpac
Title : Multiple avc1/avcC and hvc1/hvcC atoms inside a single track
Issue date:

--- start body ---
mp4box v2.2.1
```
mp4box -add video.h264 -new video.mp4
```
if the video stream video.h264 contains additional PPS in the middle of the file, mp4box adds a new `avc1` and `avcC` atom with the updated list of PPS. Here is the dump of video.mp4
```
'ftyp' 0x0 [0x1C] Major Brand: 'isom', Minor Version: 0x1
  Compatible brands: 'isom', 'avc1', 'iso6'
'moov' 0x1C [0xBD527] 
  'mvhd' 0x24 [0x6C] Movie Header: Time scale 600, Duration 1462100 (2436.83 sec)
    Rate 1, Volume 1
    Creating time: 2023/05/19 10:25:20
    Modification time: 2023/05/19 10:25:20
    Next Track ID: 2
  'iods' 0x90 [0x15] 
    Unprocessed 0xD bytes 00 00 00 00 10 07 00 4F FF FF FF 7F FF
  'trak' 0xA5 [0xBD424] 
    'tkhd' 0xAD [0x5C] Track #1, Duration 1462100
      Resolution: 3840x2160
      Creating time: 2023/05/19 10:25:20
      Modification time: 2023/05/19 10:25:38
    'edts' 0x109 [0x24] 
      Unprocessed 0x1C bytes
    'mdia' 0x12D [0xBD39C] 
      'mdhd' 0x135 [0x20] Media Header: Time scale 30000, Duration 73106033 (2436.87 sec)
        Creating time: 2023/05/19 10:25:20
        Modification time: 2023/05/19 10:25:38
      'hdlr' 0x155 [0x47] Component Type: {0000}, Subtype: 'vide', "?@GPAC2.2.1-rev0-gb34e3851-relea"
      'minf' 0x19C [0xBD32D] 
        'vmhd' 0x1A4 [0x14] 
        'dinf' 0x1B8 [0x24] 
          'dref' 0x1C0 [0x1C] 
            'url ' 0x1D0 [0xC] 
              Unprocessed 0x4 bytes 00 00 00 01
        'stbl' 0x1DC [0xBD2ED] 
          'stsd' 0x1E4 [0x9D0] 
            'avc1' 0x1F4 [0x13D] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x24A [0xB0] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}
              'pasp' 0x2FA [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x30A [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
              'btrt' 0x31D [0x14] 
                Unprocessed 0xC bytes 00 16 80 82 05 66 1B 68 03 48 1D 08
            'avc1' 0x331 [0x193] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x387 [0x11A] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}
              'pasp' 0x4A1 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x4B1 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x4C4 [0x1FB] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x51A [0x182] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}
              'pasp' 0x69C [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x6AC [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x6BF [0x269] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x715 [0x1F0] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}, PPS4{sps=0}
              'pasp' 0x905 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0x915 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
            'avc1' 0x928 [0x28C] Video Sample 3840x2160, 24 bits, 
              'avcC' 0x97E [0x213] SPS0{AVC video 3840x2160, High Profile, Level 5.1}, PPS3{sps=0}, PPS2{sps=0}, PPS1{sps=0}, PPS4{sps=0}, PPS0{sps=0}
              'pasp' 0xB91 [0x10] 
                Unprocessed 0x8 bytes 00 00 00 01 00 00 00 01
              'colr' 0xBA1 [0x13] 
                Unprocessed 0xB bytes 6E 63 6C 78 00 01 00 0B 00 01 00
          'stts' 0xBB4 [0x18] Time-to-Sample[1] (#: Count * Duration):
            ...
```
Some demuxers read only the first `avcC`, so the part of the video stream is unplayable because references to a missing PPS.
Note 1: Only first `avc1` contains `btrt`.
Note 2: I also see the following warning in the output `[AVC|H264] xPS changed but could not flush frames before signaling state change !`.
The same behavior for HEVC and `hvc1`/`hvcC`.
--- end body ---

The issue describes a potential problem with the handling of multiple `avc1`/`avcC` and `hvc1`/`hvcC` atoms within a single track in MP4 files processed by MP4Box v2.2.1. This can lead to playback issues where some demuxers only read the first `avcC`, causing parts of the video stream to be unplayable due to missing Picture Parameter Sets (PPS). While this may affect functionality and user experience, it does not indicate a direct security vulnerability.