Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at https://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Detailed guidelines: https://gpac.io/bug-reporting/

When I write the segment files using callback function (```gf_isom_set_write_callback```) 
First segment is made in the direction I want.
(```sidx styp moof mdat```)

Second segment, I want to make like below boxes  
```styp moof mdat```.  (without sidx)   
but mdat comes separately when I close the segemnt ```gf_isom_close_segment```
comes first styp, moof, and next seperatly comes mdat box   
Can’t we all make the box together? (styp, moof, mdat)   

the only different thing is   
I set the second argument to sidx to -1,  
because I do not want to make sidx box    
```
gf_isom_close_segment(file_ptr, -1, track_id, ref_track_decode_time, 0, 0, GF_FALSE, GF_FALSE, GF_FALSE, GF_FALSE, 0, 0, 0, NULL)
```



Making segment using Module API, mdat box comes separately.
This is a GitHub Issue
repo:gpac
owner:gpac
Title : Making segment using Module API, mdat box comes separately.
Issue date:

--- start body ---
Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at https://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Detailed guidelines: https://gpac.io/bug-reporting/

When I write the segment files using callback function (```gf_isom_set_write_callback```) 
First segment is made in the direction I want.
(```sidx styp moof mdat```)

Second segment, I want to make like below boxes  
```styp moof mdat```.  (without sidx)   
but mdat comes separately when I close the segemnt ```gf_isom_close_segment```
comes first styp, moof, and next seperatly comes mdat box   
Can’t we all make the box together? (styp, moof, mdat)   

the only different thing is   
I set the second argument to sidx to -1,  
because I do not want to make sidx box    
```
gf_isom_close_segment(file_ptr, -1, track_id, ref_track_decode_time, 0, 0, GF_FALSE, GF_FALSE, GF_FALSE, GF_FALSE, 0, 0, 0, NULL)
```



--- end body ---

None