ref: e8d055cd5d76f2902e12d0a39ac298e9bb2e378a
parent: a6d7e91e617d0dc39ab440a40e21e2986e099dbd
author: Sigrid Haflínudóttir <[email protected]>
date: Mon Sep 21 17:02:02 EDT 2020
show more info on subtitles
--- a/common.h
+++ b/common.h
@@ -70,6 +70,7 @@
int tracknum;
int tracktype;
vlong codecdelay;
+ char lang[8];
};
extern Biobuf stderr, out;
--- a/ebml.c
+++ b/ebml.c
@@ -130,12 +130,18 @@
}
static char *
-codec(char *s)
+format(Ebml *e)
{
static char t[16];
+ char *s;
int n;
- n = snprint(t, sizeof(t), "%s", s+2);
+ if(e->tracktype == 17){
+ if(strcmp(e->codec.name, "S_TEXT/UTF8") == 0)
+ return "srt";
+ }
+
+ n = snprint(t, sizeof(t), "%s", e->codec.name+2);
for(n -= 1; n >= 0; n--)
t[n] = tolower(t[n]);
if((s = strchr(t, '/')) != nil)
@@ -151,7 +157,7 @@
e->duration = duration;
e->duration *= e->timestampscale;
- c = codec(e->codec.name);
+ c = format(e);
if(e->tracktype == 1){
if(strcmp(c, "vp9") == 0)
e->fmt = FmtVp09;
@@ -173,7 +179,7 @@
return 0;
}
}else if(e->tracktype == 17){
- if(strcmp(e->codec.name, "S_TEXT/UTF8") == 0){
+ if(strcmp(c, "srt") == 0){
e->fmt = FmtSrt;
e->fpacket = srtpacket;
return 0;
@@ -230,13 +236,13 @@
}
t = tracktype(e);
- Bprint(o, "%d\t%s\t", e->tracknum, t);
+ Bprint(o, "%d\t%s\t%s\t", e->tracknum, t, format(e));
if(e->tracktype == 1)
- Bprint(o, "%s\t%d\t%d", codec(e->codec.name), e->video.width, e->video.height);
+ Bprint(o, "%d\t%d", e->video.width, e->video.height);
else if(e->tracktype == 2)
- Bprint(o, "%s\t%d\t%d", codec(e->codec.name), e->audio.channels, (int)e->audio.samplerate);
+ Bprint(o, "%d\t%d", e->audio.channels, (int)e->audio.samplerate);
else if(e->tracktype == 17)
- Bprint(o, "%s", e->codec.name); /* FIXME */
+ Bprint(o, "%s", e->lang);
else
Bprint(o, "???");
Bprint(o, "\n");
@@ -464,6 +470,8 @@
ebmlgetnumber(0x75a2, te.discardpad)
else
ebmlgetnumber(0x9b, te.blockdur)
+ else
+ ebmlgetstring(0x22b59c, e.lang)
}
if(Bseek(f, sz, 1) < 0)