Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subtitle sample entries #169

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions box_types_iso14496_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io"
"strings"

"github.com/abema/go-mp4/internal/bitio"
"github.com/abema/go-mp4/internal/util"
Expand Down Expand Up @@ -1210,6 +1211,8 @@ func BoxTypeMp4a() BoxType { return StrToBoxType("mp4a") }
func BoxTypeEnca() BoxType { return StrToBoxType("enca") }
func BoxTypeAvcC() BoxType { return StrToBoxType("avcC") }
func BoxTypePasp() BoxType { return StrToBoxType("pasp") }
func BoxTypeStpp() BoxType { return StrToBoxType("stpp") }
func BoxTypeSbtt() BoxType { return StrToBoxType("sbtt") }

func init() {
AddAnyTypeBoxDef(&VisualSampleEntry{}, BoxTypeMp4v())
Expand All @@ -1221,6 +1224,8 @@ func init() {
AddAnyTypeBoxDef(&AudioSampleEntry{}, BoxTypeEnca())
AddAnyTypeBoxDef(&AVCDecoderConfiguration{}, BoxTypeAvcC())
AddAnyTypeBoxDef(&PixelAspectRatioBox{}, BoxTypePasp())
AddAnyTypeBoxDef(&XMLSubtitleSampleEntry{}, BoxTypeStpp())
AddAnyTypeBoxDef(&TextSubtitleSampleEntry{}, BoxTypeSbtt())
}

type SampleEntry struct {
Expand Down Expand Up @@ -1417,6 +1422,31 @@ type PixelAspectRatioBox struct {
VSpacing uint32 `mp4:"1,size=32"`
}

type XMLSubtitleSampleEntry struct {
SampleEntry `mp4:"0,extend"`
Namespace string `mp4:"1,string"` // space-separated list
SchemaLocation string `mp4:"2,string"` // space-separated list, optional
AuxiliaryMIMETypes string `mp4:"3,string"` // space-separated list, optional
}

func (xse *XMLSubtitleSampleEntry) GetNamespaceList() []string {
return strings.Fields(xse.Namespace)
}

func (xse *XMLSubtitleSampleEntry) GetSchemaLocationList() []string {
return strings.Fields(xse.SchemaLocation)
}

func (xse *XMLSubtitleSampleEntry) GetAuxiliaryMIMETypesList() []string {
return strings.Fields(xse.AuxiliaryMIMETypes)
}

type TextSubtitleSampleEntry struct {
SampleEntry `mp4:"0,extend"`
ContentEncoding string `mp4:"1,string"` // optional
MIMEFormat string `mp4:"2,string"`
}

/*************************** sbgp ****************************/

func BoxTypeSbgp() BoxType { return StrToBoxType("sbgp") }
Expand Down
Loading
Loading