Documentation
¶
Index ¶
- Variables
- func GetBitrate(mp3Filepath string) (result int, err error)
- func GetFFmpegMetadataTag(mp3Filepath string) (result map[string]string, err error)
- func GetLengthInSeconds(mp3Filepath string) (result float64, err error)
- func SetFFmpegMetadataTag(mp3Filepath string, metadata map[string]string, chapters []Chapter) (err error)
- type Chapter
- type MP3Builder
- type Tags
Constants ¶
This section is empty.
Variables ¶
var ( DEFAULT_TIME_BASE_INT = 1000000000 DEFAULT_TIME_BASE = fmt.Sprintf("1/%d", DEFAULT_TIME_BASE_INT) TIME_BASE_REGEX = regexp.MustCompile("1/([0-9]*)") )
var ( ILLEGAL_METADATA_CHARATERS = regexp.MustCompile(`(#|;|=|\\)`) FFMPEG_STATS_REGEX = regexp.MustCompile(`.+time=(?:.*)([0-9]{2,99}):([0-9]{2}):([0-9]{2}).([0-9]{2})`) )
Functions ¶
func GetBitrate ¶
func GetFFmpegMetadataTag ¶
Gets a map of ffmpeg MP3 metadata tags. Note that the ID3 tags and ffmpeg tags are not equivalent. See this documentation for the mapping: https://wiki.multimedia.cx/index.php/FFmpeg_Metadata#MP3
func GetLengthInSeconds ¶
This function does not read the length from the metadata of the file, as metadata and actual length can be inconsistent. Instead this implementation decodes the file and returns the actual length of the audio stream. This is slower but more accurate then reading the length from the metadata.
func SetFFmpegMetadataTag ¶
func SetFFmpegMetadataTag(mp3Filepath string, metadata map[string]string, chapters []Chapter) (err error)
Sets FFmpeg MP3 metadata tag. Note that the ID3 tags and ffmpeg tags are not equivalent. See this documentation for the mapping: https://wiki.multimedia.cx/index.php/FFmpeg_Metadata#MP3
This function creates a new temp file and replaces the initial file.
Types ¶
type Chapter ¶
type Chapter struct { TimeBase string `json:"time_base,omitempty"` Start int `json:"start,omitempty"` End int `json:"end,omitempty"` Tags Tags `json:"tags,omitempty"` // contains filtered or unexported fields }
func GetChapterMetadata ¶
func (*Chapter) GetEndTimeInSeconds ¶
func (*Chapter) GetStartTimeInSeconds ¶
func (*Chapter) SetEndTime ¶
func (*Chapter) SetStartTime ¶
type MP3Builder ¶
type MP3Builder struct {
// contains filtered or unexported fields
}
func (*MP3Builder) Append ¶
func (b *MP3Builder) Append(mp3Filepath string, startInSeconds float64, endInSeconds float64) (err error)
Adds a MP3 file to the builder. If endInSeconds is set to "-1" the stream will be read until the end of the file.
func (*MP3Builder) Build ¶
func (b *MP3Builder) Build(filePath string) (err error)
Creates the MP3 file a the chosen path