shithub: mcfs

Download patch

ref: 6d2552a35e42a7fb6397b361a0ffa3a330711731
parent: 321a1b6a441f59e3e5a31f29a64a17e93ffa27f5
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Dec 14 11:00:04 EST 2020

extract aac audio from mkv

--- /dev/null
+++ b/aac.c
@@ -1,0 +1,16 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include "common.h"
+
+int
+aacpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts)
+{
+	int i;
+
+	USED(ctx); USED(ts);
+	for(i = 0; i < np; i++, p++)
+		Bwrite(out, p->data, p->sz);
+
+	return 0;
+}
--- a/common.h
+++ b/common.h
@@ -92,6 +92,7 @@
 int oggpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
 int srtpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
 int mp3packet(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
+int aacpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
 
 int ebmlint(Biobuf *f, vlong *out, int isid);
 vlong ebmlel(Biobuf *f, vlong sz, vlong *id, vlong *esz);
--- a/ebml.c
+++ b/ebml.c
@@ -191,24 +191,25 @@
 		if(strcmp(c, "vorbis") == 0){
 			e->fmt = FmtVorbis;
 			e->fpacket = oggpacket;
-			return 0;
-		}
-		if(strcmp(c, "opus") == 0){
+		}else if(strcmp(c, "opus") == 0){
 			e->fmt = FmtOpus;
 			e->fpacket = oggpacket;
-			return 0;
-		}
-		if(strcmp(c, "mp3") == 0){
+		}else if(strcmp(c, "mp3") == 0){
 			e->fmt = FmtMp3;
 			e->fpacket = mp3packet;
-			return 0;
-		}
+		}else if(strcmp(c, "aac") == 0){
+			e->fmt = FmtMp4a;
+			e->fpacket = aacpacket;
+		}else
+			goto err;
+		return 0;
 	}else if(e->tracktype == Tracksubtitles){
 		if(strcmp(c, "srt") == 0){
 			e->fmt = FmtSrt;
 			e->fpacket = srtpacket;
-			return 0;
-		}
+		}else
+			goto err;
+		return 0;
 	}
 
 err:
--- a/ivf.c
+++ b/ivf.c
@@ -141,7 +141,7 @@
 			}
 		}
 
-		if(ivfframe(out, p[0].data, p[0].sz, ts, ctx->fmt == FmtAvc1) != 0)
+		if(ivfframe(out, p->data, p->sz, ts, ctx->fmt == FmtAvc1) != 0)
 			goto err;
 		ctx->frid++;
 	}
--- a/mkfile
+++ b/mkfile
@@ -6,6 +6,7 @@
 BIN=/$objtype/bin
 
 OFILES=\
+	aac.$O\
 	crc32.$O\
 	ebml.$O\
 	iso.$O\