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/

I tried to find a solution by following the code flow, but failed.   
I am making segment files now.    
and I want to allocate sample_duration value in trun box.    
refer to below picture   
<img width="1840" alt="trun----whatpng" src="https://github.com/gpac/gpac/assets/80387186/14c9f4cf-4cb5-4c9c-acd7-a4b7a8056c8a">   

I tried below code  
```
// First, I do not use default value using force_traf_flags – if GF_TRUE, will ignore these default in each traf but will still write them in moov
if ((err = gf_isom_setup_track_fragment(file_ptr, track_id, sample_description_index, 0, 0, 0, 0, 0 , GF_TRUE)) != GF_OK)
{
        fprintf(stderr, "Err Raised : gf_isom_setup_track_fragment: %d\n", err);
        return -1;
}
// Second , add sample_duration in this function. I think that 1024 is trun sample_duration value
if ((err = gf_isom_fragment_add_sample(file_ptr, track_id, &iso_sample, sample_description_index, 1024, 0, 0, GF_FALSE)) != GF_OK)
{
            fprintf(stderr, "Err raised : gf_isom_fragment_add_smple :%d\n", err);
            return -1;
 }
```
In result, If every sample has same sample_duration, tfdt default_sample_duration is added.  
But when I use `gf_isom_fragment_add_sample` this function using different Duration argument (not fixed 1024)  
sample_duration of trun box is added.   

https://github.com/gpac/gpac/blob/50c5c207595bb22f7f120572680971f0aae3c5fc/src/isomedia/movie_fragments.c#L638C7-L638C7  

Result of looking at the code above  
If first trun sample_duration and second sample_duration values are diffrent,  
The code below works
```
if (!RunDur) trun->flags |= GF_ISOM_TRUN_DURATION;
```
https://github.com/gpac/gpac/blob/50c5c207595bb22f7f120572680971f0aae3c5fc/src/isomedia/movie_fragments.c#L678   

I am curious as to why the trun sample_duration flag does not work when the trun sample_duration is the same.  


How to allocate sample_duration value in trun box ??
This is a GitHub Issue
repo:gpac
owner:gpac
Title : How to allocate sample_duration value in trun box ??
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/

I tried to find a solution by following the code flow, but failed.   
I am making segment files now.    
and I want to allocate sample_duration value in trun box.    
refer to below picture   
<img width="1840" alt="trun----whatpng" src="https://github.com/gpac/gpac/assets/80387186/14c9f4cf-4cb5-4c9c-acd7-a4b7a8056c8a">   

I tried below code  
```
// First, I do not use default value using force_traf_flags – if GF_TRUE, will ignore these default in each traf but will still write them in moov
if ((err = gf_isom_setup_track_fragment(file_ptr, track_id, sample_description_index, 0, 0, 0, 0, 0 , GF_TRUE)) != GF_OK)
{
        fprintf(stderr, "Err Raised : gf_isom_setup_track_fragment: %d\n", err);
        return -1;
}
// Second , add sample_duration in this function. I think that 1024 is trun sample_duration value
if ((err = gf_isom_fragment_add_sample(file_ptr, track_id, &iso_sample, sample_description_index, 1024, 0, 0, GF_FALSE)) != GF_OK)
{
            fprintf(stderr, "Err raised : gf_isom_fragment_add_smple :%d\n", err);
            return -1;
 }
```
In result, If every sample has same sample_duration, tfdt default_sample_duration is added.  
But when I use `gf_isom_fragment_add_sample` this function using different Duration argument (not fixed 1024)  
sample_duration of trun box is added.   

https://github.com/gpac/gpac/blob/50c5c207595bb22f7f120572680971f0aae3c5fc/src/isomedia/movie_fragments.c#L638C7-L638C7  

Result of looking at the code above  
If first trun sample_duration and second sample_duration values are diffrent,  
The code below works
```
if (!RunDur) trun->flags |= GF_ISOM_TRUN_DURATION;
```
https://github.com/gpac/gpac/blob/50c5c207595bb22f7f120572680971f0aae3c5fc/src/isomedia/movie_fragments.c#L678   

I am curious as to why the trun sample_duration flag does not work when the trun sample_duration is the same.  


--- end body ---
