One overlay puts a second video in the corner of the first: scale=-2:480 and pad give it a 6 px white border over 1920x1080. ReelSDK renders the 10-second result for under three quarters of a cent, at $0.02 per compute minute.

Picture-in-picture video with ffmpeg

Picture-in-picture is two videos and one overlay, and ReelSDK's API rendered ours in about 19 seconds. Scale the inset to 480 px tall, pad it for a border since overlay has none, and set shortest=1 so a longer inset can't freeze the main picture at the end.

GuidesUpdated

pip
ffmpeg -i main.mp4 -i inset.mp4 -filter_complex \
  "[1:v]scale=-2:480,pad=iw+12:ih+12:6:6:white[pip];\
   [0:v][pip]overlay=W-w-40:H-h-40:shortest=1[v]" \
  -map "[v]" -map 0:a -c:v libx264 -crf 20 -c:a copy pip.mp4

The inset is scaled to 480 px tall, padded 6 px for a white border and placed 40 px from the corner. The main video's audio is kept.

Variations

The other commands you will need

  1. Bring the inset in at 2 s

    setpts delays the inset's frames by 2 s and enable keeps the overlay off until then.

    late start
    ffmpeg -i main.mp4 -i inset.mp4 -filter_complex \
      "[1:v]scale=-2:480,pad=iw+12:ih+12:6:6:white,setpts=PTS-STARTPTS+2/TB[pip];\
       [0:v][pip]overlay=W-w-40:H-h-40:enable='gte(t,2)':shortest=1[v]" \
      -map "[v]" -map 0:a -c:v libx264 -crf 20 -c:a copy pip-late.mp4

The flags

The options in these commands

The options in these commands
FlagWhat it doesUsed here
scale=-2:480480 px tall, width from the aspect ratio rounded to an even numberBoth
pad=iw+12:ih+12:6:6:whiteAdds 6 px of white on every side: the borderBoth
overlay=W-w-40:H-h-40Bottom-right corner, 40 px inBoth
shortest=1Ends the output when the shorter input ends; the default is 0Both
setpts=PTS-STARTPTS+2/TBShifts the inset's timestamps 2 s laterLate start
enable='gte(t,2)'Turns the overlay on from 2 sLate start
-map 0:aKeeps the main video's audio; the inset's is droppedBoth

Sources: ffmpeg filters: overlay, ffmpeg filters: pad, checked November 2026.

Why shortest=1

Our inset runs almost a second longer than the main video. Without shortest=1 the output video ran to the end of the inset, while the audio, copied from the main clip, stopped earlier. For that last stretch the main picture froze and only the inset moved, because overlay repeats the last frame of an input that has ended.

With shortest=1 the output stops with the main video, right where the audio ends. If the inset should play to its end instead, trim it or pad the main clip, and decide which audio to keep.

The border is just padding

There is no border option in overlay. pad=iw+12:ih+12:6:6:white grows the inset by 12 px in each direction and centers it, which leaves 6 px of white on every side: 270x480 became 282x492. Any color name or hex value works.

scale=-2:480 keeps the width even, which libx264 needs for the usual yuv420p video. -1 would have kept the exact ratio and could give an odd width.

Starting the inset later

enable='gte(t,2)' alone hides the inset for 2 s, but the inset keeps playing underneath, so it appears 2 s into its own clip. Adding setpts=PTS-STARTPTS+2/TB moves its frames 2 s later, so it starts from its first frame. We checked a frame on each side: no border pixels at 1.5 s, the whole border at 2.5 s.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with both video URLs in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 19 seconds and cost under three quarters of a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "main.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4",
      "inset.mp4": "https://api.reelsdk.com/f/lib/demo/clip.mp4"
    },
    "args": [
      "-i", "main.mp4", "-i", "inset.mp4", "-filter_complex",
      "[1:v]scale=-2:480,pad=iw+12:ih+12:6:6:white[pip];[0:v][pip]overlay=W-w-40:H-h-40:shortest=1[v]",
      "-map", "[v]", "-map", "0:a", "-c:v", "libx264", "-crf", "20", "-c:a",
      "copy", "pip.mp4"
    ],
    "outputs": ["pip.mp4"]
  }'
The vertical clip as an inset with its white border, over the 1920x1080 video.Input: main clipinset clip

FAQ

Questions, answered

How do I put one video in the corner of another with ffmpeg?

Scale the second input and overlay it: ffmpeg -i main.mp4 -i inset.mp4 -filter_complex "[1:v]scale=-2:480[p];[0:v][p]overlay=W-w-40:H-h-40:shortest=1" -c:a copy out.mp4.

Why does my picture-in-picture video freeze at the end?

One input ended and overlay repeats its last frame. Add shortest=1 to stop with the shorter input.

How do I add a border around the inset?

Pad it before the overlay: pad=iw+12:ih+12:6:6:white adds a 6 px white border.

Can I make picture-in-picture videos with an API?

Yes. POST the same args to https://api.reelsdk.com/v1/ffmpeg with both video URLs in inputs. It runs ffmpeg 8.1 for $0.02 per compute minute, billed per second.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains