shithub: treason

Download patch

ref: 2011eb1bf6d3757bfd58788357f6b4607d6baafe
parent: 5fb764c5f10056357632a54bbeb15c646042a44f
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Feb 17 07:03:14 EST 2021

add -t option to manually pick tracks by their ids

--- a/main.c
+++ b/main.c
@@ -12,6 +12,8 @@
 
 int mainstacksize = 128*1024;
 
+uvlong trackpref;
+
 static Image *curim;
 static u8int *curpx;
 static uvlong lastframe;
@@ -142,7 +144,7 @@
 static void
 usage(void)
 {
-	fprint(2, "usage: %s [-a AUDIO] file.mp4\n", argv0);
+	fprint(2, "usage: %s [-a AUDIOFILE] [-t N -t M ...] file.mp4\n", argv0);
 	threadexitsall("usage");
 }
 
@@ -181,6 +183,7 @@
 
 	debug = 0;
 	audio = nil;
+	trackpref = 0;
 	ARGBEGIN{
 	case 'a':
 		if(audio != nil){
@@ -200,6 +203,9 @@
 		break;
 	case 'd':
 		debug++;
+		break;
+	case 't':
+		trackpref |= 1<<atoi(EARGF(usage()));
 		break;
 	}ARGEND
 
--- a/stream_mc.c
+++ b/stream_mc.c
@@ -17,6 +17,8 @@
 	u8int buf[Bufsz];
 };
 
+extern uvlong trackpref;
+
 static int
 mcfs(char **argv, int *pipefd)
 {
@@ -75,6 +77,8 @@
 	Binit(&b, p, OREAD);
 	for(ns = naudio = nvideo = 0; ns < Maxstreams && (line = Brdstr(&b, '\n', 1)) != nil;){
 		n = tokenize(line, v, nelem(v));
+		if(trackpref != 0 && (trackpref & (1<<atoi(v[0]))) == 0)
+			continue;
 		if(n > 4 && str2fmt(v[2]) >= 0){
 			argv[1] = "-t";
 			argv[2] = v[0]; /* stream id */