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.
pip

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

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: