files/en-us/web/api/rtcencodedaudioframe/rtcencodedaudioframe/index.md
{{APIRef("WebRTC")}}{{AvailableInWorkers("window_and_dedicated")}}
The RTCEncodedAudioFrame() constructor creates a new and fully independent {{domxref("RTCEncodedAudioFrame")}} object.
The new object is a deep clone of the original object data and metadata, with any metadata specified in the options parameter overwriting the copied values.
new RTCEncodedAudioFrame(originalFrame);
new RTCEncodedAudioFrame(originalFrame, options);
originalFrame
options {{optional_inline}}
metadata {{optional_inline}}
This snippet shows how you might copy a frame and modify its metadata. In this case we just update the capture time.
// Frame is an incoming RTCEncodedAudioFrame
frame.getMetadata();
const newFrame = new RTCEncodedAudioFrame(frame, {
metadata: {
captureTime: frame.metadata.captureTime + 3,
},
});
This kind of modification might be useful if you need to create multiple outgoing frames from a single incoming frame; for example, in order to relay media to another peer on the network. Generally you will not need to modify the metadata for a frame.
{{Specifications}}
{{Compat}}