From 7ff0010dfaa0419c2da294d425f4d334cc4c5021 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 16 Dec 2016 17:26:44 +0100 Subject: [PATCH] Fixed MP4 live in Firefox --- src/output/output_progressive_mp4.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/output/output_progressive_mp4.cpp b/src/output/output_progressive_mp4.cpp index f29df99b..793138a4 100644 --- a/src/output/output_progressive_mp4.cpp +++ b/src/output/output_progressive_mp4.cpp @@ -588,7 +588,20 @@ namespace Mist { bool firstSample = true; + //Fun fact! Firefox cares about the ordering here. + //It doesn't care about the order or track IDs in the header. + //But - the first TRAF must be a video TRAF, if video is present. + std::deque::iterator> sortedTracks; for (std::map::iterator it = currentPartSet.begin(); it != currentPartSet.end(); it++) { + if (myMeta.tracks[it->first].type == "video"){ + sortedTracks.push_front(it); + }else{ + sortedTracks.push_back(it); + } + } + + for (std::deque::iterator>::iterator ti = sortedTracks.begin(); ti != sortedTracks.end(); ++ti) { + std::map::iterator & it = *ti; unsigned int tid = it->first; DTSC::Track & thisTrack = myMeta.tracks[tid]; MP4::TRAF trafBox;