Skip to content

Commit 2229b74

Browse files
felicialimjamrial
authored andcommitted
avformat/movenc: fix setting elst/stss for IAMF with Opus
1 parent d36883f commit 2229b74

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libavformat/movenc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,6 +3092,10 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
30923092
}
30933093
for (i = 0; i < track->entry; i++) {
30943094
int duration = get_cluster_duration(track, i);
3095+
#if CONFIG_IAMFENC
3096+
if (track->iamf && track->par->codec_id == AV_CODEC_ID_OPUS)
3097+
duration = av_rescale(duration, 48000, track->par->sample_rate);
3098+
#endif
30953099
if (i && duration == stts_entries[entries].duration) {
30963100
stts_entries[entries].count++; /* compress */
30973101
} else {
@@ -4022,6 +4026,11 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
40224026
* rounded to 0 when represented in movie timescale units. */
40234027
av_assert0(av_rescale_rnd(start_dts, mov->movie_timescale, track->timescale, AV_ROUND_DOWN) <= 0);
40244028
start_ct = -FFMIN(start_dts, 0);
4029+
4030+
#if CONFIG_IAMFENC
4031+
if (track->iamf && track->par->codec_id == AV_CODEC_ID_OPUS)
4032+
start_ct = av_rescale(start_ct, 48000, track->par->sample_rate);
4033+
#endif
40254034
/* Note, this delay is calculated from the pts of the first sample,
40264035
* ensuring that we don't reduce the duration for cases with
40274036
* dts<0 pts=0. */

0 commit comments

Comments
 (0)