| 1 | # go-ffprobe |
| 2 | |
| 3 | Small library for executing an ffprobe process on a given file and getting an easy to use struct |
| 4 | representing the returned ffprobe data. |
| 5 | |
| 6 | ## Installation |
| 7 | |
| 8 | ``` |
| 9 | go get gopkg.in/vansante/go-ffprobe.v2 |
| 10 | ``` |
| 11 | |
| 12 | ## Documentation |
| 13 | |
| 14 | Take a look at the autogenerated documentation: |
| 15 | |
| 16 | https://pkg.go.dev/gopkg.in/vansante/go-ffprobe.v2 |
| 17 | |
| 18 | ## Basic usage |
| 19 | |
| 20 | To get a quick the quick data on a video file: |
| 21 | |
| 22 | ```golang |
| 23 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 24 | defer cancelFn() |
| 25 | |
| 26 | data, err := ffprobe.ProbeURL(ctx, "/path/to/file.mp4") |
| 27 | if err != nil { |
| 28 | log.Panicf("Error getting data: %v", err) |
| 29 | } |
| 30 | ``` |
| 31 | |
| 32 | To get the ffprobe data for a video file that is accessible via HTTP, you can use the same |
| 33 | command, but with an HTTP URL. |
| 34 | |
| 35 | To get the data of a file you have an `io.Reader` for, use: |
| 36 | |
| 37 | ```golang |
| 38 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 39 | defer cancelFn() |
| 40 | |
| 41 | fileReader, err := os.Open("/path/to/file.mp4") |
| 42 | if err != nil { |
| 43 | log.Panicf("Error opening test file: %v", err) |
| 44 | } |
| 45 | |
| 46 | data, err := ffprobe.ProbeReader(ctx, fileReader) |
| 47 | if err != nil { |
| 48 | log.Panicf("Error getting data: %v", err) |
| 49 | } |
| 50 | ``` |