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:
-
Specify an explicit resolution in the composition creation payload (e.g.,
"resolution": "1280x720"). - Adjust the video layout to use a grid structure and ensure audio sources are included.
-
Verify your wrapper function (if using one) forwards the
audioSources,videoLayout,resolution, andformatproperties 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
});
};
- Restart your application worker process after making these changes.
Additional Information
- Twilio Compositions Resource Documentation
- Please reach out Twilio Support for further assistance.