This is required for the files to play back in windows media player.
These duration fields are part of the moov atom, which isn't
transmitted to clients in smooth streaming, so it didn't matter
for playback when served over http.
---
libavformat/movenc.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9a03cc5..5c5d39e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1243,6 +1243,9 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack
*track)
{
int version = track->track_duration < INT32_MAX ? 0 : 1;
+ if (track->mode == MODE_ISM)
+ version = 1;
+
(version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */
ffio_wfourcc(pb, "mdhd");
avio_w8(pb, version);
@@ -1255,7 +1258,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) */
- (version == 1) ? avio_wb64(pb, track->track_duration) : avio_wb32(pb,
track->track_duration); /* duration */
+ if (track->mode == MODE_ISM)
+ avio_wb64(pb, UINT64_C(0xffffffffffffffff));
+ else
+ (version == 1) ? avio_wb64(pb, track->track_duration) : avio_wb32(pb,
track->track_duration); /* duration */
avio_wb16(pb, track->language); /* language */
avio_wb16(pb, 0); /* reserved (quality) */
@@ -1286,6 +1292,9 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack
*track, AVStream *st)
track->timescale, AV_ROUND_UP);
int version = duration < INT32_MAX ? 0 : 1;
+ if (track->mode == MODE_ISM)
+ version = 1;
+
(version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */
ffio_wfourcc(pb, "tkhd");
avio_w8(pb, version);
@@ -1299,7 +1308,10 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack
*track, AVStream *st)
}
avio_wb32(pb, track->track_id); /* track-id */
avio_wb32(pb, 0); /* reserved */
- (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
+ if (track->mode == MODE_ISM)
+ avio_wb64(pb, UINT64_C(0xffffffffffffffff));
+ else
+ (version == 1) ? avio_wb64(pb, duration) : avio_wb32(pb, duration);
avio_wb32(pb, 0); /* reserved */
avio_wb32(pb, 0); /* reserved */
--
1.7.3.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel