In the world of video content creation, adding overlays such as picture-in-picture (PiP) can significantly enhance viewer engagement. With FFMPEGAPI.net, a hosted REST API for FFmpeg-powered video processing, developers can easily implement this feature without the hassle of managing infrastructure. This article will guide you through the steps to use the Picture-in-Picture API to overlay videos seamlessly.
What is Picture-in-Picture?
Picture-in-Picture (PiP) allows you to display a secondary video over your main video, which is particularly useful for tutorials, reactions, or commentary videos. It adds a dynamic element to your content, helping to retain the viewer's attention.
Using FFMPEGAPI.net for PiP Video Composition
FFMPEGAPI.net provides a straightforward API endpoint for creating picture-in-picture compositions. The endpoint allows you to overlay one video on another with configurable parameters for position, scale, and audio source.
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"}'
Available Parameters
When making a request to the Picture-in-Picture endpoint, you can customize the following parameters:
- main_video_url (required): The URL of the main/background video.
- pip_video_url (required): The URL of the overlay/PiP video.
- position (optional): The position of the overlay. Common values include top-left, top-right, bottom-left, bottom-right, and center. Default is bottom-right.
- scale (optional): FFmpeg scale expression for the overlay. Default is iw/4:ih/4.
- audio_option (optional): Choose the audio source: video1, video2, or mute. Default is video1.
- async (optional): If set to true, will return a job_id immediately and process in the background.
Example Request
Here’s an example of how to make a request to the Picture-in-Picture API. It demonstrates how to overlay a video on a main video and position it at the top-right corner.
import requests
url = 'https://ffmpegapi.net/api/picture_in_picture'
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)
print(response.json())
FFMPEGAPI.net simplifies the process of video composition with its reliable Picture-in-Picture endpoint, allowing developers to enhance their video content effortlessly. By providing a hosted solution that requires no server setup and includes API-key authentication, FFMPEGAPI.net is the ideal choice for developers looking to streamline their video processing workflows. Get started with FFMPEGAPI.net today and bring your video projects to life!