@@ -67,7 +67,11 @@ import (
67
67
)
68
68
69
69
func main () {
70
- manager := media NewManager ()
70
+ manager := media.NewManager ()
71
+
72
+ // Open a media file for reading. The format of the file is guessed.
73
+ // Alteratively, you can pass a format as the second argument. Further optional
74
+ // arguments can be used to set the format options.
71
75
file , err := manager.Open (os.Args [1 ], nil )
72
76
if err != nil {
73
77
log.Fatal (err)
@@ -77,7 +81,7 @@ func main() {
77
81
// Choose which streams to demultiplex - pass the stream parameters
78
82
// to the decoder. If you don't want to resample or reformat the streams,
79
83
// then you can pass nil as the function and all streams will be demultiplexed.
80
- decoder , err := file.Decoder (func (stream media.Stream ) (Parameters, error ) {
84
+ decoder , err := file.Decoder (func (stream media.Stream ) (media. Parameters , error ) {
81
85
return stream.Parameters (), nil
82
86
}
83
87
if err != nil {
@@ -86,9 +90,11 @@ func main() {
86
90
87
91
// Demuliplex the stream and receive the packets. If you don't want to
88
92
// process the packets yourself, then you can pass nil as the function
89
- if err := decoder.Demux (context.Background (), func (Packet) error {
90
- // TODO: Each packet is specific to a stream. It can be processed here
91
- // to receive audio or video frames, etc.
93
+ if err := decoder.Demux (context.Background (), func (_ media.Packet ) error {
94
+ // Each packet is specific to a stream. It can be processed here
95
+ // to receive audio or video frames, then resize or resample them,
96
+ // for example. Alternatively, you can pass the packet to an encoder
97
+ // to remultiplex the streams without processing them.
92
98
return nil
93
99
}); err != nil {
94
100
log.Fatal (err)
0 commit comments