Wednesday, February 13, 2013

Picture in picture

Following the previous post about logo this post describes in short how to make picture-in-picture (PIP) with ffmpeg and set up nginx-rtmp to work with that.

PIP can be done with the same overlay ffmpeg filter as before. This is nginx.conf example merging two incoming streams and producing picture-in-picture result.

application myapp {
live on;

application big {
live on;
exec ffmpeg -i rtmp://localhost/big/$name -i rtmp://localhost/small/$name
-filter_complex "[0][1]overlay=10:10" -f flv rtmp://localhost/myapp/$name;

application small {
live on;

The incoming streams are published in big and small application. The result is published to myapp.

Publish Sintel to big.

ffmpeg -re -i /var/video/sintel.mp4 -c:v flv -s 800x600 -c:a libfaac -ar 22050 -ac 1
-f flv rtmp://localhost/big/mystream

Then publish Elephants dream to small.

ffmpeg -re -i /var/video/ed.avi -c:v flv -s 400x200 -c:a libfaac -ar 22050 -ac 1
-f flv rtmp://localhost/small/mystream

Here's the result.

Note the result will not be available if one of incoming streams in unavailable.

No comments:

Post a Comment