- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://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

We are building an LL HLS origin and we have noticed GPAC sometimes sends several times an HTTP PUT request to the origin, for the same segment/part name, when we are in `llhls=sf` mode.

## GPAC command

```
gpac -i udp://239.0.0.1:1234 reframer:rt=on -o http://http_origin:80/live/upload/playlist.mpd:gpac:dual:buf=-100:segdur=3.0:cdur=0.2:asto=2.8:llhls=sf:hlsc=true:cmaf=cmfc:dmode=dynamic:profile=dashif.ll:utcs=https://time.akamai.com/?iso:hmode=push:template=segment_$(openssl rand -hex 5):hmode=push
```

## FFMPEG command

```
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=25 -f lavfi -i sine=frequency=1000 -f mpegts -vcodec libx264 -acodec aac -profile:v high444 -b:v 2000k -maxrate 2000k -bufsize 2000k -r:v 25 -g 50 udp://239.0.0.1:1234
```

## Steps to reproduce

Repository with all the artifacts to reproduce the case: https://github.com/estigma88/gpac_experiments/tree/main/6-udp_mpegts_duplicated_segm.

The following are the steps:

1. Navigate to the `6-udp_mpegts_duplicated_segm` folder
2. Run the docker compose for few minutes: `docker-compose up`
3. Stop the docker compose; `docker-compose down`
4. Two new folders should show up: `content` (media folder) and `logs` (nginx logs)
5. Run the python script to find the HTTP PUT duplicates in the nginx access logs:  `python3 findmediaduplicates.py` . The following is an output example:

```
  playlist.mpd
  playlist.m3u8
  playlist_1.m3u8
  playlist_2.m3u8
  segment_890df68f91_track257_2.m4s
  segment_890df68f91_track256_2.m4s
  segment_890df68f91_track256_3.m4s
  segment_890df68f91_track257_3.m4s
  segment_890df68f91_track257_4.m4s
  segment_890df68f91_track256_4.m4s
  segment_890df68f91_track256_5.m4s
  segment_890df68f91_track257_5.m4s
```

6. Open the access log in logs/access.log, and try to find one of above duplicates, you will see two places: before the first part is transferred, and before the last part is transferred:

```
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist.mpd HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist_1.m3u8 HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist_2.m3u8 HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s.1 HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"

....

172.25.0.3 - - [07/Jul/2023:01:54:42 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:42 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s.15 HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
```

## Questions

1. What is being sent in the second HTTP PUT, before the last part? and why?
2. Is this happening only for full segments or also for parts? we have seen this happening sometimes for parts, but hard to reproduce
3. Also, we have seen GPAC resending a whole segment and its parts, is that common? When can that happen?
4. What should the origin behavior be in those cases? override the previous segment? ignore?


Any help will be much appreciated.


HTTP push filter (httpout) sends several times the same segment to the origin
This is a GitHub Issue
repo:gpac
owner:gpac
Title : HTTP push filter (httpout) sends several times the same segment to the origin
Issue date:

--- start body ---
- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://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

We are building an LL HLS origin and we have noticed GPAC sometimes sends several times an HTTP PUT request to the origin, for the same segment/part name, when we are in `llhls=sf` mode.

## GPAC command

```
gpac -i udp://239.0.0.1:1234 reframer:rt=on -o http://http_origin:80/live/upload/playlist.mpd:gpac:dual:buf=-100:segdur=3.0:cdur=0.2:asto=2.8:llhls=sf:hlsc=true:cmaf=cmfc:dmode=dynamic:profile=dashif.ll:utcs=https://time.akamai.com/?iso:hmode=push:template=segment_$(openssl rand -hex 5):hmode=push
```

## FFMPEG command

```
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=25 -f lavfi -i sine=frequency=1000 -f mpegts -vcodec libx264 -acodec aac -profile:v high444 -b:v 2000k -maxrate 2000k -bufsize 2000k -r:v 25 -g 50 udp://239.0.0.1:1234
```

## Steps to reproduce

Repository with all the artifacts to reproduce the case: https://github.com/estigma88/gpac_experiments/tree/main/6-udp_mpegts_duplicated_segm.

The following are the steps:

1. Navigate to the `6-udp_mpegts_duplicated_segm` folder
2. Run the docker compose for few minutes: `docker-compose up`
3. Stop the docker compose; `docker-compose down`
4. Two new folders should show up: `content` (media folder) and `logs` (nginx logs)
5. Run the python script to find the HTTP PUT duplicates in the nginx access logs:  `python3 findmediaduplicates.py` . The following is an output example:

```
  playlist.mpd
  playlist.m3u8
  playlist_1.m3u8
  playlist_2.m3u8
  segment_890df68f91_track257_2.m4s
  segment_890df68f91_track256_2.m4s
  segment_890df68f91_track256_3.m4s
  segment_890df68f91_track257_3.m4s
  segment_890df68f91_track257_4.m4s
  segment_890df68f91_track256_4.m4s
  segment_890df68f91_track256_5.m4s
  segment_890df68f91_track257_5.m4s
```

6. Open the access log in logs/access.log, and try to find one of above duplicates, you will see two places: before the first part is transferred, and before the last part is transferred:

```
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist.mpd HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist_1.m3u8 HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/playlist_2.m3u8 HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:39 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s.1 HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"

....

172.25.0.3 - - [07/Jul/2023:01:54:42 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s HTTP/1.1" 204 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
172.25.0.3 - - [07/Jul/2023:01:54:42 +0000] "PUT /live/upload/segment_890df68f91_track257_2.m4s.15 HTTP/1.1" 201 0 "-" "GPAC/2.3-DEV-rev422-g64201a26-master"
```

## Questions

1. What is being sent in the second HTTP PUT, before the last part? and why?
2. Is this happening only for full segments or also for parts? we have seen this happening sometimes for parts, but hard to reproduce
3. Also, we have seen GPAC resending a whole segment and its parts, is that common? When can that happen?
4. What should the origin behavior be in those cases? override the previous segment? ignore?


Any help will be much appreciated.


--- end body ---
