SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Video Recording Missing Audio in Final .mp4 File

Issue

Video recordings from Twilio Video calls might have missing audio in the final .mp4 composition. The video is present, but the audio track is not included. 

 

Product

Programmable Video

 

Environment

Twilio Console

 

Cause

Twilio records audio and video tracks separately. If the composition layout is restricted to a single row and column (e.g., using the grid layout preset without specifying resolution), the Composition API may fail to multiplex and synchronize the audio container into the final .mp4 file. This results in a video-only composition.

 

Resolution

To ensure audio is included in the final composition:

  1. Specify an explicit resolution in the composition creation payload (e.g., "resolution": "1280x720").
  2. Adjust the video layout to use a grid structure and ensure audio sources are included.
  3. Verify your wrapper function (if using one) forwards the audioSourcesvideoLayoutresolution, and format properties to the Twilio SDK.

Example code:

let composition = null;
try {
  composition = await createVideoComposition({
    roomSid: session.callSid,
    audioSources: audioSourcesFromTracks,
    videoLayout: {
      grid: {
        video_sources: resolvedVideoSources,
      }
    },
    format: "mp4",
    resolution: "1280x720"
  });
} catch (error) {
  // handle error
}

 

Wrapper function:

const createVideoComposition = async ({ roomSid, audioSources, videoLayout, format = "mp4", resolution = "1280x720" }) => {
  return await twilioClient.video.v1.compositions.create({
    roomSid: roomSid,
    audioSources: audioSources,
    videoLayout: videoLayout,
    statusCallback: process.env.TWILIO_WEBHOOK_URL,
    resolution: resolution,
    format: format
  });
};
  1. Restart your application worker process after making these changes.

 

Additional Information 

Have more questions? Submit a request
Powered by Zendesk