(latest mp4box from git)
Dash segments don't have an equal duration in `SIDX.duration` and `mdat.duration(samples*dur)` fields. **Should SIDX and mdat fragment chunk durations match?**

Things go even more wrong after encryption, **first** `cenc/v1/1.m4s ` file is  `SIDX.dur=3.76s, mdat=3.84s !!!` values.

Encoding target is 3,84s segments (input aac 48Khz/h264 25fps, gop 96 frames), this should give 100% align video+audio segment durations.

**4x fragments, no drm and drm**
```
https://refapp.hbbtv.org/videos/dashtest/test1/manifest.mpd
v1/1.m4s, SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)

v1/2.m4s SIDX.earliestPresTime=49152(3,84s), timescale=12800
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)

https://refapp.hbbtv.org/videos/dashtest/test1/cenc/manifest.mpd
https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:header,sl:2000,persist:false,contentkey:EjQSNBI0EjQSNBI0EjQSNw==)
cenc/v1/1.m4s SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       11776,        12288,        12288,        11776, total=48128 (3,76s) !!!
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s) !!!

cenc/v1/2.m4s SIDX.earliestPresTime=48128(3,76s)
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)
```

**1x fragment, no drm, drm**
```
https://refapp.hbbtv.org/videos/dashtest/test3/manifest.mpd
v1/1.m4s, SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)
v1/2.m4s, SIDX.earliestPresTime=49152
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)

** 1x fragment, drm, test3/cenc/manifest.mpd **
https://refapp.hbbtv.org/videos/dashtest/test3/cenc/manifest.mpd
https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:header,sl:2000,persist:false,contentkey:EjQSNBI0EjQSNBI0EjQSNw==)
cenc/v1/1.m4s, SIDX.earliestPresTime=0, , timescale=12800
SIDX.dur=       48128 (3,76s)  !!!
mdat.dur=96*512=49152 (3,84s) !!!
cenc/v1/2.m4s, SIDX.earliestPresTime=48128(3,76s)
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)
```

**intermediary temp-xx.mp4 input files**
https://refapp.hbbtv.org/videos/dashtest/test1/temp/temp-v1.mp4
https://refapp.hbbtv.org/videos/dashtest/test1/temp/temp-a1.mp4
https://refapp.hbbtv.org/videos/dashtest/test3/temp/temp-v1.mp4
https://refapp.hbbtv.org/videos/dashtest/test3/temp/temp-a1.mp4

**Dash command lines**
```
4x fragments
MP4Box -dash 184320 -frag  46080 -dash-scale 48000 -mem-frags -rap -profile dashavc264:live \
  -profile-ext urn:hbbtv:dash:profile:isoff-live:2012 -min-buffer 2000 \
  -bs-switching no -sample-groups-traf -single-traf --tfdt64 --tfdt_traf --noroll=yes --btrt=no \
  --truns_first=yes --cmaf=cmf2 -subsegs-per-sidx 0 \
  -segment-name "$RepresentationID$/$Number$$Init=i$" \
  -out manifest.mpd:dual \
  "temp/temp-v1.mp4#trackID=1:id=v1:period=p0:asID=1:role=main:dur=24:#HLSPL=manifest_v1.m3u8" \
  "temp/temp-a1.mp4#trackID=1:id=a1:period=p0:asID=21:role=main:dur=24:#HLSPL=manifest_a1.m3u8:#HLSGroup=audio"

1x fragment
MP4Box -dash 184320 -frag 184320 -dash-scale 48000 -mem-frags -rap -profile dashavc264:live \
  -profile-ext urn:hbbtv:dash:profile:isoff-live:2012 -min-buffer 2000 \
  -bs-switching no -sample-groups-traf -single-traf --tfdt64 --tfdt_traf --noroll=yes --btrt=no \
  --truns_first=yes --cmaf=cmf2 -subsegs-per-sidx 0 \
  -segment-name "$RepresentationID$/$Number$$Init=i$" \
  -out manifest.mpd:dual \
  "temp/temp-v1.mp4#trackID=1:id=v1:period=p0:asID=1:role=main:dur=24:#HLSPL=manifest_v1.m3u8" \
  "temp/temp-a1.mp4#trackID=1:id=a1:period=p0:asID=21:role=main:dur=24:#HLSPL=manifest_a1.m3u8:#HLSGroup=audio"

Encryption
MP4Box -crypt drm-cenc.xml temp/temp-v1.mp4 -out temp/temp-v1-cenc.mp4
MP4Box -crypt drm-cenc.xml temp/temp-a1.mp4 -out temp/temp-a1-cenc.mp4
- run 4x and 1x fragment mp4box with temp-XX-cenc.mp4 input files
```

**drm-cenc.xml**
```
<?xml version="1.0" encoding="UTF-8" ?>
<GPACDRM type="CENC AES-CTR">
<!-- 
  kid=0x43215678123412341234123412341237
  key=0x12341234123412341234123412341237
  iv=0x22ee7d4745d3a26a
--> 

<!-- Playready -->
<DRMInfo type="pssh" version="0">
  <BS ID128="9A04F07998404286AB92E65BE0885F95"/>
  <BS bits="32" endian="little" value="518"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="508"/>
  <BS data64="PABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBlAEYAWQBoAFEAegBRAFMATgBCAEkAUwBOAEIASQAwAEUAagBRAFMATgB3AD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AHIAbQBpAFAAYwB6AHYAQwBXAHQAMAA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA=="/>
</DRMInfo>

<!-- Widevine -->
<DRMInfo type="pssh" version="0">
  <BS ID128="EDEF8BA979D64ACEA3C827DCD51D21ED"/>
  <BS data="0x08011210"/>
  <BS ID128="43215678123412341234123412341237"/>
</DRMInfo>

<!-- Marlin -->
<DRMInfo type="pssh" version="0">
  <BS ID128="69f908af481646ea910ccd5dcccb0a3a"/>
  <BS data="0x000000186d61726c000000106d6b69640000000000000000"/>
</DRMInfo>

<!-- CENC -->
<DRMInfo type="pssh" version="1">
  <BS ID128="1077efecc0b24d02ace33c1e52e2fb4b"/>
  <BS bits="32" value="1"/>
  <BS ID128="43215678123412341234123412341237"/>
</DRMInfo>

<CrypTrack trackID="1" IsEncrypted="1" IV_size="8" first_IV="0x22ee7d4745d3a26a" saiSavedBox="senc"   >
  <key KID="0x43215678123412341234123412341237" value="0x12341234123412341234123412341237"/>
</CrypTrack>
</GPACDRM>
```

ps: #2377 ticket is loosely related to a timing, SIDX.earliestPresentationTime value was fixed. 
dash segment fragment(SIDX , mdat) duration does not match, drm changes duration even more
This is a GitHub Issue
repo:gpac
owner:gpac
Title : dash segment fragment(SIDX , mdat) duration does not match, drm changes duration even more
Issue date:

--- start body ---
(latest mp4box from git)
Dash segments don't have an equal duration in `SIDX.duration` and `mdat.duration(samples*dur)` fields. **Should SIDX and mdat fragment chunk durations match?**

Things go even more wrong after encryption, **first** `cenc/v1/1.m4s ` file is  `SIDX.dur=3.76s, mdat=3.84s !!!` values.

Encoding target is 3,84s segments (input aac 48Khz/h264 25fps, gop 96 frames), this should give 100% align video+audio segment durations.

**4x fragments, no drm and drm**
```
https://refapp.hbbtv.org/videos/dashtest/test1/manifest.mpd
v1/1.m4s, SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)

v1/2.m4s SIDX.earliestPresTime=49152(3,84s), timescale=12800
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)

https://refapp.hbbtv.org/videos/dashtest/test1/cenc/manifest.mpd
https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:header,sl:2000,persist:false,contentkey:EjQSNBI0EjQSNBI0EjQSNw==)
cenc/v1/1.m4s SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       11776,        12288,        12288,        11776, total=48128 (3,76s) !!!
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s) !!!

cenc/v1/2.m4s SIDX.earliestPresTime=48128(3,76s)
SIDX.dur=       12800,        12288,        12288,        11776, total=49152 (3,84s)
mdat.dur=24*512=12288, 24*512=12288, 24*512=12288, 24*512=12288, total=49152 (3,84s)
```

**1x fragment, no drm, drm**
```
https://refapp.hbbtv.org/videos/dashtest/test3/manifest.mpd
v1/1.m4s, SIDX.earliestPresTime=0, timescale=12800
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)
v1/2.m4s, SIDX.earliestPresTime=49152
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)

** 1x fragment, drm, test3/cenc/manifest.mpd **
https://refapp.hbbtv.org/videos/dashtest/test3/cenc/manifest.mpd
https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(kid:header,sl:2000,persist:false,contentkey:EjQSNBI0EjQSNBI0EjQSNw==)
cenc/v1/1.m4s, SIDX.earliestPresTime=0, , timescale=12800
SIDX.dur=       48128 (3,76s)  !!!
mdat.dur=96*512=49152 (3,84s) !!!
cenc/v1/2.m4s, SIDX.earliestPresTime=48128(3,76s)
SIDX.dur=       49152 (3,84s)
mdat.dur=96*512=49152 (3,84s)
```

**intermediary temp-xx.mp4 input files**
https://refapp.hbbtv.org/videos/dashtest/test1/temp/temp-v1.mp4
https://refapp.hbbtv.org/videos/dashtest/test1/temp/temp-a1.mp4
https://refapp.hbbtv.org/videos/dashtest/test3/temp/temp-v1.mp4
https://refapp.hbbtv.org/videos/dashtest/test3/temp/temp-a1.mp4

**Dash command lines**
```
4x fragments
MP4Box -dash 184320 -frag  46080 -dash-scale 48000 -mem-frags -rap -profile dashavc264:live \
  -profile-ext urn:hbbtv:dash:profile:isoff-live:2012 -min-buffer 2000 \
  -bs-switching no -sample-groups-traf -single-traf --tfdt64 --tfdt_traf --noroll=yes --btrt=no \
  --truns_first=yes --cmaf=cmf2 -subsegs-per-sidx 0 \
  -segment-name "$RepresentationID$/$Number$$Init=i$" \
  -out manifest.mpd:dual \
  "temp/temp-v1.mp4#trackID=1:id=v1:period=p0:asID=1:role=main:dur=24:#HLSPL=manifest_v1.m3u8" \
  "temp/temp-a1.mp4#trackID=1:id=a1:period=p0:asID=21:role=main:dur=24:#HLSPL=manifest_a1.m3u8:#HLSGroup=audio"

1x fragment
MP4Box -dash 184320 -frag 184320 -dash-scale 48000 -mem-frags -rap -profile dashavc264:live \
  -profile-ext urn:hbbtv:dash:profile:isoff-live:2012 -min-buffer 2000 \
  -bs-switching no -sample-groups-traf -single-traf --tfdt64 --tfdt_traf --noroll=yes --btrt=no \
  --truns_first=yes --cmaf=cmf2 -subsegs-per-sidx 0 \
  -segment-name "$RepresentationID$/$Number$$Init=i$" \
  -out manifest.mpd:dual \
  "temp/temp-v1.mp4#trackID=1:id=v1:period=p0:asID=1:role=main:dur=24:#HLSPL=manifest_v1.m3u8" \
  "temp/temp-a1.mp4#trackID=1:id=a1:period=p0:asID=21:role=main:dur=24:#HLSPL=manifest_a1.m3u8:#HLSGroup=audio"

Encryption
MP4Box -crypt drm-cenc.xml temp/temp-v1.mp4 -out temp/temp-v1-cenc.mp4
MP4Box -crypt drm-cenc.xml temp/temp-a1.mp4 -out temp/temp-a1-cenc.mp4
- run 4x and 1x fragment mp4box with temp-XX-cenc.mp4 input files
```

**drm-cenc.xml**
```
<?xml version="1.0" encoding="UTF-8" ?>
<GPACDRM type="CENC AES-CTR">
<!-- 
  kid=0x43215678123412341234123412341237
  key=0x12341234123412341234123412341237
  iv=0x22ee7d4745d3a26a
--> 

<!-- Playready -->
<DRMInfo type="pssh" version="0">
  <BS ID128="9A04F07998404286AB92E65BE0885F95"/>
  <BS bits="32" endian="little" value="518"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="1"/>
  <BS bits="16" endian="little" value="508"/>
  <BS data64="PABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBlAEYAWQBoAFEAegBRAFMATgBCAEkAUwBOAEIASQAwAEUAagBRAFMATgB3AD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AHIAbQBpAFAAYwB6AHYAQwBXAHQAMAA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA=="/>
</DRMInfo>

<!-- Widevine -->
<DRMInfo type="pssh" version="0">
  <BS ID128="EDEF8BA979D64ACEA3C827DCD51D21ED"/>
  <BS data="0x08011210"/>
  <BS ID128="43215678123412341234123412341237"/>
</DRMInfo>

<!-- Marlin -->
<DRMInfo type="pssh" version="0">
  <BS ID128="69f908af481646ea910ccd5dcccb0a3a"/>
  <BS data="0x000000186d61726c000000106d6b69640000000000000000"/>
</DRMInfo>

<!-- CENC -->
<DRMInfo type="pssh" version="1">
  <BS ID128="1077efecc0b24d02ace33c1e52e2fb4b"/>
  <BS bits="32" value="1"/>
  <BS ID128="43215678123412341234123412341237"/>
</DRMInfo>

<CrypTrack trackID="1" IsEncrypted="1" IV_size="8" first_IV="0x22ee7d4745d3a26a" saiSavedBox="senc"   >
  <key KID="0x43215678123412341234123412341237" value="0x12341234123412341234123412341237"/>
</CrypTrack>
</GPACDRM>
```

ps: #2377 ticket is loosely related to a timing, SIDX.earliestPresentationTime value was fixed. 
--- end body ---
