-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "seamless" cross-codec (and possibly cross-container/track) switching #155
Comments
Isn't this directly related to the requested Ad Insertion use case and the related Implementation Use Cases? |
It is. Thank you for linking those here. |
Codec switching is a commonly requested feature for MSE. Since the current title of this spec issue implies a solution route (and scope that includes cross-container switching, not just cross-codec switching), I'm renaming it to allow discussion of what the desired scope is first. Also some details copied from the Chromium discussion, bold mine: From this comment:
From this comment:
Comments welcome, especially about whether or not cross-container switching is desired, or just same-container cross-codec switching within the same track. |
Wouldn't container switching require changes in HTML5? /paulc |
@paulbrucecotton This isn't totally clear to me, though I suspect it would involve at minimum further extension of HTML5 A/V/Text tracks that MSE already extends. What part of HTML5 were you specifically thinking might need changing to accommodate MSE SourceBuffer container switching (which is "MSE bytestream" switching). |
@wolenetz - I could be wrong but I thought HTML5 only supported a single MIME type for content attached to a particular HTMLMediaElement. Every time someone asked for the ability to change MIME types ie for ad insertion someone would point to this this restriction and the discussion would end. /paulc |
@paulbrucecotton I don't recall that particular restriction. Rather, MSE v1 requires implementations to support at least 1 audio and 1 video codec in a MediaSource (in 1 or 2 SourceBuffers), but leaves it as a quality of implementation issue for a user agent to possibly support more than this. Historically, many implementations have only done the minimum here, though this is slowly changing. canPlayType() may need to be extended, though. -edit added the canPlayType() portion. |
This is an issue worth discussion but there are several issues in this space that we explored in the past. For example, what happens when the tracks don't match in the inserted segment. See Bug 22137 - changes in number of audio tracks during advert insertion. canPlayType and anywhere else decisions are made using the codec params would be impacted by allowing format switching. One approach to solving this was proposed to provide a way to schedule audio/video track selection changes in HTMLMediaElements. Since this was a generic capability for media elements independent of MSE, it was filed on the HTML5 spec but no concrete proposal was made. |
@adrianba - excellent recall! Using timed text track metadata cues to tell the UA to perform the transitions makes sense to me on the surface. @silviapfeiffer, are there standardized metadata cue possibilities already for this, or would this require new kinds of cues? If folks agree that metadata cues afford the best route forward, we should follow https://www.w3.org/Bugs/Public/show_bug.cgi?id=22785#c19 and begin working on incubating a proposal (for HTML5 media in general, not just MSE). |
@jdsmith3000 @mwatson2 @mounirlamouri @jyavenard, I have a proposal for potentially incubating a solution for this issue, hopefully for WICG incubation towards inclusion in MSE vNext. Please take a look: https://github.com/wolenetz/media-source/blob/codec-switching/codec-switching-explainer.md |
At a quick glance, I don't understand the need for the changes as stated. A change of spec isn't compulsory. Currently, the only thing forbidden by the specs is a change of codec type within the same source buffer. The impossibility to change code in a source buffer is an artificial limitation, one that would be easy to remove. If we kept the scope to only allow codec change (not container type change), one could simply append a new init segment of the new data type and continue as before. Such modifications would be trivial (at least for gecko), would allow seamless codec change, and would integrate well with many content providers (they typically don't want to change container) Why the need for "changeType" when the information is already contained in the init segment to be appended ? |
The two main parts that the proposed changeType() method affords are cross-codec and cross-bytestream "seamless" adaptation. While some content providers may not want to change container (bytestream), there is a long-documented use case for this. Further, this allows adaptation cross-bytestream even within "primary content", not just the ad-insertion case. While I'm increasingly in favor of dropping Chrome's strictness of codec parameters in both addSourceBuffer() and the proposed changeType(), simply dropping that strictness is insufficient at least for affording the seamless cross-bytestream use case. Also, the proposed changeType(), even for cross-bytestream-switching, requires minimal additional spec'ing; definitely less than might be required for cross-SourceBuffer switching (the latter is certainly not the route I'm proposing). |
@jyavenard #155 (comment), also:
In the cross-bytestream case, changeType() provides a clear point where the application can indicate the bytestream format is changing. This allows the implementation to perform any necessary parser reset and reconfiguration to extract data out of the (potentially new) bytestream format. |
I generally like the proposal in your explainer, but I have a couple of questions.
Because of the way Shaka Player is currently architected, this is something we would require to adopt For example, if we could see it before setting up I recall some previous versions of Safari didn't expose
If switching between two supported types is not guaranteed to be supported by a given implementation of |
@wolenetz For cross-codec, cross container. I see no advantage in having changeType() when all of this can be achieved with multiple source buffers with no change in the current spec whatsoever. Though, having better description on the expected behaviour in switching source buffers (like do we prefer the most recent data if buffered range is available in both etc...) A source buffer contains one type of binary blob (mp4, webm, mpeg), it doesn't introduce the difficulty that @joeyparrish mentioned above (what would isTypeSupported return and the like) by piggy backing something on an existing well defined container. Adding a new method to just get around some user agent implementation isn't enough I believe to justify those changes. |
Following private discussion with @wolenetz, we agree that having a SourceBuffer::changeType(DOMString type) be the easiest way forward. changeType would take the same argument format as MediaSource::addSourceBuffer() In addition, 3.5.7 Initialization Segment Received (https://w3c.github.io/media-source/index.html#sourcebuffer-init-segment-received) in step 3 (If the first initialization segment received flag is true, then run the following steps: ) |
A test page was setup there: https://jyavenard.github.io/htmltests/tests/mse_mp4/changeType/changeType.html This plays a h264/aac 400x300 followed by h264/aac 640x480 followed by vp9/vorbis 400x300 |
I've updated my media-source fork to now be off wicg (which is off w3c), instead of directly off w3c, since GH doesn't allow for one account having multiple forks sharing an ancestor repository. For feature work on this issue, let's continue using just this w3c github issue for now. If that becomes too complex, we can add a tag "codec-switching" to track multiple issues related to this feature later. Feature work will be at github.com/wicg/media-source repository's "codec-switching" branch. This allows multiple other features to also be incubated. I've populated that branch just now with my codec-switching-explainer.md. The updated URL for the codec-switching explainer is now: https://github.com/wicg/media-source/blob/codec-switching/codec-switching-explainer.md |
@jyavenard - Please review the pull request containing the new codec-switching logic: WICG#2 (comment) If you need wicg repo permissions to be able to comment on that PR, please let me know. Thanks! |
(As of next dev/canary build following the changes which landed today), Chrome M69 has SourceBuffer.changeType() available when chrome://flags/#enable-experimental-web-platform-features is enabled. I have also landed changeType() web-platform-tests: web-platform-tests/wpt#11618 Note that some implementations may, for some test media, introduce buffered range gaps across appended media, just like existing same-codec, same-bytestream media before this feature (typically, when the unbuffered gap exceeds implementation-specific tolerances). Such gaps continue to motivate solving #160 for MSE vNext, too. |
https://bugs.webkit.org/show_bug.cgi?id=188626 LayoutTests/imported/w3c: Reviewed by Eric Carlson. * resources/import-expectations.json: * web-platform-tests/media-source/mediasource-changetype-expected.txt: Added. * web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added. * web-platform-tests/media-source/mediasource-changetype-play.html: Added. * web-platform-tests/media-source/mediasource-changetype-util.js: Added. (findSupportedChangeTypeTestTypes): (appendBuffer): (trimBuffered): (trimDuration): (runChangeTypeTest): (mediaSourceChangeTypeTest): * web-platform-tests/media-source/mediasource-changetype.html: Added. * web-platform-tests/media-source/mp3/sound_5.mp3: Added. * web-platform-tests/media-source/mp3/w3c-import.log: Added. * web-platform-tests/media-source/w3c-import.log: * web-platform-tests/media-source/webm/test-vp9.webm: Added. * web-platform-tests/media-source/webm/w3c-import.log: Source/WebCore: Reviewed by Eric Carlson. Tests: imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html imported/w3c/web-platform-tests/media-source/mediasource-changetype.html The WICG is incubating a new proposal to allow clients to switch between streams with different codecs within the same SourceBuffer. The proposal is being tracked by <w3c/media-source#155> and the proposed spec change is available at <https://rawgit.com/wicg/media-source/codec-switching/index.html>. Drive-by fix: One of the wpt tests uses a .mp3 file to test SourceBuffer switching. The AVStreamDataParser does not necessarily emit every frame appended, and after a new init segment is appended, it's possible that frames from the previous media segment will be emitted. This causes an error condition to occur, due to an added check in the spec for a new flag. When the SourceBuffer asks its private implementation to reset the parser state, since there's no API on AVStreamDataParser to actually reset the parser state, just set a flag to drop all emitted buffers until the next initialization segment is parsed. * Modules/mediasource/MediaSource.cpp: (WebCore::MediaSource::contentTypeShouldGenerateTimestamps): (WebCore::MediaSource::setDurationInternal): (WebCore::MediaSource::addSourceBuffer): * Modules/mediasource/MediaSource.h: * Modules/mediasource/SourceBuffer.cpp: (WebCore::SourceBuffer::changeType): (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment): (WebCore::SourceBuffer::validateInitializationSegment): (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): * Modules/mediasource/SourceBuffer.h: * Modules/mediasource/SourceBuffer.idl: * page/Settings.yaml: * platform/graphics/SourceBufferPrivate.h: (WebCore::SourceBufferPrivate::canSwitchToType): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): (WebCore::SourceBufferPrivateAVFObjC::resetParserState): (WebCore::SourceBufferPrivateAVFObjC::canSwitchToType): Source/WebKit: Reviewed by Eric Carlson. * Shared/WebPreferences.yaml: * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetSourceBufferChangeTypeEnabled): (WKPreferencesGetSourceBufferChangeTypeEnabled): * UIProcess/API/C/WKPreferencesRefPrivate.h: Source/WebKitLegacy/mac: <rdar://problem/43356021> Reviewed by Eric Carlson. Add a new WebPreference property mapping to the WebCore SourceBufferChangeTypeEnabled setting. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences sourceBufferChangeTypeEnabled]): (-[WebPreferences setSourceBufferChangeTypeEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Tools: <rdar://problem/43356021> Reviewed by Eric Carlson. * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): (resetWebPreferencesToConsistentValues): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): LayoutTests: Reviewed by Eric Carlson. * platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@234940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
I've updated the codec switching explainer today to describe the API in the incubation specification that evolved from the original proposal. The explainer now also includes links to implementation status and experimental web platform test results, describes the routes chosen in the incubation spec to resolve the original proposal's open questions, and it also mentions the "implicit codec switching" scenario and the related new non-normative guidance also included in the incubation spec. |
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316}
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316}
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316}
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316}
… relaxed type strictness and allowance for implicit changeType, a=testonly Automatic update from web-platform-tests MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316} -- Fix async tests in media-source mediasource-util.js redefines test.done() to add a final assertion before actually calling done(). However, the assertion was not wrapped in test.step(), which would lead to uncaught errors. -- wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845 wpt-pr: 17416
… relaxed type strictness and allowance for implicit changeType, a=testonly Automatic update from web-platform-tests MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316} -- Fix async tests in media-source mediasource-util.js redefines test.done() to add a final assertion before actually calling done(). However, the assertion was not wrapped in test.step(), which would lead to uncaught errors. -- wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845 wpt-pr: 17416
…allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#672316}
Is |
changeType is intended to support changing the codec or bytestream for an existing track, with some flexibility for track ID varying if there is only one track of that media type (e.g. audio or video). However, if previously, only one track type (e.g. audio-only or video-only) were buffered into a SourceBuffer, using changeType to switch that track type (audio->video or vice-versa) or to add another track of any type is not intended to be supported. |
… relaxed type strictness and allowance for implicit changeType, a=testonly Automatic update from web-platform-tests MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersdchromium.org> Commit-Queue: Matthew Wolenetz <wolenetzchromium.org> Cr-Commit-Position: refs/heads/master{#672316} -- Fix async tests in media-source mediasource-util.js redefines test.done() to add a final assertion before actually calling done(). However, the assertion was not wrapped in test.step(), which would lead to uncaught errors. -- wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845 wpt-pr: 17416 UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
… relaxed type strictness and allowance for implicit changeType, a=testonly Automatic update from web-platform-tests MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersdchromium.org> Commit-Queue: Matthew Wolenetz <wolenetzchromium.org> Cr-Commit-Position: refs/heads/master{#672316} -- Fix async tests in media-source mediasource-util.js redefines test.done() to add a final assertion before actually calling done(). However, the assertion was not wrapped in test.step(), which would lead to uncaught errors. -- wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845 wpt-pr: 17416 UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
… relaxed type strictness and allowance for implicit changeType, a=testonly Automatic update from web-platform-tests MSE: Test addSourceBuffer and changeType relaxed type strictness and allowance for implicit changeType In preparation for Chrome's relaxation of addSourceBuffer and changeType codec specificity within the mime type parameter, this change adds new new tests. It also updates the Blink test expectations for these new tests to be failures. Later changes will add Chrome's implementation of the relaxed strictness, and will also remove the failure expectations. external/wpt/media-source/mediasource-changetype-play-without-codecs-parameter: Tests successful addSourceBuffer, changeType, and codec switching without using any codecs parameter in types passed to addSourceBuffer and changeType for pairs of test media that are of same media class (audio or video) and are single track. This test is very similar to mediasource-changetype-play.html, just with less specific parameters to addSourceBuffer and changeType. This file is kept separate from mediasource-changetype-play.html to help identify implementations (like Chrome at the time of this change) that require more specific parameters to those methods. external/wpt/media-source/mediasource-changetype-play-implicit.html: Tests successful codec switching without using changeType for test media of the same bytestream format, separately for audio-only and video-only pairs of media. Also includes a set of the same tests where the initial addSourceBuffer uses only the (relaxed) mime type/subtype without any codecs parameters, for any pairs that included codecs parameters in their full types. Note: In Chrome, only 1 pair of actually different media files is supported across the test media: webm vp8 and vp9. We can add more test media later if greater coverage is desired. external/wpt/media-source/mediasource-changetype-play-negative.html: Tests of various explicit, implicit, strict and relaxed scenarios which should fail. Main MSE spec issue for this: w3c/media-source#161 Related codec-switching MSE spec issue: w3c/media-source#155 These new tests exercise related scenarios to the new non-normative guidance in the codec-switching incubation spec branch in WICG (https://github.com/WICG/media-source/tree/codec-switching), clarifying that implementations can be relaxed in addSourceBuffer and changeType codec-specificity, but not isTypeSupported; apps should still provide as much type specifics as they can to achieve earlier confidence in support or lack thereof, and to avoid issues with implementations (like Chrome at the time of this change) that require more specific parameters to those methods. BUG=535738 Change-Id: I20fd477b2429ef94ee70bf57ed8c18543774da93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663349 Reviewed-by: Dan Sanders <sandersdchromium.org> Commit-Queue: Matthew Wolenetz <wolenetzchromium.org> Cr-Commit-Position: refs/heads/master{#672316} -- Fix async tests in media-source mediasource-util.js redefines test.done() to add a final assertion before actually calling done(). However, the assertion was not wrapped in test.step(), which would lead to uncaught errors. -- wpt-commits: b42e788c6937bce1317411e61e9d18ba06835d82, 012de5bb12d78ad7135c26b15fc24f366b1c5845 wpt-pr: 17416 UltraBlame original commit: 87512e5f2ef881420cf09f14c96520b4281cccb0
I've noticed that this has begun landing in more and more browsers and I don't see it in the Editor's draft, what is the plan for getting this into the official media-source spec? |
#155 (comment) / @gregwhitworth that is a very timely question. I'm working on upstreaming the various incubations, including this one, from wicg to the main w3c repo. Expect progress on this very soon. |
We discussed this within CTA WAVE and are pleased to see it is planned for v2. If it is possible to address @jpiesing's most recent comment, that would be beneficial. |
Yes. That should count as supported. Then changes can be made to improve support. Chromium The implementation MUST disclose which codecs they intend to support is clear language to developers. Relevant to delays between frames when switching media, the ideal is "seamless". Where evidence, for example, in a bug report at an implementation describes delay between frames, that is in fact a bug. Implementations MUST disclose the codecs used and the specific implememtation thereof to the user, in code, if possible, so that the user knows which encoder or decoder the implementation is using, coould save dozens of bugs just to get to the source of a specific codec limitation. |
Would somebody be willing to assist me regarding the recommended approach for polyfilling this on legacy platforms that do not support I've seen reference to "resetting" the source buffer, or simply filtering out representations with a codec not matching the first played one, but I'm unsure how either of these would work in a practical sense. Assuming we can have only one audio or video source buffer attached at a time, and the player will be appending data into the source buffer several seconds ahead of the play head, how could the source buffer be replaced or reset at the point of "new codec append" without interrupting playback? Any advice much appreciated. |
@#155 (comment) : The practical problem you'll probably hit due to an implementation's lack of
edited to reference the comment to which this is a response. |
@#155 (comment) thank you that's very helpful. |
https://bugs.webkit.org/show_bug.cgi?id=188626 LayoutTests/imported/w3c: Reviewed by Eric Carlson. * resources/import-expectations.json: * web-platform-tests/media-source/mediasource-changetype-expected.txt: Added. * web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added. * web-platform-tests/media-source/mediasource-changetype-play.html: Added. * web-platform-tests/media-source/mediasource-changetype-util.js: Added. (findSupportedChangeTypeTestTypes): (appendBuffer): (trimBuffered): (trimDuration): (runChangeTypeTest): (mediaSourceChangeTypeTest): * web-platform-tests/media-source/mediasource-changetype.html: Added. * web-platform-tests/media-source/mp3/sound_5.mp3: Added. * web-platform-tests/media-source/mp3/w3c-import.log: Added. * web-platform-tests/media-source/w3c-import.log: * web-platform-tests/media-source/webm/test-vp9.webm: Added. * web-platform-tests/media-source/webm/w3c-import.log: Source/WebCore: Reviewed by Eric Carlson. Tests: imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html imported/w3c/web-platform-tests/media-source/mediasource-changetype.html The WICG is incubating a new proposal to allow clients to switch between streams with different codecs within the same SourceBuffer. The proposal is being tracked by <w3c/media-source#155> and the proposed spec change is available at <https://rawgit.com/wicg/media-source/codec-switching/index.html>. Drive-by fix: One of the wpt tests uses a .mp3 file to test SourceBuffer switching. The AVStreamDataParser does not necessarily emit every frame appended, and after a new init segment is appended, it's possible that frames from the previous media segment will be emitted. This causes an error condition to occur, due to an added check in the spec for a new flag. When the SourceBuffer asks its private implementation to reset the parser state, since there's no API on AVStreamDataParser to actually reset the parser state, just set a flag to drop all emitted buffers until the next initialization segment is parsed. * Modules/mediasource/MediaSource.cpp: (WebCore::MediaSource::contentTypeShouldGenerateTimestamps): (WebCore::MediaSource::setDurationInternal): (WebCore::MediaSource::addSourceBuffer): * Modules/mediasource/MediaSource.h: * Modules/mediasource/SourceBuffer.cpp: (WebCore::SourceBuffer::changeType): (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment): (WebCore::SourceBuffer::validateInitializationSegment): (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): * Modules/mediasource/SourceBuffer.h: * Modules/mediasource/SourceBuffer.idl: * page/Settings.yaml: * platform/graphics/SourceBufferPrivate.h: (WebCore::SourceBufferPrivate::canSwitchToType): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): (WebCore::SourceBufferPrivateAVFObjC::resetParserState): (WebCore::SourceBufferPrivateAVFObjC::canSwitchToType): Source/WebKit: Reviewed by Eric Carlson. * Shared/WebPreferences.yaml: * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetSourceBufferChangeTypeEnabled): (WKPreferencesGetSourceBufferChangeTypeEnabled): * UIProcess/API/C/WKPreferencesRefPrivate.h: Source/WebKitLegacy/mac: <rdar://problem/43356021> Reviewed by Eric Carlson. Add a new WebPreference property mapping to the WebCore SourceBufferChangeTypeEnabled setting. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences sourceBufferChangeTypeEnabled]): (-[WebPreferences setSourceBufferChangeTypeEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Tools: <rdar://problem/43356021> Reviewed by Eric Carlson. * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): (resetWebPreferencesToConsistentValues): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): LayoutTests: Reviewed by Eric Carlson. * platform/mac/imported/w3c/web-platform-tests/media-source/mediasource-changetype-play-expected.txt: Added. Canonical link: https://commits.webkit.org/203720@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
#274 merged the WICG-incubated specification for this feature into MSEv2 main spec (editor's draft). |
Currently, the minimum interop requirement for A/V tracks is at most one of each.
These tracks must conform to the mime-type used to construct their SourceBuffer(s).
Consequently, web apps that would like to have "seamless" cross-codec (e.g., webm vp9->h264 avc->webm vp8) transitions within the same media timeline must polyfill and depend on event delivery/timers to approximate a best-effort transition across these using multiple MediaSource objects swapped in as media element src.
This issue is opened to understand:
The text was updated successfully, but these errors were encountered: