The clone() method of MediaStreamcreates a duplicate stream with a new id and clonedMediaStreamTrack objects. Learn how that differs from new MediaStream(stream) (shared tracks), verify independent track objects, and when to clone for WebRTC or recording—with five examples and try-it labs.
01
Kind
Instance method
02
Returns
MediaStream
03
Params
none
04
Tracks
cloned copies
05
New id
unique GUID
06
Status
Baseline widely
Fundamentals
Introduction
Sometimes you need a copy of a media stream—for example, to send the same camera feed to two peer connections without sharing one stream object. Call stream.clone() on any MediaStream from getUserMedia(), captureStream(), or your own composed stream.
MDN: the returned stream has a new unique id and contains clones of every track in the original. That is different from new MediaStream(original), which reuses the same track references.
💡
Beginner tip
clone() is like photocopying the whole playlist and each song file—not just pointing two playlists at the same files.
Concept
Understanding MediaStream.clone()
An instance method that duplicates the stream and its tracks without modifying the original.
Parameters — none.
Return value — a new MediaStream instance.
New id — the clone gets its own unique id string.
Cloned tracks — each track is a clone, not the same object reference.
Original unchanged — the source stream stays as it was.
Baseline Widely available on MDN (since September 2017).
Foundation
📝 Syntax
JavaScript
clone()
Parameters
None.
Return value
A new MediaStream with a new unique id and cloned copies of every MediaStreamTrack from the original stream.
MediaStream.clone() is marked Baseline Widely available on MDN (since September 2017). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
MediaStream.clone()
Duplicate a stream with a new id and cloned MediaStreamTrack objects.
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerNo MediaStream.clone
Not supported
MediaStream.clone()Excellent
Bottom line: Call stream.clone() when you need independent track copies and a new stream id.
Wrap Up
Conclusion
MediaStream.clone() returns a duplicate stream with a new id and cloned copies of every track. Use it when you need independence from the original; use new MediaStream(stream) when you want to share track references instead.
Assume clone() shares track references like the constructor
Forget cloned tracks still consume media resources
Confuse clone() with shallow object copy in JavaScript
Expect the same id on original and clone
Clone ended streams expecting new live media without a source
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about clone()
Duplicate streams with independent tracks.
5
Core concepts
⚙️01
clone()
new stream
API
🔗02
New id
unique GUID
Identity
📦03
Tracks
cloned
Copies
📄04
vs ctor
shared refs
Compare
🎯05
Baseline
since Sep 2017
Status
❓ Frequently Asked Questions
clone() creates a duplicate MediaStream. The new stream has a new unique id and contains clones of every MediaStreamTrack from the original—not the same track objects.
No. MDN marks MediaStream.clone() as Baseline Widely available (since September 2017). It is not Deprecated, Experimental, or Non-standard.
No. MDN documents clone() with no parameters. You call it on an existing MediaStream: stream.clone().
new MediaStream(other) shares the same track references. clone() returns a new stream whose tracks are independent clones—stopping a track on one stream does not necessarily end the cloned track on the other.
Yes. MDN says the new MediaStream has a new unique id. See MediaStream.id for the GUID format.
A new MediaStream instance with cloned tracks. The original stream is unchanged.
Did you know?
MDN says clone() gives you a stream with a new unique id and clones of every track—unlike new MediaStream(original), which reuses the exact same MediaStreamTrack objects.