I implement custom video encoders for pion webrtc like this:
func CreateCustomOpen264Encoder() codec.ReadCloser {
// Your image data (replace this with your image loading logic)
customVideoReader := NewCustomVideoReader2()
open264Params, _ := openh264.NewParams()
mediaProp := prop.Media{
//DeviceID: "",
Video: prop.Video{
Width: 350,
Height: 350,
FrameRate: 25,
FrameFormat: frame.FormatRGBA,
DiscardFramesOlderThan: 0,
},
//Audio: prop.Audio{},
}
open264Encoder, err := openh264Params.BuildVideoEncoder(&customVideoReader, mediaProp)
if err != nil {
println("Error BuildVideoEncoder")
}
return open264Encoder
}
It works for vp8, vp9 and x264, but open264 throws the following error:
/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/usr/bin/ld: /tmp/go-link-1015362183/000012.o: in function `enc_new':
/home/alex/go/pkg/mod/github.com/pion/mediadevices@v0.6.1/pkg/codec/x264/bridge.h:24: multiple definition of `enc_new'; /tmp/go-link-1015362183/000008.o:/home/alex/go/pkg/mod/github.com/pion/mediadevices@v0.6.1/pkg/codec/openh264/bridge.cpp:7: first defined here
/usr/bin/ld: /tmp/go-link-1015362183/000012.o: in function `enc_encode':
/home/alex/go/pkg/mod/github.com/pion/mediadevices@v0.6.1/pkg/codec/x264/bridge.h:81: multiple definition of `enc_encode'; /tmp/go-link-1015362183/000008.o:/home/alex/go/pkg/mod/github.com/pion/mediadevices@v0.6.1/pkg/codec/openh264/bridge.cpp:74: first defined here
collect2: error: ld returned 1 exit status
I implement custom video encoders for pion webrtc like this:
It works for vp8, vp9 and x264, but open264 throws the following error: