Fixed ELST box in mp4, and use it to fix track desync issues.
This commit is contained in:
parent
ecbb48dbfe
commit
0c41fee7c8
2 changed files with 25 additions and 15 deletions
|
@ -3197,57 +3197,57 @@ namespace MP4 {
|
||||||
|
|
||||||
void ELST::setSegmentDuration(uint32_t cnt, uint64_t newVal) {
|
void ELST::setSegmentDuration(uint32_t cnt, uint64_t newVal) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
setInt64(newVal, 28*cnt+8);
|
setInt64(newVal, 20*cnt+8);
|
||||||
} else {
|
} else {
|
||||||
setInt32(newVal, 20*cnt+8);
|
setInt32(newVal, 12*cnt+8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ELST::getSegmentDuration(uint32_t cnt) {
|
uint64_t ELST::getSegmentDuration(uint32_t cnt) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
return getInt64(28*cnt+8);
|
return getInt64(20*cnt+8);
|
||||||
} else {
|
} else {
|
||||||
return getInt32(20*cnt+8);
|
return getInt32(12*cnt+8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELST::setMediaTime(uint32_t cnt, uint64_t newVal) {
|
void ELST::setMediaTime(uint32_t cnt, uint64_t newVal) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
setInt64(newVal, 28*cnt+16);
|
setInt64(newVal, 20*cnt+16);
|
||||||
} else {
|
} else {
|
||||||
setInt32(newVal, 20*cnt+12);
|
setInt32(newVal, 12*cnt+12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ELST::getMediaTime(uint32_t cnt) {
|
uint64_t ELST::getMediaTime(uint32_t cnt) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
return getInt64(28*cnt+16);
|
return getInt64(20*cnt+16);
|
||||||
} else {
|
} else {
|
||||||
return getInt32(20*cnt+12);
|
return getInt32(12*cnt+12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELST::setMediaRateInteger(uint32_t cnt, uint16_t newVal) {
|
void ELST::setMediaRateInteger(uint32_t cnt, uint16_t newVal) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
setInt16(newVal, 28*cnt+24);
|
setInt16(newVal, 20*cnt+24);
|
||||||
} else {
|
} else {
|
||||||
setInt16(newVal, 20*cnt+16);
|
setInt16(newVal, 12*cnt+16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ELST::getMediaRateInteger(uint32_t cnt) {
|
uint16_t ELST::getMediaRateInteger(uint32_t cnt) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
return getInt16(28*cnt+24);
|
return getInt16(20*cnt+24);
|
||||||
} else {
|
} else {
|
||||||
return getInt16(20*cnt+16);
|
return getInt16(12*cnt+16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELST::setMediaRateFraction(uint32_t cnt, uint16_t newVal) {
|
void ELST::setMediaRateFraction(uint32_t cnt, uint16_t newVal) {
|
||||||
if (getVersion() == 1) {
|
if (getVersion() == 1) {
|
||||||
setInt16(newVal, 28*cnt+26);
|
setInt16(newVal, 20*cnt+26);
|
||||||
} else {
|
} else {
|
||||||
setInt16(newVal, 20*cnt+18);
|
setInt16(newVal, 12*cnt+18);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ namespace Mist {
|
||||||
uint64_t res = 36 // FTYP Box
|
uint64_t res = 36 // FTYP Box
|
||||||
+ 8 //MOOV box
|
+ 8 //MOOV box
|
||||||
+ 108; //MVHD Box
|
+ 108; //MVHD Box
|
||||||
|
uint64_t firstms = 0xFFFFFFFFFFFFFFFFull;
|
||||||
|
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||||
|
if (myMeta.tracks[*it].firstms < firstms){
|
||||||
|
firstms = myMeta.tracks[*it].firstms;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||||
DTSC::Track & thisTrack = myMeta.tracks[*it];
|
DTSC::Track & thisTrack = myMeta.tracks[*it];
|
||||||
uint64_t tmpRes = 0;
|
uint64_t tmpRes = 0;
|
||||||
|
@ -54,6 +60,9 @@ namespace Mist {
|
||||||
+ 8 //MINF Box
|
+ 8 //MINF Box
|
||||||
+ 36 //DINF Box
|
+ 36 //DINF Box
|
||||||
+ 8; // STBL Box
|
+ 8; // STBL Box
|
||||||
|
if (thisTrack.firstms != firstms){
|
||||||
|
tmpRes += 12;// EDTS entry extra
|
||||||
|
}
|
||||||
|
|
||||||
//These boxes are empty when generating fragmented output
|
//These boxes are empty when generating fragmented output
|
||||||
tmpRes += 20 + (partCount * 4);//STSZ
|
tmpRes += 20 + (partCount * 4);//STSZ
|
||||||
|
@ -171,6 +180,7 @@ namespace Mist {
|
||||||
elstBox.setMediaTime(0, 0);
|
elstBox.setMediaTime(0, 0);
|
||||||
elstBox.setMediaRateInteger(0, 1);
|
elstBox.setMediaRateInteger(0, 1);
|
||||||
elstBox.setMediaRateFraction(0, 0);
|
elstBox.setMediaRateFraction(0, 0);
|
||||||
|
|
||||||
edtsBox.setContent(elstBox, 0);
|
edtsBox.setContent(elstBox, 0);
|
||||||
trakBox.setContent(edtsBox, trakOffset++);
|
trakBox.setContent(edtsBox, trakOffset++);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue