Skip to content

Commit af58360

Browse files
committed
Updated the documentation
1 parent 6c4dfba commit af58360

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ import (
6767
)
6868

6969
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.
7175
file, err := manager.Open(os.Args[1], nil)
7276
if err != nil {
7377
log.Fatal(err)
@@ -77,7 +81,7 @@ func main() {
7781
// Choose which streams to demultiplex - pass the stream parameters
7882
// to the decoder. If you don't want to resample or reformat the streams,
7983
// 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) {
8185
return stream.Parameters(), nil
8286
}
8387
if err != nil {
@@ -86,9 +90,11 @@ func main() {
8690

8791
// Demuliplex the stream and receive the packets. If you don't want to
8892
// 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.
9298
return nil
9399
}); err != nil {
94100
log.Fatal(err)

0 commit comments

Comments
 (0)