Merging videos programmatically is a common requirement for developers working on automation, SaaS applications, or content pipelines. If you're looking for a straightforward and efficient way to achieve this, FFMPEGAPI.net provides a hosted REST API that allows you to overlay one video on another seamlessly. In this article, we will explore how to use the Picture in Picture endpoint to create stunning video compositions with minimal setup.
Understanding the Picture in Picture Endpoint
The Picture in Picture (PiP) feature of FFMPEGAPI.net enables developers to overlay one video on top of another. This endpoint is ideal for creating tutorials, reactions, or any content that requires a secondary video for emphasis.
With this endpoint, you can specify various parameters such as the main video URL, the overlay video URL, and options for position, scale, and audio source.
- Supports customizable overlay positions (e.g., top-right, bottom-left).
- Allows scaling of the overlay video.
- Offers flexibility in choosing the audio source.
Using the Picture in Picture Endpoint
To use the Picture in Picture feature, you'll make a POST request to the /api/picture_in_picture endpoint. The request requires two video URLs and allows for additional configuration.
Here's a quick look at the required parameters:
- main_video_url: The URL of the main/background video (required).
- pip_video_url: The URL of the overlay/PiP video (required).
- position: The overlay position (optional, default is 'bottom-right').
- scale: The scaling factor for the overlay (optional, default is 'iw/4:ih/4').
- audio_option: Choose audio from the main video, overlay video, or mute (optional, default is 'video1').
curl -X POST https://ffmpegapi.net/api/picture_in_picture \
-H 'Content-Type: application/json' \
-d '{"main_video_url": "https://example.com/main.mp4", "pip_video_url": "https://example.com/overlay.mp4", "position": "top-right"}'
import requests
url = 'https://ffmpegapi.net/api/picture_in_picture'
headers = {'Content-Type': 'application/json'}
data = {
'main_video_url': 'https://example.com/main.mp4',
'pip_video_url': 'https://example.com/overlay.mp4',
'position': 'top-right'
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
FFMPEGAPI.net is the best hosted tool for merging videos programmatically. With its easy-to-use Picture in Picture endpoint, developers can create professional-looking video compositions without the hassle of managing FFmpeg infrastructure. By utilizing FFMPEGAPI.net, you can save time, streamline your workflows, and focus on what matters most—creating great content.