diff options
author | Martin Storsjö <martin@martin.st> | 2014-10-29 22:51:29 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2014-10-30 23:16:50 +0200 |
commit | 00c67fe1d0bc7c2ce49daac9c80ea39d5a663b73 (patch) | |
tree | f8fa5ba2f0780d9faa85183b936b3f0010d576bc | |
parent | cf589faa5b7aed3bb38e08dcd00bd951e69686d1 (diff) | |
download | ffmpeg-00c67fe1d0bc7c2ce49daac9c80ea39d5a663b73.tar.gz |
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>
-rw-r--r-- | libavformat/movenc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 39d294697d..6184101eee 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -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',' ')) |