Use new vp09 codec string for WebM by default

Configurable under flag --use_legacy_vp9_codec_string, which defaults
to false as all major browsers and platforms support new style vp09
codec string already.

Closes #406.

Change-Id: I22e917777f9d66db815ff9d55eb47b6d55806269
This commit is contained in:
KongQun Yang 2018-06-05 18:31:21 -07:00
parent 099c9ab724
commit 8bba658605
6 changed files with 42 additions and 8 deletions

View File

@ -3,7 +3,7 @@
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360000610351562S"> <MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.7360000610351562S">
<Period id="0"> <Period id="0">
<AdaptationSet id="0" contentType="video" width="320" height="240" frameRate="1000000/33000" subsegmentAlignment="true" par="4:3"> <AdaptationSet id="0" contentType="video" width="320" height="240" frameRate="1000000/33000" subsegmentAlignment="true" par="4:3">
<Representation id="0" bandwidth="196039" codecs="vp9" mimeType="video/webm" sar="1:1"> <Representation id="0" bandwidth="196039" codecs="vp09.00.10.08.01.02.02.02.00" mimeType="video/webm" sar="1:1">
<BaseURL>bear-vp9-blockgroup-video.webm</BaseURL> <BaseURL>bear-vp9-blockgroup-video.webm</BaseURL>
<SegmentBase indexRange="302-320" timescale="1000000"> <SegmentBase indexRange="302-320" timescale="1000000">
<Initialization range="0-301"/> <Initialization range="0-301"/>

View File

@ -12,7 +12,7 @@
</Representation> </Representation>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" contentType="video" width="320" height="240" frameRate="1000000/34000" subsegmentAlignment="true" par="16:9"> <AdaptationSet id="1" contentType="video" width="320" height="240" frameRate="1000000/34000" subsegmentAlignment="true" par="16:9">
<Representation id="1" bandwidth="225727" codecs="vp9" mimeType="video/webm" sar="427:320"> <Representation id="1" bandwidth="225727" codecs="vp09.00.10.08.01.02.02.02.00" mimeType="video/webm" sar="427:320">
<BaseURL>bear-320x240-vp9-opus-video.webm</BaseURL> <BaseURL>bear-320x240-vp9-opus-video.webm</BaseURL>
<SegmentBase indexRange="302-350" timescale="1000000" presentationTimeOffset="37000"> <SegmentBase indexRange="302-350" timescale="1000000" presentationTimeOffset="37000">
<Initialization range="0-301"/> <Initialization range="0-301"/>

View File

@ -6,7 +6,7 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="31323334-3536-3738-3930-313233343536"> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="31323334-3536-3738-3930-313233343536">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh> <cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection> </ContentProtection>
<Representation id="0" bandwidth="184009" codecs="vp9" mimeType="video/webm" sar="1:1"> <Representation id="0" bandwidth="184009" codecs="vp09.00.10.08.00.02.02.02.00" mimeType="video/webm" sar="1:1">
<BaseURL>bear-320x180-vp9-altref-video.webm</BaseURL> <BaseURL>bear-320x180-vp9-altref-video.webm</BaseURL>
<SegmentBase indexRange="353-371" timescale="1000000"> <SegmentBase indexRange="353-371" timescale="1000000">
<Initialization range="0-352"/> <Initialization range="0-352"/>

View File

@ -6,7 +6,7 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="31323334-3536-3738-3930-313233343536"> <ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" cenc:default_KID="31323334-3536-3738-3930-313233343536">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh> <cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection> </ContentProtection>
<Representation id="0" bandwidth="184009" codecs="vp9" mimeType="video/webm" sar="1:1"> <Representation id="0" bandwidth="184009" codecs="vp09.00.10.08.00.02.02.02.00" mimeType="video/webm" sar="1:1">
<BaseURL>bear-320x180-vp9-altref-video.webm</BaseURL> <BaseURL>bear-320x180-vp9-altref-video.webm</BaseURL>
<SegmentBase indexRange="353-371" timescale="1000000"> <SegmentBase indexRange="353-371" timescale="1000000">
<Initialization range="0-352"/> <Initialization range="0-352"/>

View File

@ -6,6 +6,7 @@
#include "packager/mpd/base/mpd_utils.h" #include "packager/mpd/base/mpd_utils.h"
#include <gflags/gflags.h>
#include <libxml/tree.h> #include <libxml/tree.h>
#include "packager/base/base64.h" #include "packager/base/base64.h"
@ -18,6 +19,14 @@
#include "packager/mpd/base/representation.h" #include "packager/mpd/base/representation.h"
#include "packager/mpd/base/xml/scoped_xml_ptr.h" #include "packager/mpd/base/xml/scoped_xml_ptr.h"
DEFINE_bool(
use_legacy_vp9_codec_string,
false,
"Use legacy vp9 codec string 'vp9' if set to true; otherwise new style "
"vp09.xx.xx.xx... codec string will be used. Default to false as indicated "
"in https://github.com/google/shaka-packager/issues/406, all major "
"browsers and platforms already support the new 'vp09' codec string.");
namespace shaka { namespace shaka {
namespace { namespace {
@ -97,9 +106,11 @@ std::string GetCodecs(const MediaInfo& media_info) {
// new codec strings. // new codec strings.
if (codec == "vp08") if (codec == "vp08")
return "vp8"; return "vp8";
if (FLAGS_use_legacy_vp9_codec_string) {
if (codec == "vp09") if (codec == "vp09")
return "vp9"; return "vp9";
} }
}
return media_info.video_info().codec(); return media_info.video_info().codec();
} }

View File

@ -6,6 +6,7 @@
#include "packager/mpd/base/representation.h" #include "packager/mpd/base/representation.h"
#include <gflags/gflags.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <inttypes.h> #include <inttypes.h>
@ -22,6 +23,8 @@ using ::testing::Not;
using ::testing::Values; using ::testing::Values;
using ::testing::WithParamInterface; using ::testing::WithParamInterface;
DECLARE_bool(use_legacy_vp9_codec_string);
namespace shaka { namespace shaka {
namespace { namespace {
@ -210,9 +213,29 @@ TEST_F(RepresentationTest, CheckVideoInfoVp8CodecInWebm) {
EXPECT_THAT(representation->GetXml().get(), AttributeEqual("codecs", "vp8")); EXPECT_THAT(representation->GetXml().get(), AttributeEqual("codecs", "vp8"));
} }
// Check that vp9 codec string will be updated for backward compatibility
// support in webm.
TEST_F(RepresentationTest, CheckVideoInfoVp9CodecInWebm) { TEST_F(RepresentationTest, CheckVideoInfoVp9CodecInWebm) {
const char kTestMediaInfoCodecVp9[] =
"video_info {\n"
" codec: 'vp09.00.00.08.01.01.00.00'\n"
" width: 1280\n"
" height: 720\n"
" time_scale: 10\n"
" frame_duration: 10\n"
" pixel_width: 1\n"
" pixel_height: 1\n"
"}\n"
"container_type: 3\n";
auto representation =
CreateRepresentation(ConvertToMediaInfo(kTestMediaInfoCodecVp9),
kAnyRepresentationId, NoListener());
ASSERT_TRUE(representation->Init());
EXPECT_THAT(representation->GetXml().get(),
AttributeEqual("codecs", "vp09.00.00.08.01.01.00.00"));
}
TEST_F(RepresentationTest, CheckVideoInfoLegacyVp9CodecInWebm) {
FLAGS_use_legacy_vp9_codec_string = true;
const char kTestMediaInfoCodecVp9[] = const char kTestMediaInfoCodecVp9[] =
"video_info {\n" "video_info {\n"
" codec: 'vp09.00.00.08.01.01.00.00'\n" " codec: 'vp09.00.00.08.01.01.00.00'\n"