mirror of
https://github.com/qrtc/ffmpeg-dev-go.git
synced 2025-10-05 15:47:33 +08:00
2023-10-31 09:16:44 CST W44D2
This commit is contained in:
40
examples/show-metadata/main.go
Normal file
40
examples/show-metadata/main.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var fmtCtx *ffmpeg.AVFormatContext
|
||||
var tag *ffmpeg.AVDictionaryEntry
|
||||
var ret int32
|
||||
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Fprintf(os.Stderr, "usage: %s <input_file>\n"+
|
||||
"example program to demonstrate the use of the libavformat metadata API.\n"+
|
||||
"\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if ret = ffmpeg.AvFormatOpenInput(&fmtCtx, os.Args[1], nil, nil); ret != 0 {
|
||||
os.Exit(int(ret))
|
||||
}
|
||||
|
||||
if ret = ffmpeg.AvFormatFindStreamInfo(fmtCtx, nil); ret < 0 {
|
||||
ffmpeg.AvLog(nil, ffmpeg.AV_LOG_ERROR, "Cannot find stream information\n")
|
||||
os.Exit(int(ret))
|
||||
}
|
||||
|
||||
for {
|
||||
if tag = ffmpeg.AvDictGet(fmtCtx.GetMetadata(), "", tag, ffmpeg.AV_DICT_IGNORE_SUFFIX); tag == nil {
|
||||
break
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "%s=%s\n", tag.GetKey(), tag.GetValue())
|
||||
}
|
||||
|
||||
ffmpeg.AvFormatCloseInput(&fmtCtx)
|
||||
os.Exit(0)
|
||||
}
|
Reference in New Issue
Block a user