The segment_duration must not be set to zero when writing the moov atom for the second time. This is related to edit lists in standard MP4 files.
Unified · Split
| @@ -4036,8 +4036,13 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, · 4035 unmodified lines | |||
| 4036 | /* For fragmented files, we don't know the full length yet. Setting | 4036 | /* For fragmented files, we don't know the full length yet. Setting |
| 4037 | * duration to 0 allows us to only specify the offset, including | 4037 | * duration to 0 allows us to only specify the offset, including |
| 4038 | * the rest of the content (from all future fragments) without specifying | 4038 | * the rest of the content (from all future fragments) without specifying |
| 4039 | * an explicit duration. */ | 4039 | * an explicit duration. |
| 4040 | if (mov->flags & FF_MOV_FLAG_FRAGMENT) | 4040 | * |
| 4041 | * For hybrid_fragmented during mov_write_trailer (mov->moov_written != 0), | ||
| 4042 | * don't reset duration to zero. | ||
| 4043 | */ | ||
| 4044 | if (mov->flags & FF_MOV_FLAG_FRAGMENT && | ||
| 4045 | !(mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED && mov->moov_written)) | ||
| 4041 | duration = 0; | 4046 | duration = 0; |
| 4042 | 4047 | ||
| 4043 | /* duration */ | 4048 | /* duration */ |