Login

Overlay audio at specific timeline in your video

Overlaying audio at chosen points in your video allows you to add layers of sound—such as music, sound effects, or narration—at the exact times where they are most impactful. With this FastPix feature, you can fine-tune the placement and transition of audio, creating an engaging viewing experience by enhancing specific moments with additional audio elements.


Steps to overlay audio at specific timestamps

Using FastPix’s Create media from URL endpoint, you can overlay an audio track onto your video with customized start and end times, as well as smooth fade-in and fade-out effects. Here’s how to set up the overlay.


Step 1: Prepare your audio file for overlay

Before adding an overlay, ensure the audio file matches the required quality and length for the segment you’re enhancing. Save it to an accessible URL to use in the request.


Step 2: Configure the JSON request to overlay audio

To add an audio overlay to your video, use the FastPix API with the following JSON structure:

  1. Specify type: video and provide the video’s URL.
  2. Specify type: audio with imposeUrl for overlay audio, and add timing and transition details.

The parameters you’ll need are:

  • url: URL of the audio file to be overlaid.
  • startTime: Timestamp (in seconds) where the overlay audio should begin.
  • endTime: Timestamp where the overlay audio should end.
  • fadeInLevel: Duration (in seconds) for the audio to reach full volume.
  • fadeOutLevel: Duration (in seconds) for the audio to fade out to zero volume.

Example JSON request

Below is an example of a JSON request for overlaying audio onto a video with specific start and end times, and customized fade-in and fade-out settings:

{ 
  "inputs": [ 
    { 
      "type": "video", 
      "url": " https://static.fastpix.io/sample-video.mp4" 
    }, 
    { 
      "type": "audio", 
      "imposeUrl": [ 
        { 
          "url": " https://static.fastpix.io/sample-audio.mp3", 
          "startTime": 0, 
          "endTime": 14, 
          "fadeInLevel": 2, 
          "fadeOutLevel": 3 
        } 
      ] 
    } 
  ] 
} 

In this example, the overlay audio starts immediately (at 0 seconds) and ends at the 14-second mark. The fade-in effect takes 2 seconds, while the fade-out occurs over 3 seconds, creating a smooth audio transition.


Step 3: Submit your API request

Once your JSON request is prepared, submit it through the FastPix API endpoint. The API will process the request, and the new audio overlay will be added according to the specified parameters.


Example use case

Suppose you have a tutorial video with a 20-second segment that explains a key concept. You decide to overlay a voice narration from 2 to 18 seconds, with a 1-second fade-in and a 1.5-second fade-out, to guide viewers through the information. By using this API feature, you seamlessly integrate the narration, enhancing viewer comprehension and engagement.