1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avformat/movenc: fix setting elst/stss for IAMF with Opus

This commit is contained in:
Felicia Lim
2025-02-20 12:50:28 -08:00
committed by James Almer
parent d36883f119
commit 2229b74127

View File

@ -3092,6 +3092,10 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
}
for (i = 0; i < track->entry; i++) {
int duration = get_cluster_duration(track, i);
#if CONFIG_IAMFENC
if (track->iamf && track->par->codec_id == AV_CODEC_ID_OPUS)
duration = av_rescale(duration, 48000, track->par->sample_rate);
#endif
if (i && duration == stts_entries[entries].duration) {
stts_entries[entries].count++; /* compress */
} else {
@ -4022,6 +4026,11 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
* rounded to 0 when represented in movie timescale units. */
av_assert0(av_rescale_rnd(start_dts, mov->movie_timescale, track->timescale, AV_ROUND_DOWN) <= 0);
start_ct = -FFMIN(start_dts, 0);
#if CONFIG_IAMFENC
if (track->iamf && track->par->codec_id == AV_CODEC_ID_OPUS)
start_ct = av_rescale(start_ct, 48000, track->par->sample_rate);
#endif
/* Note, this delay is calculated from the pts of the first sample,
* ensuring that we don't reduce the duration for cases with
* dts<0 pts=0. */