OpenCV build script

Maybe you can try an opencv gstreamer VideoWriter to shmsink and use rstp server to use this source for streaming such as here.

If you want to use ffmpeg, you may just enable ffmpeg support with -D WITH_FFMPEG=ON when configuring your opencv build with cmake. You need to have a ffmpeg version installed. Check the cmake configure log for found libs.

For more details about using your own ffmpeg version you may also have a look to this post.