From 1c3f4de149371255de31ac3272ea8493e1b811ee Mon Sep 17 00:00:00 2001 From: Jonathan Viney Date: Fri, 26 Apr 2019 12:51:59 +1200 Subject: [PATCH] Improve README.md example. --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2415e2c..234f611 100644 --- a/README.md +++ b/README.md @@ -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 }