Replace existing audio

Replace a video’s audio track with a new file (for narration updates, background music, or localization) without re-editing the video.

You can enhance your video content by seamlessly replacing existing audio tracks with new, high-quality audio. Whether you’re updating narration, adding background music, or swapping in a different language, FastPix makes it simple to switch audio while maintaining a smooth, professional experience for viewers.


Replacing audio using FastPix

To replace a video’s audio track, use FastPix’s Create media from URL or Upload media from device API endpoints. By providing the reference for both the original video and the new audio track, FastPix integrates the new audio seamlessly.


Prepare your new audio file

Ensure your new audio file is high-quality and aligns with the length and tone of your video. Save it to an accessible URL.


IMPORTANT

The new audio file must match the video’s duration to prevent audio-sync issues. If the audio duration is shorter or longer, adjust the audio file accordingly.


Configure the JSON request to swap audio

Set up the API request by defining the original video URL and the new audio URL in the JSON structure. Specify type: "video" for the original video and type: "audio" for the new audio track using the swapTrackUrl field.


Replace audio track by creating media from URL

{  
  "inputs": [  
    {  
      "type": "video",  
      "url": "https://static.fastpix.io/fp-sample-video.mp4"  
    },  
    {  
      "type": "audio",  
      "swapTrackUrl":"https://static.fastpix.io/music-2.mp3"
    }  
  ], 
"accessPolicy": "public"
} 

In the above example, the audio track to replace the original audio is mentioned by the parameter swapTrackUrl in the inputs under “type”:”audio”


IMPORTANT

Replace each URL in the request example above with the actual path to your media files.


Replace audio track while creating media by direct upload

{ 
  "corsOrigin": "*", 
  "pushMediaSettings": { 
    "inputs": [ 
      { 
        "type":"audio", 
        "swapTrackUrl":"https://static.fastpix.io/music-2.mp3"
      } 
    ], 
    "accessPolicy": "public"
  } 
} 

How to replace existing audio with new audio from the Dashboard

  1. Open the FastPix Dashboard > Products > Media > Add new media.
  2. Choose Pull Video (URL) or Push Video (direct upload).
  3. For new uploads:
    • For Pull Video, use the example in Request body creating new media from URL.
    • For Push Video, use the example in Request body creating new media by direct upload.
    • In your request body, include "type": "audio" and "swapTrackUrl":"https://example.com/new-audio-file.mp3" so that FastPix rèplaces the original audio with the new track during video ingest.
  4. For existing media, follow this process to replace existing audio:
  • Open Media and copy the Media ID of the video whose audio you want to replace.
  • Click Add new media > Pull Video.
  • Use this request body:
{  
"inputs": [  
  {  
    "type": "video",  
    "url": "fp_mediaId://{Media_ID}"  
  },  
  {  
    "type": "audio",  
    "swapTrackUrl":"https://static.fastpix.io/music-2.mp3"
  }  
], 
"accessPolicy": "public"
} 
  • In the request, replace {Media_ID} with your existing media ID.
  • This creates a new media entry that preserves the original video but uses the new audio track.
  1. After processing is complete, the media with the replaced audio appears in your Media list as a new item.


Webhook events for status

Upon successfully replacing audio from the media, FastPix triggers the video.media.audio_swap.ready webhook event.

Audio swap event ready

Tips for best results

  • Ensure audio-video alignment: Check that the new audio matches the pace and cues of the video content for natural sync.
  • Use high-quality audio: Choose audio files with clear sound and minimal background noise for a professional finish.
  • Preview edited video: After processed, preview the final video to confirm that the audio swap is successful and meets your requirements.

Example scenario

Imagine you have a 60-second promotional video originally narrated in English. To localize it for a Spanish-speaking audience, you record a Spanish narration, upload it as an audio file, and use the FastPix API to replace the English track with the new Spanish version. This enables you to expand your video’s reach without re-editing the visuals.