In the previous post, we saw how to setup nginx web server with RTMP plugin. We will now install ffmpeg and use it to publish our own streams to the nginx RTMP url which can then be accessed via HTTP by any other client. We will compile libx264 and then ffmpeg. Compiling in Raspberry Pi itself will take a long time due to hardware limitations. As an alternative, ffmpeg can be compiled by emulating Pi in your desktop computer or by cross-compiling.

If you decide to compile ffmpeg in Pi itself, the following steps might help you.

Compile and install libx264 first.

If you get a message complaining that the yasm installed is old, you can update it as below:

Now compile and install ffmpeg.

Now you should be able to repackage RTMP streams to HTTP streams using ffmpeg. Lets take an example using an RTMP url that looks as below:

This stream can be repackaged using ffmpeg as shown below:

As you can see, the codecs are copied, and not encoded again. The repackaged stream will be published to the nginx RTMP url, and can be accessed via below url using any client, for example VLC Player.