shithub: mcfs

Download patch

ref: 31f2fad7a119fbd09485233b0794be6cbdaa6c31
parent: 03f6379de5cbf44e8d5cec74e4e3d259309af562
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Sep 21 04:58:42 EDT 2020

ebml: fix ivf duration

--- a/common.h
+++ b/common.h
@@ -61,7 +61,6 @@
 
 	packet_f fpacket;
 
-	double ebmldur;
 	vlong timestampscale;
 	vlong seekpreroll;
 	vlong perframe;
--- a/ebml.c
+++ b/ebml.c
@@ -145,10 +145,12 @@
 }
 
 static int
-initctx(Ebml *e)
+initctx(Ebml *e, double duration)
 {
 	char *c;
 
+	e->duration = duration;
+	e->duration *= e->timestampscale;
 	c = codec(e->codec.name);
 	if(e->tracktype == 1){
 		if(strcmp(c, "vp9") == 0)
@@ -172,8 +174,6 @@
 			return 0;
 		}
 	}
-	e->duration = e->ebmldur;
-	e->duration *= e->timestampscale;
 
 err:
 	werrstr("don't know how to remux %s", c);
@@ -245,6 +245,7 @@
 	uvlong ts;
 	uchar *buf;
 	vlong timestamp, endtracks, timestampscale;
+	double duration;
 	Ebml e, te;
 
 	buf = nil;
@@ -256,6 +257,7 @@
 	te.tracknum = -1;
 	timestampscale = 1000000;
 	e.tracknum = -1;
+	duration = 0;
 	for(isebml = 0; left != 0;){
 		if(endtracks > 0 && left < endtracks && trackdump == Nodump){
 			/* early exit */
@@ -316,7 +318,7 @@
 			left -= n;
 			sz -= n;
 			if(track == trackdump && track == te.tracknum){
-				if(te.fpacket == nil && initctx(&te) != 0){
+				if(te.fpacket == nil && initctx(&te, duration) != 0){
 					werrstr("packet: %r");
 					goto err;
 				}
@@ -449,7 +451,7 @@
 			else
 				ebmlgetnumber(0x56bb, e.seekpreroll)
 			else
-				ebmlgetfloat(0x4489, e.duration)
+				ebmlgetfloat(0x4489, duration)
 			else
 				ebmlgetnumber(0x73c5, e.trackuid)
 			//else