Documentation
¶
Overview ¶
Package mediaprobe provides functions for parsing media files for information, such as dimensions, codecs, duration, etc. It uses bindings to ffmpeg and libmagic.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Name string
MediaType string
MediaSubtype string
Size int64
StartTime time.Duration
Duration time.Duration
BitRate int64
Width int
Height int
Streams []Stream
// contains filtered or unexported fields
}
Info contains parsed information
func New ¶
New initialized Info and calculate file size.
Accepted filename as local path or absolute url.
func Parse ¶
Parse file media data It determines the file type by magic bytes, and parses the media data of the video or image.
Accepted filename as local path or absolute url.
Example ¶
package main
import (
"log"
"github.com/Arimeka/mediaprobe"
)
func main() {
info, err := mediaprobe.Parse("./fixtures/video.mp4")
if err != nil {
log.Fatalf("Error: %s\n", err)
}
log.Printf("Result: %+v\n", info)
}
func (*Info) CalculateMime ¶
CalculateMime calculates mime type by magic numbers Function uses libmagic bindings using github.com/rakyll/magicmime package.
func (*Info) FFProbe ¶
FFProbe parses video or audio using ffmpeg bindings It uses github.com/3d0c/gmf package
Example ¶
package main
import (
"log"
"github.com/Arimeka/mediaprobe"
)
func main() {
info, err := mediaprobe.New("./fixtures/video.mp4")
if err != nil {
log.Fatalf("Error: %s\n", err)
}
// Skipping calculate mime-type by magic numbers and immediately parse video
if err = info.FFProbe(); err != nil {
log.Fatalf("Error: %s\n", err)
}
log.Printf("Result: %+v\n", info)
}
func (*Info) ParseImage ¶
ParseImage used for retrieve image data
Example ¶
package main
import (
"log"
"github.com/Arimeka/mediaprobe"
)
func main() {
info, err := mediaprobe.New("./fixtures/image.jpeg")
if err != nil {
log.Fatalf("Error: %s\n", err)
}
// Skipping calculate mime-type by magic numbers and immediately parse image
if err = info.ParseImage(); err != nil {
log.Fatalf("Error: %s\n", err)
}
log.Printf("Result: %+v\n", info)
}
type Stream ¶
type Stream struct {
ID int
Index int
MediaType string
Codec string
CodecTag string
CodecLongName string
IsExperimental bool
Profile string
ColorRangeName string
SampleFmtName string
Bitrate int
Width int
Height int
AspectRation float64
FrameRate float64
AvgFrameRate float64
BFrames int
BitsPerSample int
PixFmt int
PixFmtName string
}
Stream contains audio/video stream information