Bug 226219 - Support H264 profiles in MediaRecorder
Summary: Support H264 profiles in MediaRecorder
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-25 05:51 PDT by youenn fablet
Modified: 2021-05-27 03:19 PDT (History)
7 users (show)

See Also:


Attachments
Patch (15.05 KB, patch)
2021-05-25 05:56 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (15.18 KB, patch)
2021-05-25 07:08 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (15.67 KB, patch)
2021-05-27 00:37 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2021-05-25 05:51:00 PDT
Support H264 profiles in MediaRecorder
Comment 1 youenn fablet 2021-05-25 05:51:14 PDT
<rdar://78027944>
Comment 2 youenn fablet 2021-05-25 05:56:42 PDT
Created attachment 429649 [details]
Patch
Comment 3 youenn fablet 2021-05-25 07:08:10 PDT
Created attachment 429652 [details]
Patch
Comment 4 Eric Carlson 2021-05-25 09:21:13 PDT
Comment on attachment 429652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429652&action=review

> Source/WebCore/ChangeLog:11
> +        By default, use baseline profile, which is not VideoToolbox profile but has wider decoding support.

I'm not sure what you mean by "which is not VideoToolbox profile but has wider decoding support", it sounds like you are saying that VideoToolbox doesn't support baseline.

> Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:52
> +        if (startsWithLettersIgnoringASCIICase(codec, "avc1.") && codec.length() >= 11) {
> +            if (codec[5] == '6' && codec[6] == '4')
> +                profile = Profile::High;
> +            else if (codec[5] == '4' && (codec[6] == 'd' || codec[6] == 'D'))
> +                profile = Profile::Main;
> +            break;

Do we want to use Baseline if the configuration is not supported or invalid? It is probably worth logging in that case whatever we do.

> Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:165
> +    RELEASE_LOG_ERROR_IF(error, MediaStream, "VideoSampleBufferCompressor VTSessionSetProperty kVTCompressionPropertyKey_ProfileLevel failed with %d", error);

Probably with logging what profile failed.
Comment 5 youenn fablet 2021-05-25 11:57:58 PDT
(In reply to Eric Carlson from comment #4)
> Comment on attachment 429652 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429652&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        By default, use baseline profile, which is not VideoToolbox profile but has wider decoding support.
> 
> I'm not sure what you mean by "which is not VideoToolbox profile but has
> wider decoding support", it sounds like you are saying that VideoToolbox
> doesn't support baseline.

It is not VideoToolbox default apparently.

> 
> > Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:52
> > +        if (startsWithLettersIgnoringASCIICase(codec, "avc1.") && codec.length() >= 11) {
> > +            if (codec[5] == '6' && codec[6] == '4')
> > +                profile = Profile::High;
> > +            else if (codec[5] == '4' && (codec[6] == 'd' || codec[6] == 'D'))
> > +                profile = Profile::Main;
> > +            break;
> 
> Do we want to use Baseline if the configuration is not supported or invalid?
> It is probably worth logging in that case whatever we do.

I'll check whether we have cases where baseline, main or high are not supported.
If it fails, then we use the OS default, which is not too bad.

> > Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:165
> > +    RELEASE_LOG_ERROR_IF(error, MediaStream, "VideoSampleBufferCompressor VTSessionSetProperty kVTCompressionPropertyKey_ProfileLevel failed with %d", error);
> 
> Probably with logging what profile failed.

OK.
Comment 6 Eric Carlson 2021-05-25 12:11:51 PDT
Comment on attachment 429652 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429652&action=review

>>> Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:52
>>> +            break;
>> 
>> Do we want to use Baseline if the configuration is not supported or invalid? It is probably worth logging in that case whatever we do.
> 
> I'll check whether we have cases where baseline, main or high are not supported.
> If it fails, then we use the OS default, which is not too bad.

I meant should we use baseline if the specified profile isn't supported or is invalid but now that I look, the spec says we should throw if we don't support the MIME type:

3. If invoking `is type supported` with options’ mimeType member as its argument returns false, throw a NotSupportedError DOMException and abort these steps.

so this isn't correct.

This means the logic should also be used by MediaRecorderProvider::isSupported so a page can find out what we support.
Comment 7 youenn fablet 2021-05-27 00:37:06 PDT
Created attachment 429853 [details]
Patch
Comment 8 youenn fablet 2021-05-27 02:39:15 PDT
I changed the patch to use baseline as a default if mime type profile does not stick.

> This means the logic should also be used by
> MediaRecorderProvider::isSupported so a page can find out what we support.

Right but this logic is in GPUProcess so we do not have it synchronously.
In any case, I believe baseline is supported everywhere.
If other profiles are not supported, we will use baseline which is not too bad.
We can try to improve feature detection as a follow-up patch.
Comment 9 EWS 2021-05-27 03:19:26 PDT
Committed r278158 (238202@main): <https://commits.webkit.org/238202@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429853 [details].