mirror of
https://github.com/giorgisio/goav.git
synced 2024-04-21 12:31:56 +00:00
Improve README.md example.
This commit is contained in:
@@ -13,20 +13,25 @@ import "github.com/giorgisio/goav/avformat"
|
||||
|
||||
func main() {
|
||||
|
||||
filename := "/home/giorgis/media/sample.mp4"
|
||||
filename := "sample.mp4"
|
||||
|
||||
// Register all formats and codecs
|
||||
avformat.AvRegisterAll()
|
||||
|
||||
ctx := avformat.AvformatAllocContext()
|
||||
|
||||
// Open video file
|
||||
if avformat.AvformatOpenInput(&ctxtFormat, filename, nil, nil) != 0 {
|
||||
if avformat.AvformatOpenInput(&ctx, filename, nil, nil) != 0 {
|
||||
log.Println("Error: Couldn't open file.")
|
||||
return
|
||||
}
|
||||
|
||||
// Retrieve stream information
|
||||
if ctxtFormat.AvformatFindStreamInfo(nil) < 0 {
|
||||
if ctx.AvformatFindStreamInfo(nil) < 0 {
|
||||
log.Println("Error: Couldn't find stream information.")
|
||||
|
||||
// Close input file and free context
|
||||
ctx.AvformatCloseInput()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user