ffmpeg picture-in-picture

So just a quick one. I needed to create a video that has Picture in Picture. So we could have a video of the presentation, inside a recording of the slides used. Usually I would use Adobe premier pro for this, but as I have Ubuntu installed on my laptop, I though of ffmpeg. It is much less resource intensive then the Adobe product, but of course its all command line, so you don’t get a pretty GUI to play with. Once you master ffmpeg, its an amazing and fast tool that can do pretty much manipulate any audio/visual that you need in any way you want

ffmpeg -i pip1.mp4 -i pip2.mp4 \
-filter_complex "[1]scale=iw/4:ih/4 [pip]; [0][pip] \
overlay=main_w-overlay_w-250:main_h-overlay_h-100" \
-b:v 50M -ar 44100 <br />-ab 192k -vcodec mpeg4 \
-acodec libmp3lame PIPoutput.mp4

Here is a screen shot of what it accomplishes. It encodes it using mpeg4 for video, and mp3 for audio and keeps the quality of the original video’s. (this is just an example using 2 random videos I found)

pip with 2 videos

If you adjust the bits “-overlay_w-250” and “-overlay_h-100” this is adjust the location of the pip relative to the bottom corner of the screen (I’m pretty sure)