mirror of
https://github.com/nu774/fdkaac.git
synced 2025-02-11 00:40:40 +01:00
m4af: fix mvhd/tkhd duration
According to 14496-12, duration of mvhd/tkhd shall be the sum of duration of edits
This commit is contained in:
parent
fdf5c2f251
commit
9d65d3b3bf
@ -1103,8 +1103,10 @@ void m4af_write_tkhd_box(m4af_ctx_t *ctx, uint32_t track_idx)
|
|||||||
{
|
{
|
||||||
m4af_track_t *track = &ctx->track[track_idx];
|
m4af_track_t *track = &ctx->track[track_idx];
|
||||||
int64_t pos = m4af_tell(ctx);
|
int64_t pos = m4af_tell(ctx);
|
||||||
int64_t duration =
|
int64_t duration = track->duration;
|
||||||
(double)track->duration / track->timescale * ctx->timescale + .5;
|
if (ctx->priming_mode & M4AF_PRIMING_MODE_EDTS)
|
||||||
|
duration -= (track->encoder_delay + track->padding);
|
||||||
|
duration = (double)duration / track->timescale * ctx->timescale + .5;
|
||||||
uint8_t version = (track->creation_time > UINT32_MAX ||
|
uint8_t version = (track->creation_time > UINT32_MAX ||
|
||||||
track->modification_time > UINT32_MAX ||
|
track->modification_time > UINT32_MAX ||
|
||||||
duration > UINT32_MAX);
|
duration > UINT32_MAX);
|
||||||
@ -1169,6 +1171,8 @@ int64_t m4af_movie_duration(m4af_ctx_t *ctx)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < ctx->num_tracks; ++i) {
|
for (i = 0; i < ctx->num_tracks; ++i) {
|
||||||
double x = ctx->track[i].duration;
|
double x = ctx->track[i].duration;
|
||||||
|
if (ctx->priming_mode & M4AF_PRIMING_MODE_EDTS)
|
||||||
|
x -= (ctx->track[i].encoder_delay + ctx->track[i].padding);
|
||||||
int64_t duration = x / ctx->track[i].timescale * ctx->timescale + .5;
|
int64_t duration = x / ctx->track[i].timescale * ctx->timescale + .5;
|
||||||
if (duration > movie_duration)
|
if (duration > movie_duration)
|
||||||
movie_duration = duration;
|
movie_duration = duration;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user