Bug 85851

Summary: MediaStream API: support MediaStreamRecorder implementation
Product: WebKit Reporter: William Lin <wei.a.lin>
Component: WebRTCAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: 709922234, abarth, adam.szaloczi, adam, ajuma, alonm, alovell, andrey, andriworld, chrisguttandin, dccollie, diego.caravana, dirkk0, dmannion, dustin.kerstein, eric.carlson, extern.dominik.schmelz, florent.thiery, frank, hi, jchrist7, jeremy.noring, jonandonicastelo, jpincheira, kaisers, kimscott, kipo1971, krukid, lepinski, magnuson.carl, marcel, marcosdg3, mark, matthewmcginniss, max, mayowadan17, mcasas, michael, mika.lumbroso, mike, naicuoctavian, pkishan1990, rafaeljsg14, remusnegrota, rigel, rob, salvoravida, Senthil.Ramachandran, shaunbowe, shradha, stuart, tokarjn234, tommyw, tsi, tswieter, waza123, webkit-bug-importer, webkitbugzilla, webkit, winofchina, youennf, yuhan_wu, zach
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 197673, 188822, 189526, 190018, 190291, 190438, 190642, 190778, 194779, 198912, 202233, 213720, 214972, 214973, 215018, 216663, 216664, 216688, 216832, 216856, 234784    
Bug Blocks:    
Attachments:
Description Flags
MediaRecorder recorded video with STP Release 113 (Safari 14.0.1, WebKit 15610.2.3.1)
none
FFMPEG output video - dropping frames/stuttery but playable on Chrome none

Description William Lin 2012-05-07 19:26:19 PDT
To support MediaStreamRecorder implementation in MediaStream API
Comment 1 Tommy Widenflycht 2012-05-08 00:43:01 PDT
Just FYI this feature is quite far in the future since the specification is way behind.
Comment 2 Miguel Casas-Sanchez 2016-11-14 17:25:57 PST
Update: This is available in Chrome and Firefox:

http://caniuse.com/#search=mediarecorder

and the Spec is on its way to become Candidate Recommendation.
Comment 3 Jeremy Noring 2017-05-16 08:17:55 PDT
I'd also like to add this is one feature that's important to have to abandon flash support.  Right now to record media in the browser, really the only way besides javascript encoder/decoder implementations (performance isn't there yet) is to use a media server and stream rtmp (yuck!).
Comment 4 Frank Faubert 2017-06-09 11:54:26 PDT
Please add support for this so we can finally get rid of flash...
Comment 5 waza123 2018-01-15 10:19:41 PST
MediaRecorder
PLEASE CREATE THIS Class faster !
Comment 6 Jeremy Noring 2018-04-03 10:48:48 PDT
I'm at the point where I need this feature so badly that I'm willing to try and do the work myself.  Questions:

1. Would webkit accept a contribution like this, assuming I went through the normal process to make contributions to webkit, and 
2. Is there a webkit developer I could work with to make this happen?

Roundabout story: we've tried to make a MediaRecorder polyfill with webassembly, and it is prohibitively difficult for a number of reasons (tl;dr codec royalties are a thing, javascript garbage collection and video are hard, script processor nodes are finicky and working with a canvas has some idiosyncrasies that are difficult to address).  

Any advice: hugely welcome.
Comment 7 Eric Carlson 2018-06-27 07:45:48 PDT
Apologies for the late reply, I didn't see your questions before now. 

(In reply to Jeremy Noring from comment #6)
> I'm at the point where I need this feature so badly that I'm willing to try
> and do the work myself.  Questions:
> 
> 1. Would webkit accept a contribution like this, assuming I went through the
> normal process to make contributions to webkit, and 

Yes of course!

> 2,. Is there a webkit developer I could work with to make this happen?
> 

If you mean someone to help with questions and patch reviews, I will be happy to help out.
Comment 8 Eric Carlson 2018-06-27 07:48:15 PDT
<rdar://problem/40939511>
Comment 9 youenn fablet 2018-06-27 07:50:27 PDT
> 1. Would webkit accept a contribution like this, assuming I went through the
> normal process to make contributions to webkit, and 

+1 !!

> 2. Is there a webkit developer I could work with to make this happen?

I can also help a bit.

> Roundabout story: we've tried to make a MediaRecorder polyfill with
> webassembly, and it is prohibitively difficult for a number of reasons
> (tl;dr codec royalties are a thing, javascript garbage collection and video
> are hard, script processor nodes are finicky and working with a canvas has
> some idiosyncrasies that are difficult to address).  

+1
Comment 10 Octavian Naicu 2018-07-11 04:27:37 PDT
Having this feature in Safari on iOS would allow us to move away from the limited HTML Media Capture spec (which on Safari/iOS doesn't even work for audio just video) and implement proper video recording directly in iOS devices using our UI, our start/stop/pause controls, our constraints, JavaScript, we could trigger events, etc.

Having this feature in Safari on macOS would allow us to retire the last piece of Flash we're using.

(In reply to Jeremy Noring from comment #6)

> Roundabout story: we've tried to make a MediaRecorder polyfill with
> webassembly, and it is prohibitively difficult for a number of reasons
> (tl;dr codec royalties are a thing, javascript garbage collection and video
> are hard, script processor nodes are finicky and working with a canvas has
> some idiosyncrasies that are difficult to address).  

We've actually considered doing the same thing: taking snapshots from the canvas and encoding them as video using a WebAssembly video encoding library. I'm not sure it's possible though or, if works, if it could be used in production. For example these FFMPEG WebAssembly builds are 12MB in size and 4-5MB gzipped https://github.com/BrianJFeldman/ffmpeg.js.wasm. Another problem is audio would have to be captured separately and thus it will most certainly be out of sync.

As an example, there is a working MediaRecorder polyfill for audio that records uncompressed pcm in .wav https://github.com/ai/audio-recorder-polyfill

We've also tried using WebRTC to establish a p2p connection to a server and record the video server side but the video quality is bad (since WebRTC prioritizes low latency as it should) and the connection process is extremely complex (to account for all possible networks) resulting in failed connections: https://addpipe.com/blog/troubleshooting-webrtc-connection-issues/

Chrome supports mediastream recording since January 2016. It was "The most starred Chrome feature EVER" with 2877 stars https://developers.google.com/web/updates/2016/01/mediarecorder

I am not even that much concerned about codecs as we can easily convert those server side to whatever we need.
Comment 11 Octavian Naicu 2018-07-11 04:37:08 PDT
Just a thought: If this does not make it in Safari/12 and Safari 12/macOS we'll most probably have to wait at least another year until Safari 13.
Comment 12 Andrey Sitnik 2018-07-11 07:14:55 PDT
I wrote a polyfill for MediaRecorder for audio https://github.com/ai/audio-recorder-polyfill

But it will be much better to have native support. Really useful feature.
Comment 13 dirkk0 2018-07-11 10:23:09 PDT
+1 from me.
I am working on PWAs for clients who would love proper audio and especially video support.
Comment 14 Remus Negrota 2018-07-12 00:53:15 PDT
Having this feature will greatly improve usability on iOS. As of now on Safari on iOS if you want to capture just audio you have to rely on HTML Media Capture and this does not even allow you to record audio directly, it records both videa and audio and after that we must extract the audio.

Not the simplest of tasks as it should be and is on all other modern browsers.
Comment 15 Jeremy Noring 2018-07-12 08:41:11 PDT
(In reply to Octavian Naicu from comment #10)
> Having this feature in Safari on iOS would allow us to move away from the
> limited HTML Media Capture spec (which on Safari/iOS doesn't even work for
> audio just video) and implement proper video recording directly in iOS
> devices using our UI, our start/stop/pause controls, our constraints,
> JavaScript, we could trigger events, etc.
> 
> Having this feature in Safari on macOS would allow us to retire the last
> piece of Flash we're using.
> 
> (In reply to Jeremy Noring from comment #6)
> 
> > Roundabout story: we've tried to make a MediaRecorder polyfill with
> > webassembly, and it is prohibitively difficult for a number of reasons
> > (tl;dr codec royalties are a thing, javascript garbage collection and video
> > are hard, script processor nodes are finicky and working with a canvas has
> > some idiosyncrasies that are difficult to address).  
> 
> We've actually considered doing the same thing: taking snapshots from the
> canvas and encoding them as video using a WebAssembly video encoding
> library. I'm not sure it's possible though or, if works, if it could be used
> in production. For example these FFMPEG WebAssembly builds are 12MB in size
> and 4-5MB gzipped https://github.com/BrianJFeldman/ffmpeg.js.wasm. Another
> problem is audio would have to be captured separately and thus it will most
> certainly be out of sync.
> 
> As an example, there is a working MediaRecorder polyfill for audio that
> records uncompressed pcm in .wav
> https://github.com/ai/audio-recorder-polyfill
> 
> We've also tried using WebRTC to establish a p2p connection to a server and
> record the video server side but the video quality is bad (since WebRTC
> prioritizes low latency as it should) and the connection process is
> extremely complex (to account for all possible networks) resulting in failed
> connections:
> https://addpipe.com/blog/troubleshooting-webrtc-connection-issues/
> 
> Chrome supports mediastream recording since January 2016. It was "The most
> starred Chrome feature EVER" with 2877 stars
> https://developers.google.com/web/updates/2016/01/mediarecorder
> 
> I am not even that much concerned about codecs as we can easily convert
> those server side to whatever we need.

So the issue with codecs is: if you want to playback the video you just recorded in the browser--which is a really common use case--then you either need MediaRecorder producing files supported by that particular browser, or you need yet another polyfill (we've been using ogv.js, for example) to decode whatever random codec you recorded in locally.

This is where the codec royalty issue comes into play: if you ship a polyfill that records in H.264, your company owes royalties to MPEG-LA. The easy way around this is to record in something that doesn't require royalties, like VP8, but then that necessitates yet another webassembly project to playback the video you just recorded.
Comment 16 Octavian Naicu 2018-07-13 02:03:58 PDT
On desktop we're using Media Recorder API + Flash on Safari/IE/legacy and that works great. We're most concerned about mobile where on Safari we're stuck with HTML Media Capture while Chrome on Android has full Media Recorder API support.
Comment 17 Michael L. 2018-07-22 03:25:07 PDT
This is also crucial to us, for the exact same reasons as previous contributors, getting rid of Flash and Media Capture for the sake of user experience.

Happy to help if I can, please update us on the current status !
Comment 18 jp pincheira 2018-07-25 15:14:17 PDT
Crucial to us too, we really don't want to use Flash, so sadly, we're encouraging our users to move away from Desktop Safari at the moment, to Chrome/FF/Opera.
Comment 19 Robert Gerald (Rob) Porter 2018-07-30 11:35:50 PDT
This is something where we've been forced to recommend only Android devices (&Chrome) for doing short video recording for our clients. Would love to see this having proper cross-browser support. Feels like such a large gap item to me, especially considering the push to abandon Flash.
Comment 20 Shradha 2018-08-16 00:07:16 PDT
We are using the api to let our users record short videos(<1 min). We've been forced to direct our users to download chrome/ff. We do want it on Safari as well but right now it just seems like too much effort.Waiting for it to be released for safari.
Comment 21 Matt 2018-08-17 09:50:42 PDT
Even Adobe recommends disabling Flash:

"Adobe said that it will now 'encourage content creators to build with new web standards,' such as HTML5, rather than Flash. It's also beginning to deprecate the Flash name by renaming its animation app to Animate CC, away from Flash Professional CC."

https://www.theverge.com/2015/12/1/9827778/stop-using-flash
Comment 22 jp pincheira 2018-08-17 10:02:38 PDT
I feel that "Status:	UNCONFIRMED" is a bit of a disrespect to developers using and caring about Webkit. It is really offensive that this is the status since 2012.
Comment 23 Timothy Swieter 2018-08-27 07:54:03 PDT
I'd love to see this implemented so that Safari and Chrome/FF can have similar functionality.
Comment 24 winofchina 2018-08-27 14:56:54 PDT
6 years passed, the bug still exists...
Comment 25 Thomas Sigdestad 2018-09-09 11:34:38 PDT
Let's get this done Apple!
Apple is slowly turning into a new Microsoft by stalling the development of the web - just like they did with ie6. That did not end well...

I'm sad to say I have many friends and colleagues that have used iOS since 2009, that have now abandoned it for Android due to the limited web support. Under Jobs, Safari/iOS was the best mobile web platform on earth - not anymore :-(
Comment 26 stuart 2018-09-16 09:55:20 PDT
Can someone from the webkit team tell us whether there is a plan to fix/implement this? If it's going to come and we just need to wait, then that's useful information. If it's not going to happen at all, then we know we need to make other plans.
Any info either way would be very useful.

Thankyou

Stuart
Comment 27 youenn fablet 2018-09-16 17:50:16 PDT
As detailed in https://webkit.org/status/#feature-mediastream-recording-api, this feature is under consideration. Corresponding WPT tests have also been imported in WebKit and are run in WebKit CI.

Any help around that feature is welcome.
Contributing media stream recording API tests to https://github.com/web-platform-tests/wpt would be useful. It would require MediaStream recording API knowledge plus general JS/HTML knowledge.
Comment 28 Zach Rattner 2018-10-01 13:19:44 PDT
+1 that this would be great to see ton mobile Safari since Chrome has had it for some time now. Recording streams through WebRTC sacrifices video quality since it's fundamentally a different use case than record + upload. Sort of strange to still be in unconfirmed status after 6 years...
Comment 29 Octavian Naicu 2018-10-02 05:52:19 PDT
We are now working on implementing recording through WebRTC for Safari on iOS and macOS and it is a pain: you need a server to handle signalling and act as the other client, the connection process is complex and might fail especially without another TURN server/service and the quality is just not there because WebRTC is made for low latency live video.

On Chrome/Android we can just use the MediaStream Recording API. Its the same code we use on desktop plus a few extra lines to handle the front/back camera.
Comment 30 Allan 2018-12-05 05:25:14 PST
We are working on doing a mobile version of our application and the challenge is to record videos using camera of IOS devices such as Iphone or iPADs, we are stuck and so far only android /chrome implementation is possible. If anyone has ideas, it will be grateful to share..
Comment 31 Allan 2018-12-05 05:34:49 PST
We are working on doing a web app version of our application on mobile devices,  the challenge is to use safari and access the camera and record videos on IOS devices such as Iphone or iPADs, we are stuck and so far only android /chrome implementation is possible. If anyone has ideas, it will be grateful to share..
Comment 32 Mark Beeby 2018-12-27 08:26:56 PST
Have the Safari team taken note of Edge's latest maneuver? In adopting the Chromium project they're going to be able to take the Microsoft brand forward without holding everyone back, Safari really is going to be the biggest pain in back for developers. This feature is one of too many that are sat in the ignored column by Apple...
Comment 33 David Mannion 2019-01-10 10:55:03 PST
We really need this feature implemented.  We have an application that works great in Chrome and Firefox on non-Apple devices but we had to write a work around for Webkit that requires the user to jump out of the browser to the device's video recording app to capture their video.  Please get this done ASAP!
Comment 34 Octavian Naicu 2019-01-29 02:18:03 PST
Great news! 

Safari Technology Preview 73 implements a basic working version of the MediaStream Recorder API.

I've covered what works and what doesn't here: https://addpipe.com/blog/safari-technology-preview-73-adds-limited-mediastream-recorder-api-support/

Hopefully a fully working implementation will be shipped in Safari 12.x .
Comment 35 Adam Szaloczi 2019-03-14 14:09:18 PDT
I am planning to make an app, where the main functionality would be audio recording in browser, but currently, the mediarecorder API is the bottleneck. There is a workaround with webaudio API, but thats very poorly documented, so very hard to implement.
Comment 36 pkishan1990 2019-03-19 07:46:35 PDT
Please add support, working with media stream server is scary and not supported by our current stack.
Comment 37 Jeff 2019-03-29 11:54:43 PDT
iOS 12.2 still does not support MediaRecorder. Please add!
Comment 38 Octavian Naicu 2019-08-08 01:45:07 PDT
Quick update:  the MediaRecorder feature in Safari is an Experimental Feature in both iOS 12.4 and iOS 13 public beta 4. It is turned off by default. You need to manually enable it from the iOS Settings > Safari > Advanced > Experimental Features for it to work.
Comment 39 Mayowa Daniel 2019-08-09 13:29:24 PDT
finally!!!!(In reply to Octavian Naicu from comment #38)
> Quick update:  the MediaRecorder feature in Safari is an Experimental
> Feature in both iOS 12.4 and iOS 13 public beta 4. It is turned off by
> default. You need to manually enable it from the iOS Settings > Safari >
> Advanced > Experimental Features for it to work.
Comment 40 Nam 2019-08-22 00:38:18 PDT
The recorded video frames are rotated 90 degrees and stretched by the MediaRecorder feature in Safari is an Experimental Feature
Comment 41 Alon Meytal 2019-09-09 01:03:40 PDT
Any idea when is this feature going to be out of the experimental phase??
Comment 42 Octavian Naicu 2019-09-09 02:58:59 PDT
(In reply to Alon Meytal from comment #41)
> Any idea when is this feature going to be out of the experimental phase??

Hopefully in iOS 13 - Apple's event is tomorrow - together with an HTML Media Capture implementation for audio-only recordings. That would bring it in line with Chrome on Android in terms of audio & video recording capabilities.
Comment 43 Octavian Naicu 2019-09-20 02:01:20 PDT
Installed Safari 13 on my Mac and iPhone yesterday. 

Media Stream Recorder API is still experimental :(.

On top of that trying to record just audio with HTML Media Capture crashes Safari on iOS and iPad OS, I've reported the issue here: https://bugs.webkit.org/show_bug.cgi?id=202039
Comment 44 Senthil Ramachandran 2019-11-01 15:27:10 PDT
Hi, with experimental features turned on, recorded videos look stretched and flipped -90 degrees.

Here is the my repo I used to reproduce this.
https://github.com/senpost/mediarecorderX

If you don't have node or you don't want to run this locally, I can try to publish this site into netlify so it is accessible from internet.
Comment 45 rigel 2020-01-27 18:18:48 PST
The experimental implementation still results in stretched/flipped video files. Here is a video of what this looks like in iOS 13.3: https://youtu.be/OVDM-aQhoiM

Repro steps:
1. Turn on MediaRecorder in Safari Experimental Settings (iOS 13)
2. Navigate to https://addpipe.com/media-recorder-api-demo/
3. Record + Save video
4. Open saved video in Chrome (no iOS webm playback)

Also described here: https://bugs.webkit.org/show_bug.cgi?id=198912
Comment 46 salvo 2020-03-25 08:52:22 PDT
Hi there!,

Currently even last Safari 13.1 does not have MediaRecorder activated by default.

Is there a release date for this Api?
Thanks
Comment 47 Diego Caravana 2020-03-28 06:26:09 PDT
Just curious to know why this feature is just half-baked.

Why even start implementing it if there is no interest (from Apple at least) in releasing it?

And it's clear there is no interest cause MediaRecorder is there as an experimental feature since more than one year, and given the fairly good implementations in other browsers, there is clearly no technical reason not to complete and deliver it.

Our clients are demanding more and more that our software works on iOS, too, but we cannot satisfy their needs as currently there is no simple alternative on iOS to do video recording, except using a distorted implementation of WebRTC perhaps, or creating an app, which we don't want to create yet.

In these hard times, enabling communication in every possible way should be the first priority of a company like Apple, a company that has a huge impact on many millions of lives every day.

Thanks for listening.
Comment 48 salvo 2020-03-28 06:59:03 PDT
@Diego. i think the biggest problem is the webm video replay after record.

it is very strange that MediaReacorder api can record in webm format but <video tag cannot reproduce it.

i have impementend a workaorund for this problem: convert the video client side with ffmepg_asm.js with codec: copy. just convert the container from webm to mp4.

So i need only to convice my clients to turn on the Experminetal Features flag.

Please Apple, take us a release date!!!!!
Comment 49 Octavian Naicu 2020-03-28 11:27:06 PDT
(In reply to Diego Caravana from comment #47)

> there is no simple
> alternative on iOS to do video recording, except using a distorted
> implementation of WebRTC perhaps, or creating an app, which we don't want to
> create yet.

We're actually still using a Flash-based client and a Wowza media server to record audio & video from Safari users. I think we'll stop supporting Safari end of 2020 unless Media Stream Recorder API is implemented.
Comment 50 Kim Scott 2020-05-11 11:55:48 PDT
We're currently just not supporting Safari at https://lookit.mit.edu (video-based online developmental research) because of this issue. Would be very excited about MediaStreamRecorder support!
Comment 51 AndyDeveloper 2020-05-12 08:27:28 PDT
@salvo (In reply to salvo from comment #48)

> it is very strange that MediaReacorder api can record in webm format but
> <video tag cannot reproduce it.

MediaRecorder on Safari can record directly in mp4 
 new MediaRecorder(stream, { type: 'video/mp4' })

Cheers
Comment 52 Diego Caravana 2020-05-29 13:38:24 PDT
(In reply to Kim Scott from comment #50)
> We're currently just not supporting Safari at https://lookit.mit.edu
> (video-based online developmental research) because of this issue. Would be
> very excited about MediaStreamRecorder support!

Thank you Kim, I was planning to do something to fill this gap anyway, but your project gave me another strong reason to do it.

So I'm even happier now to share the proof of concept I put together.

Basically it's a MediaRecorder polyfill that merges code from these two projects:

- https://github.com/GoogleChromeLabs/webm-wasm
- https://github.com/kbumsik/opus-media-recorder


The first one provides a way to efficiently create a webm video file through Wasm, while the second is a (good) example of MediaRecorder polyfill (just for audio recording, though).

All the credit goes to these two projects, I just packaged them together.

Both are fairly complex projects, so to make things simpler I worked on this file only:

https://github.com/dcaravana/webm-wasm/blob/ios_test/demo/live_download_mediarecorder.html


I want to reiterate that this is just a prototype, the code is quite rough and far from being usable in production, so feel free to take inspiration from it or even contribute back.

I'm quite proud of this result as it defeats any  reasoning behind holding the MediaRecorder implementation back in Safari (in fact, it took me a bit more that one day of work).
Comment 53 Diego Caravana 2020-06-29 02:57:21 PDT
No feedback in one month.

This bug has been filed in 2012.

After considering what I heard at WWDC keynote about Safari, I'm assuming there is an explicit will not to finish this implementation.

I just wonder why?

An official word from Apple (and I see Apple employees in the CC list here) would at least make it all more polite and put everyone's hopes finally to rest.

Maybe something like this?

https://www.zdnet.com/article/apple-declined-to-implement-16-web-apis-in-safari-due-to-privacy-concerns/


Thanks.
Comment 54 youenn fablet 2020-06-29 03:05:22 PDT
Implementation of MediaRecorder is making some progress with the implementation of progressive results now implemented.
Testing is of course most welcome when these changes will hit STP.
Comment 55 Zach Rattner 2020-07-18 08:14:42 PDT
The latest Safari Technology Preview (release 110) adds support for MediaRecorder.onstart and other APIs crucial for recording: 

https://developer.apple.com/safari/technology-preview/release-notes/

The Apple Developer site is only clear on how to get Safari Technology Preview on macOS. I couldn't find iOS instructions, but I'll try getting the latest iOS 14 beta on my iPhone and see if that does the trick.
Comment 56 Jeremy Noring 2020-07-29 15:31:37 PDT
This is now available in Chrome, Firefox, and Edge.  The only missing browser is safari.  Is there _any_ hope of this making into into safari without being hidden behind a switch?  I don't even want to go into the sort of horrific crap we've had to do to continue supporting safari for recording.
Comment 57 Octavian Naicu 2020-08-25 16:30:51 PDT
Safari 14 is one or two months out, is this going to be in Safari 14 (without the flag)? We need to know to prepare for either case:

1. not supported at launch or behind a flag: we'll not support Safari 14 and need to announce clients
2. supported at launch: we need to make sure our current MediaStream Recorder implementation works as expected
Comment 58 Jeremy Noring 2020-08-26 08:13:57 PDT
Ditto.  I'd like to know if we can stop blocking safari.
Comment 59 Diego Caravana 2020-09-17 05:58:01 PDT
For the recordi, Safari 14, out today for desktop and mobile, doesn't support this API yet.

Expected given the issues that are still open here.
Comment 60 AndyDeveloper 2020-09-17 11:45:31 PDT
I'm observing that in iOS 14 Safari, the video no longer appears stretched (it is still rotated -90 degrees). Any existing workarounds will have to become conditional, based on the iOS version.
Comment 61 AndyDeveloper 2020-09-22 08:56:43 PDT
Also, I am experiencing a new issue with the recorded files since iOS 14 and Safari 14 on MacOS. Most media players can't play the recorded files. It seems the metadata (duration, frame rate...) are not set properly. If I re-encode the file assuming the frame rate, then I get a valid file.
Comment 62 youenn fablet 2020-09-22 09:11:29 PDT
(In reply to AndyDeveloper from comment #61)
> Also, I am experiencing a new issue with the recorded files since iOS 14 and
> Safari 14 on MacOS. Most media players can't play the recorded files. It
> seems the metadata (duration, frame rate...) are not set properly. If I
> re-encode the file assuming the frame rate, then I get a valid file.

Can you file a new bug report and provide some repro steps?
Comment 63 AndyDeveloper 2020-09-22 09:56:36 PDT
Filed this bug: 
MediaRecorder produces invalid video files since iOS/Safari 14
https://bugs.webkit.org/show_bug.cgi?id=216832
Comment 64 Marcos G. 2020-09-22 12:24:12 PDT
Using safari 14, I am able to get video recording working using this example from https://webrtc.github.io/samples/src/content/getusermedia/record/.

In order to get the example working, I ignored the isTypeSupported check, specified video/mp4 vs video/webm, updated the constraints {video: true, audio:true}, and I am able to record video but not audio.

https://codepen.io/marcosdg3/pen/rNeoyzz

I used ffprobe and found the audio stream is missing. Am I missing something, is there any documentation you can share on how this is being used/tested in-house?

Any help would be much appreciated as we would like to support safari.

Video recorded in chrome:
$ ffprobe tested-in-chrome.mp4 
ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tested-in-chrome.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:03.31, start: 0.000000, bitrate: 167 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 126 kb/s, 16 fps, 16 tbr, 16384 tbn, 32 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 24000 Hz, mono, fltp, 32 kb/s (default)
    Metadata:
      handler_name    : SoundHandler


Video recorded in safari:
$ ffprobe tested-in-safari.mp4
ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tested-in-safari.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2020-09-22T18:20:34.000000Z
  Duration: 18:47:50.35, start: 67669.391667, bitrate: 0 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 0 kb/s, 30.39 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2020-09-22T18:20:34.000000Z
      handler_name    : Core Media Video
Comment 65 Marcos G. 2020-09-22 13:32:56 PDT
I had 'Modern WebAudio API' enabled in experimental features which prevented sound from being recorded. After disabling and restarting the browser, audio is recorded. The video is corrupted though.

Also updating my audio constraints to: 
{sampleRate: 24000, noiseSuppression: true, echoCancellation: true} 
prevented audio recording. 

Noting that the video constraints are ignored as well. 

Output from ffprobe for video recording:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fbd52008200] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 640x480, 1 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'safari.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2020-09-22T20:16:42.000000Z
  Duration: 20:44:27.94, start: 2.249333, bitrate: 1 kb/s
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none, 640x480, 1 kb/s, SAR 1:1 DAR 4:3, 30.05 fps, 600 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2020-09-22T20:16:42.000000Z
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 174 kb/s (default)
    Metadata:
      creation_time   : 2020-09-22T20:16:42.000000Z
      handler_name    : Core Media Audio
Comment 66 youenn fablet 2020-09-23 07:27:08 PDT
(In reply to Marcos G. from comment #65)

This bug entry is to keep track of all MediaRecorder bugs.
Would you be able to file a specific bug entry for your issue and cc me?
Repro steps are always helpful.
Comment 67 Marcos G. 2020-09-24 10:55:50 PDT
Yes of course, I'll review and create tickets for issues that aren't already listed.
Comment 68 alovell 2020-09-29 07:03:53 PDT
I have noticed a lot of work being done by apple for MediaRecorder. Do we know if this is planed to be released with macOS Big Sur? https://developer.apple.com/safari/technology-preview/release-notes/
Comment 69 shaunbowe 2020-09-29 12:36:09 PDT
(In reply to AndyDeveloper from comment #61)
> Also, I am experiencing a new issue with the recorded files since iOS 14 and
> Safari 14 on MacOS. Most media players can't play the recorded files. It
> seems the metadata (duration, frame rate...) are not set properly. If I
> re-encode the file assuming the frame rate, then I get a valid file.

We are experiencing the same issue. Can you please provide the values that you re-encode the file with as a temporary workaround? If you have the ffmpeg command that would be even better. Thanks.
Comment 70 d2vid 2020-09-30 06:40:59 PDT
(In reply to Marcos G. from comment #65)
> unspecified pixel format
> Consider increasing the value for the 'analyzeduration' and 'probesize'

On my end, I'm able to use ffprobe on a Safari MediaRecorder created video if I increase the "-analyzeduration" and "-probesize" options. My (very incomplete) understanding is that this is caused by the moov atom header info being placed at the end of the file, so these option flags are require for ffprobe to scan enough of the file to find that info.

That being said, I'm still unable to play these videos outside of Safari/Quicktime, hoping that https://bugs.webkit.org/show_bug.cgi?id=216832 might resolve the issue.

Here's my command and output:

$ ffprobe -analyzeduration 2147483647 -probesize 2147483647 in.mp4 
ffprobe version N-93789-g06ba4783a0 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.3)
  configuration: --prefix=/usr/local --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --disable-stripping --enable-avresample --enable-avisynth --enable-libbs2b --enable-libcaca --enable-libfontconfig --enable-libfribidi --enable-libgme --enable-libgsm --enable-libopenjpeg --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtwolame --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libxvid --enable-libzmq --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-chromaprint --enable-frei0r --enable-shared --enable-nonfree
  libavutil      56. 26.101 / 56. 26.101
  libavcodec     58. 52.101 / 58. 52.101
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2020-09-29T14:46:52.000000Z
  Duration: 49:36:09.46, start: 3.668000, bitrate: 0 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 0 kb/s, 30.02 fps, 600 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2020-09-29T14:46:52.000000Z
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 132 kb/s (default)
    Metadata:
      creation_time   : 2020-09-29T14:46:52.000000Z
      handler_name    : Core Media Audio
Comment 71 d2vid 2020-09-30 06:48:07 PDT
Created attachment 410114 [details]
MediaRecorder recorded video with STP Release 113 (Safari 14.0.1, WebKit 15610.2.3.1)
Comment 72 d2vid 2020-09-30 06:48:52 PDT
Created attachment 410115 [details]
FFMPEG output video - dropping frames/stuttery but playable on Chrome
Comment 73 youenn fablet 2020-09-30 06:50:54 PDT
Would it be possible to continue discussing this specific issue in https://bugs.webkit.org/show_bug.cgi?id=216832?
Comment 74 Marcos G. 2020-09-30 13:43:43 PDT
Is this related to https://bugs.webkit.org/show_bug.cgi?id=169870 ?

I attempted to specify the mediastream constraints using https://codepen.io/marcosdg3/pen/jOqogQd

Ex:

navigator.mediaDevices.getUserMedia({
                    audio: {
                        sampleRate: 24000,
                        echoCancellation: true
                    },
                    video: {
                        width: {
                            min: 480,
                            ideal: 640,
                            max: 800
                        },
                        height: {
                            min: 360,
                            ideal: 480,
                            max: 600
                        },
                        frameRate: 16,
                        aspectRatio: (4 / 3)
                    }
                })


No sound is recorded (I think this may have been addressed in another ticket). Also the frameRate config is ignored.

The recorded output from ffprobe (30.36 fps vs the 16 fps configured in the recorder):
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 0 kb/s, 30.36 fps, 29.92 tbr, 600 tbn, 1200 tbc (default)
Comment 75 youenn fablet 2020-09-30 14:20:46 PDT
(In reply to Marcos G. from comment #74)
> Is this related to https://bugs.webkit.org/show_bug.cgi?id=169870 ?
> 
> I attempted to specify the mediastream constraints using
> https://codepen.io/marcosdg3/pen/jOqogQd

Please file a new bug entry.
For frameRate, we are doing integer decimation.
Can you try 14 or 15 instead of 16, given the native frame rate might be 30fps.

For audio not playing, maybe try with audio:true only.
Comment 76 Marcos G. 2020-09-30 15:17:05 PDT
Thank you youenn, 15 worked for me.

Created https://bugs.webkit.org/show_bug.cgi?id=217147 to track.
Comment 77 Zach Rattner 2020-11-11 22:25:56 PST
Does anyone here have any info on how to test this on an iPhone or iPad?

MediaRecorder is enabled by default on iOS in WebKit revision 267400: https://trac.webkit.org/changeset/267400/webkit

Safari Tech Preview 115 (released Oct 22) covered revisions 267325-267719: https://webkit.org/blog/11333/release-notes-for-safari-technology-preview-115/ 

It appears Apple bundles Safari with iOS and doesn’t make specific WebKit version numbers available to mere mortals. So I’m not clear on how to get STP 115 on a mobile device.
Comment 78 AndyDeveloper 2020-11-13 09:37:12 PST
(In reply to Zach Rattner from comment #77)
> Does anyone here have any info on how to test this on an iPhone or iPad?

I usually get the latest Safari version by installing the latest iOS developer beta version. I just upgraded now to iOS 14.2 RC by installing the iOS developer "beta profile". This upgraded Safari to 14.0.1.  However, I don't think that version corresponds to Release 115, as the issues I tested are still present, and the version we need is probably Safari 14.1 (same as Mac OS).

fyi - I've tested the encoding issue on MacOS Safari Technology Preview Release 115 (Safari 14.1) and it seems to be fixed.
Comment 79 AndyDeveloper 2020-11-13 10:58:29 PST
UPDATE:  I just updated to iOS 14.3 developer beta. Safari appears to have the bug fixes from this thread (orientation, encoding). I can't tell whether MediaRecorder has become enabled by default, and I can't tell what webkit version is used. The user agent string hasn't changed much from iOS 14.2 to 14.3.
As a result of the bug fixes, any workarounds need to be made conditional on the version of iOS.
Comment 80 Zach Rattner 2020-11-15 18:16:25 PST
Thanks AndyDeveloper for the sleuthing. On iOS 14.3 beta, I still see MediaRecorder.isTypeSupported is not defined, so that means https://bugs.webkit.org/show_bug.cgi?id=216856 is not present. The patch for this bug is Subversion revision 267821 (dated Oct 1), so whatever revision is present on iOS 14.3 beta is earlier than this.

The patch to enable MediaRecorder by default on iOS ( https://bugs.webkit.org/show_bug.cgi?id=216664 ) is Subversion revision 267225 (dated Sep 21). When I take a vanilla factory reset iPad on 14.2 and install the 14.3 beta, I see the MediaRecorder flag changed from off in 14.2 to on in 14.3. 

So, for anyone trying to triangulate when MediaRecorder support will hit on iOS/iPadOS, this leads me to believe the Webkit version used in Safari on 14.3 beta has Subversion revision after 267225 (Sep 21) but before 267821 (Oct 1).
Comment 81 Marcel 2020-12-17 09:49:31 PST
We are trying to get the MediaRecoder working with only one video tag. 

So for playing the GUM stream we do:
const stream = await navigator.mediaDevices.getUserMedia(constraints);
const video = document.querySelector('video#gum');
video.srcObject = stream;


After we have created a recoding with the MediaRecoder we want to play the video we do the following: 
const superBuffer = new Blob(recordedBlobs, {type: 'video/webm'});
video.srcObject = null;
video.src = window.URL.createObjectURL(superBuffer);
video.play();

We see a short flickering in the video playout but the stream form the GUM keeps playing 


We have found the link explaining we should us the Blob directly on the src of the video tag in case of Safari https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
const superBuffer = new Blob(recordedBlobs, {type: 'video/webm'});
video.srcObject = superBuffer;
video.play();

We also see a short flickering in the video playout but the stream form the GUM keeps playing 


With two video tags where one is for recoding (the GUM stream) and the other for playing the recoding (blob). Then it works fine.
Comment 82 youenn fablet 2020-12-17 11:00:38 PST
MediaRecorder is not supporting webm format at the moment.
Ditto for the media element.
Can you retry by using video/mp4?


(In reply to Marcel from comment #81)
> We are trying to get the MediaRecoder working with only one video tag. 
> 
> So for playing the GUM stream we do:
> const stream = await navigator.mediaDevices.getUserMedia(constraints);
> const video = document.querySelector('video#gum');
> video.srcObject = stream;
> 
> 
> After we have created a recoding with the MediaRecoder we want to play the
> video we do the following: 
> const superBuffer = new Blob(recordedBlobs, {type: 'video/webm'});
> video.srcObject = null;
> video.src = window.URL.createObjectURL(superBuffer);
> video.play();
> 
> We see a short flickering in the video playout but the stream form the GUM
> keeps playing 
> 
> 
> We have found the link explaining we should us the Blob directly on the src
> of the video tag in case of Safari
> https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
> const superBuffer = new Blob(recordedBlobs, {type: 'video/webm'});
> video.srcObject = superBuffer;
> video.play();
> 
> We also see a short flickering in the video playout but the stream form the
> GUM keeps playing 
> 
> 
> With two video tags where one is for recoding (the GUM stream) and the other
> for playing the recoding (blob). Then it works fine.
Comment 83 Marcel 2020-12-18 01:12:50 PST
Thank you for your quick response Youenn

My bad. I posted the wrong line of code for the creation of the Blob. It should have been: 
const blob = new Blob(recordedBlobs, {type: mediaRecorder.mimeType});

mediaRecorder.mimeType returns "video/mp4"

And yes after this change we still have the same issues.


(In reply to youenn fablet from comment #82)
> MediaRecorder is not supporting webm format at the moment.
> Ditto for the media element.
> Can you retry by using video/mp4?
Comment 84 Marcel 2020-12-18 02:07:12 PST
Here is a example of the issue:

https://jsfiddle.net/vyapfckd/1/


(In reply to Marcel from comment #83)
> Thank you for your quick response Youenn
> 
> My bad. I posted the wrong line of code for the creation of the Blob. It
> should have been: 
> const blob = new Blob(recordedBlobs, {type: mediaRecorder.mimeType});
> 
> mediaRecorder.mimeType returns "video/mp4"
> 
> And yes after this change we still have the same issues.
> 
> 
> (In reply to youenn fablet from comment #82)
> > MediaRecorder is not supporting webm format at the moment.
> > Ditto for the media element.
> > Can you retry by using video/mp4?
Comment 85 youenn fablet 2020-12-18 02:15:13 PST
(In reply to Marcel from comment #84)
> Here is a example of the issue:
> 
> https://jsfiddle.net/vyapfckd/1/
> 
> 
> (In reply to Marcel from comment #83)
> > Thank you for your quick response Youenn
> > 
> > My bad. I posted the wrong line of code for the creation of the Blob. It
> > should have been: 
> > const blob = new Blob(recordedBlobs, {type: mediaRecorder.mimeType});
> > 
> > mediaRecorder.mimeType returns "video/mp4"
> > 
> > And yes after this change we still have the same issues.

Oh, I see, this is probably https://bugs.webkit.org/show_bug.cgi?id=219258.
Can you try in latest STP 117?
Comment 86 Marcel 2020-12-18 02:50:24 PST
YES, this fixes it :D


(In reply to youenn fablet from comment #85)
> (In reply to Marcel from comment #84)
> > Here is a example of the issue:
> > 
> > https://jsfiddle.net/vyapfckd/1/
> > 
> > 
> > (In reply to Marcel from comment #83)
> > > Thank you for your quick response Youenn
> > > 
> > > My bad. I posted the wrong line of code for the creation of the Blob. It
> > > should have been: 
> > > const blob = new Blob(recordedBlobs, {type: mediaRecorder.mimeType});
> > > 
> > > mediaRecorder.mimeType returns "video/mp4"
> > > 
> > > And yes after this change we still have the same issues.
> 
> Oh, I see, this is probably https://bugs.webkit.org/show_bug.cgi?id=219258.
> Can you try in latest STP 117?
Comment 87 Octavian Naicu 2021-01-29 08:42:26 PST
Hi,

I've spent the last few days playing with the implementation in Safari 14.0.2 and Safari TP 119. 

As a result I have 2 comments regarding the information presented in https://webkit.org/blog/11353/mediarecorder-api/

1) It mentions Safari Technology Preview 105 as the one that enabled support for the MediaRecorder API by default but in fact Safari TP 114 is the one which lists "Enabled MediaRecorder by default on macOS" in it's release notes:
https://developer.apple.com/safari/technology-preview/release-notes/

2) The code in that post shows the use of 1 second time slices:

    // Let's receive 1 second blobs
    mediaRecorder.start(1000); 

In Safari 14.0.2 this functionality is broken. Using the above code will produce an .mp4 file that's corrupt as it won't play in the browser or locally in VLC.

mediaRecorder.start() does work in Safari 14.0.2 on desktop.
Comment 88 Octavian Naicu 2021-02-12 04:54:41 PST
(In reply to Octavian Naicu from comment #87)

> 2) The code in that post shows the use of 1 second time slices:
> 
>     // Let's receive 1 second blobs
>     mediaRecorder.start(1000); 
> 
> In Safari 14.0.2 this functionality is broken. Using the above code will
> produce an .mp4 file that's corrupt as it won't play in the browser or
> locally in VLC.

I've tested some more and the `timeslice` argument is supported and it works as expected. I was testing cached code when I was unable to get it to work.
Comment 89 Pantxisto 2021-02-15 05:41:11 PST
Hello,

I have Safari 14.4 on Ipad (7º gen). The issue is complex, related to orientation and I will try to explain:
There are 2 scenarios:
1-If I get a MediaStream in the Ipad and I record with MediaRecorder (originally on portrait mode), when saving on the serverside the file is on portrait mode; very good. But if I try to pipe that file with stream (nodejs) and pipe the response, if the headers are not setted correctly (meaning, accept-range... and 206 status code) the video is streammed in landscape mode. Well, we can survive this setting all the headers and the status code. I dont know if this behaviour is natural.
2-If I get the mediastream (with the WebRTC API I get from the other peer), I use chrome (in my case ubuntu), and incomming mediastream comes from safari, if I save the stream in a video file on the server side, in this case the video is saved in landscape mode (originally been on portrait mode on the safari browser). Headers doesnt work; if I pipe the file to the response it is seen on landscape mode.

My posibble reasons for this bugs are:
1-When sending the mediastream with WebRTC API (ontrackadded)some metadata is changed or added and the mediastream is corrupted.
2-When receiving a mediastream from Safari (only mp4 supported) peer on Chrome peer (only webm supported) the origin mediastream (with mp4 support, this is a hipotesis) is wrong recorded because different types support.

Thank you very much!!
Comment 90 youenn fablet 2021-02-15 05:48:41 PST
(In reply to Pantxisto from comment #89)
> Hello,
> 
> I have Safari 14.4 on Ipad (7º gen). The issue is complex, related to
> orientation and I will try to explain:
> There are 2 scenarios:
> 1-If I get a MediaStream in the Ipad and I record with MediaRecorder
> (originally on portrait mode), when saving on the serverside the file is on
> portrait mode; very good. But if I try to pipe that file with stream
> (nodejs) and pipe the response, if the headers are not setted correctly
> (meaning, accept-range... and 206 status code) the video is streammed in
> landscape mode. Well, we can survive this setting all the headers and the
> status code. I dont know if this behaviour is natural.

Could you file a dedicated bug, ideally with some repro steps (jsfiddle would be great).

> 2-If I get the mediastream (with the WebRTC API I get from the other peer),
> I use chrome (in my case ubuntu), and incomming mediastream comes from
> safari, if I save the stream in a video file on the server side, in this
> case the video is saved in landscape mode (originally been on portrait mode
> on the safari browser). Headers doesnt work; if I pipe the file to the
> response it is seen on landscape mode.

I am not exactly clear what the bug is here.
Usually, with WebRTC, CVO information is provided as RTP header and should allow the server to control correctly the orientation.
You might want to try disabling this extension, so that Safari will do the rotation before sending the data.
Comment 91 Pantxisto 2021-02-22 14:20:23 PST
Hello,
It would be great to file a dedicated bug with some repro steps but unfortunatelly I don’t have time to do that.

I make more tests and I realised the same stream saved as a file on sender (IPad-safari) is saved on portrait mode and on receiver (Ubuntu-Chrome) is saved on ladscape mode. Some weird orientation change is happening.

So it has to be something related with:
1-Metadata added or substracted on sended stream.
2-Codec incompability related to differences between Chrome and safari browsers type supporting on mediarecorder API.

Thanks.
Comment 92 Michael L 2021-07-19 06:14:15 PDT
Hello,

I noticed that on our recordings, it doesn't seem that the webkit implementation follows the bitrate guidelines.

When initiating the MediaRecorder object we pass this options config object:

{
    bitsPerSecond: 2000000
}

In theory that should limit the recording to a maximum of 1953 kb/s.

We see on multiple occurences (eg on Safari 14.1.1 on iOS 14.6) that the output file has a much bigger bitrate (eg 9700 kb/s just for the video) which produces files that are hard to upload given the size. Is this a known issue ? Is there a workaround ? (like using videoBitsPerSecond instead of bitsPerSecond ?)

Thanks
Comment 93 Michael L 2021-08-31 01:40:58 PDT
Hi Youenn,

Any news on this ? Should I open a separate ticket ?

Thanks

(In reply to Michael L from comment #92)
> Hello,
> 
> I noticed that on our recordings, it doesn't seem that the webkit
> implementation follows the bitrate guidelines.
> 
> When initiating the MediaRecorder object we pass this options config object:
> 
> {
>     bitsPerSecond: 2000000
> }
> 
> In theory that should limit the recording to a maximum of 1953 kb/s.
> 
> We see on multiple occurences (eg on Safari 14.1.1 on iOS 14.6) that the
> output file has a much bigger bitrate (eg 9700 kb/s just for the video)
> which produces files that are hard to upload given the size. Is this a known
> issue ? Is there a workaround ? (like using videoBitsPerSecond instead of
> bitsPerSecond ?)
> 
> Thanks
Comment 94 youenn fablet 2021-08-31 06:01:36 PDT
(In reply to Michael L from comment #93)
> Hi Youenn,
> 
> Any news on this ? Should I open a separate ticket ?
> 
> Thanks

Yes a new ticket would be good.
WebKit currently supports audioBitsPerSecond and videoBitsPerSecond but not yet bitsPerSecond.
Comment 95 Remus Negrota 2021-09-13 04:22:56 PDT
MediaRecorder.start() timeslice parameter is not consistent in the way it works on different macOS versions but the SAME Safari version.

Case and point, both scenarios were tested on Safari 14.1.2, with a timeslice parameter of 200.

1. On macOS 11.5.2 the recording works as expected.

2. On macOS 10.15.7 the recording is corrupted(it seems moov atom related). No matter how much you record, the recording stops playing back after 1-2 seconds.
The only way I could get it to work was to reduce the timeslice parameter to 10.
Comment 96 Tim 2021-12-22 02:24:27 PST
(In reply to youenn fablet from comment #94)
> (In reply to Michael L from comment #93)
> > Hi Youenn,
> > 
> > Any news on this ? Should I open a separate ticket ?
> > 
> > Thanks
> 
> Yes a new ticket would be good.
> WebKit currently supports audioBitsPerSecond and videoBitsPerSecond but not
> yet bitsPerSecond.

Has a ticket been created and where can I track it? I am interested to follow any progress on this. I am running into the same issue and even videoBitsPerSecond is being ignored for me.
Comment 97 maxcodefaster 2022-01-03 09:32:27 PST
https://bugs.webkit.org/show_bug.cgi?id=234784