✨ Add ffprobe
This commit is contained in:
parent
afb5953ea0
commit
4435ebf98f
4 changed files with 131 additions and 1 deletions
68
ffmpeg/probe.go
Normal file
68
ffmpeg/probe.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package ffmpeg
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||
)
|
||||
|
||||
type Probe struct {
|
||||
Format Format
|
||||
Streams []Stream
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
Index int
|
||||
CodecName string `json:"codec_name"`
|
||||
CodecLongName string `json:"codec_long_name"`
|
||||
Profile string
|
||||
CodecType string `json:"codec_type"`
|
||||
CodecTag string `json:"codec_tag_string"`
|
||||
Width int
|
||||
Height int
|
||||
StartTime float64 `json:"start_time,string"`
|
||||
Duration float64 `json:",string"`
|
||||
DurationTs int `json:"duration_ts"`
|
||||
Tags Tags
|
||||
}
|
||||
|
||||
type Format struct {
|
||||
Path string `json:"filename"`
|
||||
Streams int `json:"nb_streams"`
|
||||
FormatName string `json:"format_name"`
|
||||
FormatLongName string `json:"format_long_name"`
|
||||
StartTime float64 `json:"start_time,string"`
|
||||
Duration float64 `json:",string"`
|
||||
Size int `json:",string"`
|
||||
BitRate int `json:"bit_rate,string"`
|
||||
Score int `json:"probe_score"`
|
||||
Tags Tags
|
||||
}
|
||||
|
||||
type Tags struct {
|
||||
MajorBrand string `json:"major_brand"`
|
||||
Title string
|
||||
Artist string
|
||||
AlbumArtist string `json:"album_artist"`
|
||||
Album string
|
||||
Date string
|
||||
Encoder string
|
||||
Comment string
|
||||
Description string
|
||||
Composer string
|
||||
Genre string
|
||||
Disc string
|
||||
Track string
|
||||
}
|
||||
|
||||
func ProbeFile(path string) Probe {
|
||||
out, err := ffmpeg.Probe(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ret := Probe{}
|
||||
err = json.Unmarshal([]byte(out), &ret)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue