}
// This box seems important for the psp playback ... without it the movie seems to hang
-static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
+ MOVTrack *track)
{
int64_t duration = av_rescale_rnd(track->track_duration, MOV_TIMESCALE,
track->timescale, AV_ROUND_UP);
duration += delay;
}
+ /* For fragmented files, we don't know the full length yet. Setting
+ * duration to 0 allows us to only specify the offset, including
+ * the rest of the content (from all future fragments) without specifying
+ * an explicit duration. */
+ if (mov->flags & FF_MOV_FLAG_FRAGMENT)
+ duration = 0;
+
/* duration */
if (version == 1) {
avio_wb64(pb, duration);
if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS ||
(track->entry && track->cluster[0].dts) ||
is_clcp_track(track)) {
- if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
- mov_write_edts_tag(pb, track); // PSP Movies require edts box
+ mov_write_edts_tag(pb, mov, track); // PSP Movies require edts box
}
if (track->tref_tag)
mov_write_tref_tag(pb, track);
return 0;
}
+static int mov_write_tfdt_tag(AVIOContext *pb, MOVTrack *track)
+{
+ int64_t pos = avio_tell(pb);
+
+ avio_wb32(pb, 0); /* size */
+ ffio_wfourcc(pb, "tfdt");
+ avio_w8(pb, 1); /* version */
+ avio_wb24(pb, 0);
+ avio_wb64(pb, track->frag_start);
+ return update_size(pb, pos);
+}
+
static int mov_write_traf_tag(AVIOContext *pb, MOVMuxContext *mov,
MOVTrack *track, int64_t moof_offset,
int moof_size)
ffio_wfourcc(pb, "traf");
mov_write_tfhd_tag(pb, mov, track, moof_offset);
+ mov_write_tfdt_tag(pb, track);
mov_write_trun_tag(pb, mov, track, moof_size);
if (mov->mode == MODE_ISM) {
mov_write_tfxd_tag(pb, track);
}
info = &track->frag_info[track->nb_frag_info - 1];
info->offset = avio_tell(s->pb);
- info->time = mov->tracks[i].frag_start;
+ info->time = track->frag_start;
info->duration = duration;
mov_write_tfrf_tags(s->pb, mov, track);
* of this packet to be what the previous packets duration implies. */
trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
}
- if (trk->start_dts == AV_NOPTS_VALUE)
+ if (trk->start_dts == AV_NOPTS_VALUE) {
trk->start_dts = pkt->dts;
+ if (pkt->dts && mov->flags & FF_MOV_FLAG_EMPTY_MOOV)
+ av_log(s, AV_LOG_WARNING,
+ "Track %d starts with a nonzero dts %"PRId64". This "
+ "currently isn't handled correctly in combination with "
+ "empty_moov.\n", pkt->stream_index, pkt->dts);
+ }
trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
if (pkt->pts == AV_NOPTS_VALUE) {