diff --git a/examples/rtp/README.md b/examples/rtp/README.md index ecdf3ac..682c1ce 100644 --- a/examples/rtp/README.md +++ b/examples/rtp/README.md @@ -1,5 +1,14 @@ ## Instructions +### Install required codecs + +In this example, we'll be using x264 and opus as our video and audio codecs. Therefore, we need to make sure that these codecs are installed within our system. + +Installation steps: + +* [x264](https://github.com/pion/mediadevices#x264) +* [opus](https://github.com/pion/mediadevices#opus) + ### Download rtpexample ``` @@ -10,13 +19,13 @@ go get github.com/pion/mediadevices/examples/rtp Install GStreamer and run: ``` -gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,encode-name=VP8 \ - ! rtpvp8depay ! vp8dec ! videoconvert ! autovideosink +gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,encode-name=H264 \ + ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink ``` Or run VLC media plyer: ``` -vlc ./vp8.sdp +vlc ./h264.sdp ``` ### Run rtp diff --git a/examples/rtp/vp8.sdp b/examples/rtp/h264.sdp similarity index 84% rename from examples/rtp/vp8.sdp rename to examples/rtp/h264.sdp index 88d4baa..a02b6ad 100644 --- a/examples/rtp/vp8.sdp +++ b/examples/rtp/h264.sdp @@ -6,4 +6,4 @@ c=IN IP4 0.0.0.0 t=0 0 a=recvonly m=video 5000 RTP/AVP 100 -a=rtpmap:100 VP8/90000 +a=rtpmap:100 H264/90000 diff --git a/examples/rtp/main.go b/examples/rtp/main.go index 1295132..0f83885 100644 --- a/examples/rtp/main.go +++ b/examples/rtp/main.go @@ -6,7 +6,7 @@ import ( "os" "github.com/pion/mediadevices" - "github.com/pion/mediadevices/pkg/codec/vpx" // This is required to use VP8/VP9 video encoder + "github.com/pion/mediadevices/pkg/codec/x264" // This is required to use H264 video encoder _ "github.com/pion/mediadevices/pkg/driver/camera" // This is required to register camera adapter "github.com/pion/mediadevices/pkg/frame" "github.com/pion/mediadevices/pkg/prop" @@ -29,12 +29,13 @@ func main() { } dest := os.Args[1] - vp8Params, err := vpx.NewVP8Params() + x264Params, err := x264.NewParams() must(err) - vp8Params.BitRate = 100000 // 100kbps + x264Params.Preset = x264.PresetMedium + x264Params.BitRate = 1_000_000 // 1mbps codecSelector := mediadevices.NewCodecSelector( - mediadevices.WithVideoEncoders(&vp8Params), + mediadevices.WithVideoEncoders(&x264Params), ) mediaStream, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{ @@ -50,7 +51,7 @@ func main() { videoTrack := mediaStream.GetVideoTracks()[0] defer videoTrack.Close() - rtpReader, err := videoTrack.NewRTPReader(vp8Params.RTPCodec().Name, mtu) + rtpReader, err := videoTrack.NewRTPReader(x264Params.RTPCodec().Name, mtu) must(err) addr, err := net.ResolveUDPAddr("udp", dest)