mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 13:26:38 +08:00
支持 ASS 字幕原样渲染与字幕显示设置
This commit is contained in:
@@ -100,7 +100,7 @@ func TestEmbeddedSubtitleProbeClassifiesTextAndBitmapTracks(t *testing.T) {
|
||||
if len(tracks) != 2 {
|
||||
t.Fatalf("len(tracks) = %d, want 2", len(tracks))
|
||||
}
|
||||
if tracks[0].Delivery != "webvtt" || tracks[0].Path != "embedded:2" {
|
||||
if tracks[0].Delivery != "ass" || tracks[0].Path != "embedded:2" {
|
||||
t.Fatalf("text track = %#v", tracks[0])
|
||||
}
|
||||
if tracks[1].Delivery != "burn" || tracks[1].StreamIndex != 4 {
|
||||
@@ -108,6 +108,18 @@ func TestEmbeddedSubtitleProbeClassifiesTextAndBitmapTracks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubtitleDeliveryClassifiesASSForLibass(t *testing.T) {
|
||||
if got := subtitleDeliveryForCodec("ass"); got != "ass" {
|
||||
t.Fatalf("ass delivery = %q, want ass", got)
|
||||
}
|
||||
if got := subtitleDeliveryForCodec("ssa"); got != "ass" {
|
||||
t.Fatalf("ssa delivery = %q, want ass", got)
|
||||
}
|
||||
if got := subtitleDeliveryForCodec("subrip"); got != "webvtt" {
|
||||
t.Fatalf("subrip delivery = %q, want webvtt", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormaliseTimecode(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"0:00:01": "00:00:01",
|
||||
@@ -176,4 +188,17 @@ func TestSubtitleServeRawWritesSourceBytes(t *testing.T) {
|
||||
if got := buf.String(); got != raw {
|
||||
t.Fatalf("ServeRaw returned %q, want raw %q", got, raw)
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
if err := svc.ServeASS(t.Context(), media.ID, subPath, &buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := buf.String(); got != raw {
|
||||
t.Fatalf("ServeASS returned %q, want raw ASS %q", got, raw)
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
if err := svc.ServeRaw(t.Context(), media.ID, videoPath, &buf); err == nil {
|
||||
t.Fatal("ServeRaw accepted a non-subtitle file")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user