movenc: Write a 0 duration in mdhd and tkhd for an empty initial moov
ISO/IEC 14496-12:2012/Cor 1:2013 is explicit about how this should be handled. All zeros doesn't mean that the full file has got a zero duration, only that the track samples described within the initial moov have got zero duration. An all ones duration means an indeterminate duration. Keep writing a duration consisting of all ones for the ISM mode - older windows media player versions won't play a file if this is zero. (Newer windows media player versions play either version fine.) Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
cf589faa5b
commit
00c67fe1d0
@ -1434,7 +1434,8 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
|
||||
return update_size(pb, pos);
|
||||
}
|
||||
|
||||
static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
|
||||
static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
MOVTrack *track)
|
||||
{
|
||||
int version = track->track_duration < INT32_MAX ? 0 : 1;
|
||||
|
||||
@ -1453,8 +1454,10 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
|
||||
avio_wb32(pb, track->time); /* modification time */
|
||||
}
|
||||
avio_wb32(pb, track->timescale); /* time scale (sample rate for audio) */
|
||||
if (!track->entry)
|
||||
if (!track->entry && mov->mode == MODE_ISM)
|
||||
(version == 1) ? avio_wb64(pb, UINT64_C(0xffffffffffffffff)) : avio_wb32(pb, 0xffffffff);
|
||||
else if (!track->entry)
|
||||
(version == 1) ? avio_wb64(pb, 0) : avio_wb32(pb, 0);
|
||||
else
|
||||
(version == 1) ? avio_wb64(pb, track->track_duration) : avio_wb32(pb, track->track_duration); /* duration */
|
||||
avio_wb16(pb, track->language); /* language */
|
||||
@ -1470,12 +1473,13 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
|
||||
return 32;
|
||||
}
|
||||
|
||||
static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track)
|
||||
static int mov_write_mdia_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
MOVTrack *track)
|
||||
{
|
||||
int64_t pos = avio_tell(pb);
|
||||
avio_wb32(pb, 0); /* size */
|
||||
ffio_wfourcc(pb, "mdia");
|
||||
mov_write_mdhd_tag(pb, track);
|
||||
mov_write_mdhd_tag(pb, mov, track);
|
||||
mov_write_hdlr_tag(pb, track);
|
||||
mov_write_minf_tag(pb, track);
|
||||
return update_size(pb, pos);
|
||||
@ -1517,8 +1521,10 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
}
|
||||
avio_wb32(pb, track->track_id); /* track-id */
|
||||
avio_wb32(pb, 0); /* reserved */
|
||||
if (!track->entry)
|
||||
if (!track->entry && mov->mode == MODE_ISM)
|
||||
(version == 1) ? avio_wb64(pb, UINT64_C(0xffffffffffffffff)) : avio_wb32(pb, 0xffffffff);
|
||||
else if (!track->entry)
|
||||
(version == 1) ? avio_wb64(pb, 0) : avio_wb32(pb, 0);
|
||||
else
|
||||
(version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
|
||||
|
||||
@ -1771,7 +1777,7 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,
|
||||
}
|
||||
if (track->tref_tag)
|
||||
mov_write_tref_tag(pb, track);
|
||||
mov_write_mdia_tag(pb, track);
|
||||
mov_write_mdia_tag(pb, mov, track);
|
||||
if (track->mode == MODE_PSP)
|
||||
mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box
|
||||
if (track->tag == MKTAG('r','t','p',' '))
|
||||
|
Loading…
x
Reference in New Issue
Block a user