Documentation
¶
Index ¶
- Variables
- func AddCHAPAndCTOC(duration mp3duration.Info, tag *id3v2.Tag, chapters []Chapter) error
- func AddCoverJPEG(tag *id3v2.Tag, jpegPath string) error
- func GetFFmpegChaptersTXT(duration mp3duration.Info, chapters []Chapter) ([]byte, error)
- func GetMP3Duration(mp3path string) (time.Duration, error)
- func StringTimeToMillis(t string) (uint32, error)
- func StringTimeToTime(t string) (time.Time, error)
- func TextFrame(title string) []byte
- func WriteFFmpegChaptersTXT(duration mp3duration.Info, chapters []Chapter) (string, error)
- func WriteFFmpegMetadataFile(duration time.Duration, input TrackInfo) (string, error)
- func WriteID3v2Tag(mp3file string, input TrackInfo) error
- type Chapter
- type TrackInfo
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddCHAPAndCTOC ¶
AddCHAPAndCTOC adds each CHAP and a final CTOC frame to tag from a slice of Chapter structs. duration is an Info struct returned by mp3duration.Read or ReadFile as AddCHAPAndCTOC need to know the duration of the underlying MP3 in order to calculate end of last chapter. If chapters is an empty slice, no frames will be added. Returns error if something failed, in which case tag is to be considered corrupt (should not be saved via tag.Save).
func AddCoverJPEG ¶
AddCoverJPEG adds a cover picture (jpegPath) to tag or return error.
func GetFFmpegChaptersTXT ¶ added in v0.2.0
func GetFFmpegChaptersTXT(duration mp3duration.Info, chapters []Chapter) ([]byte, error)
GetFFmpegChaptersTXT returns a chapters.txt file for use with FFmpeg when generating e.g m4b files. Maybe strange to also support ffmpeg and m4b in a package for MP3 ID3 tags, but the functionality is already here and chapters in m4b is much better. Returns a chapters.txt as a byte slice or error if something failed.
func StringTimeToMillis ¶ added in v0.4.0
func WriteFFmpegChaptersTXT ¶ added in v0.2.0
func WriteFFmpegChaptersTXT(duration mp3duration.Info, chapters []Chapter) (string, error)
WriteFFmpegChaptersTXT returns a temporary (os.CreateTemp) ffmpeg-compatible chapters.txt file for use if generating e.g an m4b instead of an mp3. Returns full path to tempfile or error if something failed.
func WriteFFmpegMetadataFile ¶ added in v0.2.0
WriteFFmpegMetadataFile returns a temporary (os.CreateTemp) ffmpeg-compatible metadata file for use with illustrative example:
ffmpeg -i input.flac output.m4a ffmpeg -i output.m4a -i metadata.txt -map_metadata 1 -codec copy final_output.m4a
Returns full path to tempfile or error if something failed.
func WriteID3v2Tag ¶
WriteID3v2Tag writes everything this package is designed for; title, album, arist, genre, year, cover picture (jpeg), and chapters. If any field is empty (zero length or empty slice, etc), it will not be added to the tag. The output mp3 will be modified.
Types ¶
type TrackInfo ¶
type TrackInfo struct {
Title string `json:"title" yaml:"title,omitempty"`
Album string `json:"album" yaml:"album,omitempty"`
Artist string `json:"artist" yaml:"artist,omitempty"`
Genre string `json:"genre" yaml:"genre,omitempty"`
Year string `json:"year" yaml:"year,omitempty"`
Date time.Time `json:"date" yaml:"date,omitempty"` // yyyy-mm-dd
Track string `json:"track" yaml:"track,omitempty"`
Comment string `json:"comment" yaml:"comment,omitempty"`
Description string `json:"description" yaml:"description,omitempty"`
Language string `json:"language" yaml:"language,omitempty"`
Copyright string `json:"copyright" yaml:"copyright,omitempty"`
CoverJPEG string `json:"coverJPEG" yaml:"coverJPEG,omitempty"`
Chapters []Chapter `json:"chapters" yaml:"chapters,omitempty"`
}