MKV output bugfixes
This commit is contained in:
parent
fb6b0dd492
commit
d77ae15b46
12
hi/mkv.c
12
hi/mkv.c
@ -272,7 +272,7 @@ struct Internal {
|
||||
size_t videoTrack, audioTrack;
|
||||
|
||||
size_t currentClusterTimecode;
|
||||
|
||||
bool beforeFirstCluster;
|
||||
bool codecPrivatesFound;
|
||||
|
||||
CHiBSFrames *audioBacklog;
|
||||
@ -315,12 +315,13 @@ static int muxmkv_perform(CHiPubNode *pubn) {
|
||||
|
||||
size_t nextTimestamp = next_timestamp(this);
|
||||
|
||||
bool shouldUpdateCluster = (this->videoBacklog && this->videoBacklog->count && (this->videoBacklog->data[0].flags & CUTIHI_BS_FLAG_KEY)) || (nextTimestamp - this->currentClusterTimecode > 15000);
|
||||
bool shouldUpdateCluster = this->beforeFirstCluster || (this->videoBacklog && this->videoBacklog->count && (this->videoBacklog->data[0].flags & CUTIHI_BS_FLAG_KEY)) || (nextTimestamp - this->currentClusterTimecode > 15000);
|
||||
|
||||
if(shouldUpdateCluster) {
|
||||
if(this->currentClusterTimecode != 0) {
|
||||
if(!this->beforeFirstCluster) {
|
||||
ebml_writer_pop(&this->wr);
|
||||
}
|
||||
this->beforeFirstCluster = false;
|
||||
|
||||
// Cluster
|
||||
ebml_writer_push(&this->wr, 0x1F43B675);
|
||||
@ -493,14 +494,14 @@ static int muxmkv_perform(CHiPubNode *pubn) {
|
||||
|
||||
assert(this->audioBacklog->data[0].flags & CUTIHI_BS_SETUP_PACKET);
|
||||
|
||||
if(CHi_Crawl(&pubn->sinks[0])->type == CUTIHI_VAL_OPUSBS) {
|
||||
if(CHi_Crawl(&pubn->sinks[1])->type == CUTIHI_VAL_OPUSBS) {
|
||||
ebml_writer_put(&this->wr, 0x86, EBML_STRING, (EBMLPrimitive) {.string = "A_OPUS"});
|
||||
|
||||
CHiBSFrame *opusHead = &this->audioBacklog->data[0];
|
||||
|
||||
// CodecPrivate
|
||||
ebml_writer_put(&this->wr, 0x63A2, EBML_BINARY, (EBMLPrimitive) {.binary = {.length = opusHead->sz, .ptr = opusHead->ptr}});
|
||||
} else if(CHi_Crawl(&pubn->sinks[0])->type == CUTIHI_VAL_AACBS) {
|
||||
} else if(CHi_Crawl(&pubn->sinks[1])->type == CUTIHI_VAL_AACBS) {
|
||||
ebml_writer_put(&this->wr, 0x86, EBML_STRING, (EBMLPrimitive) {.string = "A_AAC/MPEG2/LC"});
|
||||
}
|
||||
|
||||
@ -547,6 +548,7 @@ static int muxmkv_start(CHiPubNode *pubn) {
|
||||
|
||||
this->currentClusterTimecode = 0;
|
||||
this->codecPrivatesFound = false;
|
||||
this->beforeFirstCluster = true;
|
||||
|
||||
int trackNum = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user