Login

Replace existing audio with new audio

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 will integrate the new audio seamlessly.


Step 1: 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 should match the video’s duration to prevent audio-sync issues. If the audio duration is shorter or longer, adjust the audio file accordingly.


Step 2: 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.


Request body for replacing track by creating media from URL


{  
  "inputs": [  
    {  
      "type": "video",  
      "url": "https://static.fastpix.io/sample-video.mp4"  
    },  
    {  
      "type": "audio",  
      “swapTrackUrl”:”https://static.fastpix.io/sample-audio.mp4” 
    }  
  ], 
"accessPolicy": "public", 
 "maxResolution": "1080p" 
} 

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.


Request body for replacing track while creating media by direct upload

{ 
  "corsOrigin": "*", 
  "pushMediaSettings": { 
    "inputs": [ 
      { 
        "type":"audio", 
        "swapTrackUrl":"https://static.fastpix.io/sample-audio.mp4" 
      } 
    ], 
    "metadata": { 
      "key1": "value1" 
    }, 
    "accessPolicy": "public", 
    "maxResolution": "1080p" 
  } 
} 

Example Response Body


{ 
  "success": true, 
  "data": { 
    "id": "902cdd45-718f-4c43-a576-daf0c674d55e", 
    "trial": false, 
    "status": "created", 
    "createdAt": "2024-12-05T04:13:12.020372Z", 
    "updatedAt": "2024-12-05T04:13:12.020390Z", 
    "playbackIds": [ 
      { 
        "id": "3723b85d-dbef-4455-ae46-2f30a0617e7f", 
        "accessPolicy": "public" 
      } 
    ], 
    "metadata": { 
      "key1": "value1" 
    }, 
    "maxResolution": "1080p" 
  } 
} 

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: Once 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.