Skip to content

Commit

Permalink
Add keyframe interval support. (#216)
Browse files Browse the repository at this point in the history
* Add keyframe distance support.

* Address reviewer comments.

* Introduce count to go with duration.

* address reviewer comments

* Update MediaRecorder.bs

Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>

* Update MediaRecorder.bs

Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>

* Address reviewer comments

* Update MediaRecorder.bs

Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>

* address reviewer comments

* Update MediaRecorder.bs

Co-authored-by: youennf <youennf@users.noreply.github.com>

---------

Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>
Co-authored-by: henbos <hbos@google.com>
Co-authored-by: youennf <youennf@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 20, 2023
1 parent 5d54320 commit 4b57924
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions MediaRecorder.bs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,16 @@ interface MediaRecorder : EventTarget {
member.</li>
<li>Let |recorder| have a <dfn>\[[ConstrainedBitsPerSecond]]</dfn> internal
slot, initialized to the value of |options|'
{{MediaRecorderOptions/bitsPerSecond}} member, if it is present, otherwise
<code>undefined</code>.</li>
{{MediaRecorderOptions/bitsPerSecond}} member if it is present, otherwise
<code>null</code>.</li>
<li>Let |recorder| have a <dfn>\[[VideoKeyFrameIntervalDuration]]</dfn> internal
slot, initialized to the value of |options|'
{{MediaRecorderOptions/videoKeyFrameIntervalDuration}} member if it is present, otherwise
<code>null</code>.</li>
<li>Let |recorder| have a <dfn>\[[VideoKeyFrameIntervalCount]]</dfn> internal
slot, initialized to the value of |options|'
{{MediaRecorderOptions/videoKeyFrameIntervalCount}} member if it is present, otherwise
<code>null</code>.</li>
<li>Initialize |recorder|'s {{MediaRecorder/stream}} attribute to
|stream|.</li>
<li>Initialize |recorder|'s {{MediaRecorder/mimeType}} attribute to the
Expand All @@ -115,7 +123,7 @@ interface MediaRecorder : EventTarget {
present. Otherwise, choose a target value the User Agent deems reasonable
for audio.</li>
<li>If |recorder|'s [=[[ConstrainedBitsPerSecond]]=] slot is not
<code>undefined</code>, set |recorder|'s {{MediaRecorder/videoBitsPerSecond}} and
<code>null</code>, set |recorder|'s {{MediaRecorder/videoBitsPerSecond}} and
{{MediaRecorder/audioBitsPerSecond}} attributes to values the User Agent deems reasonable
for the respective media types, such that the sum of {{MediaRecorder/videoBitsPerSecond}}
and {{MediaRecorder/audioBitsPerSecond}} is close to the value of |recorder|'s
Expand Down Expand Up @@ -221,7 +229,7 @@ interface MediaRecorder : EventTarget {
slot.</li>

<li>If |recorder|'s [=[[ConstrainedBitsPerSecond]]=] slot is not
<code>undefined</code>, set |recorder|'s {{MediaRecorder/videoBitsPerSecond}} and
<code>null</code>, set |recorder|'s {{MediaRecorder/videoBitsPerSecond}} and
{{MediaRecorder/audioBitsPerSecond}} attributes to values the User Agent deems reasonable
for the respective media types, for recording all tracks in |tracks|, such
that the sum of {{MediaRecorder/videoBitsPerSecond}} and {{MediaRecorder/audioBitsPerSecond}} is close
Expand All @@ -241,6 +249,30 @@ interface MediaRecorder : EventTarget {
the value might be surpassed, not achieved, or only be achieved over a long
period of time.</li>

<li>Let |videoKeyFrameIntervalDuration| be
|recorder|.[=[[VideoKeyFrameIntervalDuration]]=], and let
|videoKeyFrameIntervalCount| be
|recorder|.[=[[VideoKeyFrameIntervalCount]]=]. The UA SHOULD constrain the
configuration of |recorder| so that the video encoder follows the below rules:
<ul>
<li>If |videoKeyFrameIntervalDuration| is not <code>null</code> and |videoKeyFrameIntervalCount| is <code>null</code>,
the video encoder produces a keyframe on the first frame arriving after |videoKeyFrameIntervalDuration|
milliseconds elapsed since the last key frame.</li>

<li>If |videoKeyFrameIntervalCount| is not <code>null</code> and |videoKeyFrameIntervalDuration| is <code>null</code>,
the video encoder produces a keyframe on the first frame arriving after |videoKeyFrameIntervalCount|
frames passed since the last key frame.</li>

<li>If both |videoKeyFrameIntervalDuration| and |videoKeyFrameIntervalCount| are not <code>null</code>,
the UA may ignore either.</li>

<li>If both |videoKeyFrameIntervalDuration| and |videoKeyFrameIntervalCount| are <code>null</code>,
the User Agent may emit key frames as it deems fit.</li>
</ul>

Note that encoders will sometimes make independent decisions about when to
emit key frames.</li>

<li>Constrain the configuration of |recorder| to encode using the
{{BitrateMode}} specified by the value of |recorder|'s {{MediaRecorder/audioBitrateMode}}
attribute for all audio tracks |recorder| will be recording.</li>
Expand Down Expand Up @@ -531,6 +563,8 @@ dictionary MediaRecorderOptions {
unsigned long videoBitsPerSecond;
unsigned long bitsPerSecond;
BitrateMode audioBitrateMode = "variable";
DOMHighResTimeStamp videoKeyFrameIntervalDuration;
unsigned long videoKeyFrameIntervalCount;
};
</pre>

Expand Down Expand Up @@ -564,6 +598,16 @@ dictionary MediaRecorderOptions {

<dt><dfn dict-member for="MediaRecorderOptions"><code>audioBitrateMode</code></dfn></dt>
<dd>Specifes the {{BitrateMode}} that should be used to encode the Audio track(s).</dd>

<dt><dfn dict-member for="MediaRecorderOptions"><code>videoKeyFrameIntervalDuration</code></dfn></dt>
<dd>Specifies the nominal interval in time between key frames in the encoded video stream.
The UA controls key frame generation considering this dictionary member as well as
{{MediaRecorderOptions/videoKeyFrameIntervalCount}}.</dd>

<dt><dfn dict-member for="MediaRecorderOptions"><code>videoKeyFrameIntervalCount</code></dfn></dt>
<dd>Specifies the interval in number of frames between key frames in the encoded video stream.
The UA controls key frame generation considering this dictionary member as well as
{{MediaRecorderOptions/videoKeyFrameIntervalDuration}}.</dd>
</dl>

## BitrateMode ## {#bitratemode}
Expand Down

0 comments on commit 4b57924

Please sign in to comment.