shithub: mcfs

Download patch

ref: 9ded8ee0d2acb896ba8a88038c8fb422078cda71
parent: ed803b2139a490df5d69f4d82320e8fecd2f7324
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Sep 9 10:44:30 EDT 2020

add -i option to print available streams inside a container

--- a/README.md
+++ b/README.md
@@ -8,3 +8,12 @@
 
 For now I'm trying not to go crazy while reading ISO specs.  It hasn't
 been easy so far.
+
+## Status
+
+It's not a filesystem yet, but it can extract video streams (as IVF)
+and audio streams (only AAC atm).
+
+MP4 container format is too complex to ever state it is _supported_ by
+this program.  So far at least some of the videos downloaded from
+youtube are supported.
--- a/iso.c
+++ b/iso.c
@@ -1154,7 +1154,7 @@
 static void
 usage(void)
 {
-	Bprint(&stderr, "usage: iso [-d] [-t TRACK] FILE\n");
+	fprint(2, "usage: iso [-i | -t TRACK] FILE\n");
 	exits("usage");
 }
 
@@ -1164,11 +1164,16 @@
 	Box b;
 	Biobuf *f;
 	char *status;
-	int eof, trackdump;
+	Track *t;
+	int eof, trackdump, iflag, i;
 
 	dflag = 0;
+	iflag = 0;
 	trackdump = -1;
 	ARGBEGIN{
+	case 'i':
+		iflag++;
+		break;
 	case 'd':
 		dflag++;
 		break;
@@ -1175,36 +1180,49 @@
 	case 't':
 		trackdump = atoi(EARGF(usage()));
 		break;
+	default:
+		usage();
 	}ARGEND
 
+	if(argc != 1 || (iflag && trackdump >= 0))
+		usage();
+
 	fmtinstall('T', typefmt);
 
 	Binit(&stderr, 2, OWRITE);
 
-	status = nil;
-	for(; *argv && status == nil; argv++){
-		if((f = Bopen(*argv, OREAD)) == nil)
-			sysfatal("%s: %r", *argv);
+	if((f = Bopen(*argv, OREAD)) == nil)
+		sysfatal("%s: %r", *argv);
 
-		for(;;){
-			dind = 0;
-			memset(&b, 0, sizeof(b));
-			if(parsebox(f, &b, &eof) != 0){
-				if(eof)
-					break;
-				sysfatal("%s: %r", *argv);
-			}
-			Bseek(f, b.dstart+b.dsz, 0);
+	for(;;){
+		dind = 0;
+		memset(&b, 0, sizeof(b));
+		if(parsebox(f, &b, &eof) != 0){
+			if(eof)
+				break;
+			sysfatal("%s: %r", *argv);
 		}
+		Bseek(f, b.dstart+b.dsz, 0);
+	}
 
-		if(trackdump >= 0 && dumptrack(f, trackdump) != 0){
-			Bprint(&stderr, "%s: %r\n", *argv);
-			status = "dump";
+	status = nil;
+	if(iflag){
+		for(i = 0; i < ntracks; i++){
+			t = &tracks[i];
+			print("%d	", t->id);
+			if(t->handlertype == HandlerVideo)
+				print("video	%T", t->video.format);
+			else if(t->handlertype == HandlerAudio)
+				print("audio	%T", t->audio.format);
+			else
+				print("%T	???", t->handlertype);
+			print("\n");
 		}
-
-		Bterm(f);
+	}else if(trackdump >= 0 && dumptrack(f, trackdump) != 0){
+		status = "dump";
 	}
 
+	Bterm(f);
 	Bterm(&stderr);
 
 	exits(status);