[MP4] Make outputs CMAF compatible

- Added flag --mp4_include_pssh_in_stream, default to true. If it is
  set to false, the encrypted mp4 stream will not include pssh.
- Align BytesOfProtectedData to multiple of 16 bytes for cenc.
- Set TrackHeader flag to kTrackEnabled | kTrackInMovie |
                          kTrackInPreview
- Move mvex to after trak, required by HLS
- Add cmfc/cmfs compatible brands except for avc3/hev1, where CMAF
  requires single initialization switching set which is not supported.
- Set duration to 0 in tkhd, mdhd, mvhd.

Also updated major_brand and compatible brands:
- Set major_brand to isom (iso-bmff media file format) and made dash
  a compatible brand
- Replaced compatible brand iso6 with iso8 since we use sthd for text
  tracks

Fixes b/36278260

Change-Id: I3cc5dd5aa1621714d517fe02fe3841d19a1a07f6
This commit is contained in:
Kongqun Yang 2017-03-15 12:42:00 -07:00
parent 5d71d8cc9f
commit d007ddf20b
91 changed files with 266 additions and 135 deletions

View File

@ -41,3 +41,6 @@ DEFINE_string(temp_dir,
"",
"Specify a directory in which to store temporary (intermediate) "
" files. Used only if single_segment=true.");
DEFINE_bool(mp4_include_pssh_in_stream,
true,
"MP4 only: include pssh in the encrypted stream.");

View File

@ -18,5 +18,6 @@ DECLARE_double(fragment_duration);
DECLARE_bool(fragment_sap_aligned);
DECLARE_int32(num_subsegments_per_sidx);
DECLARE_string(temp_dir);
DECLARE_bool(mp4_include_pssh_in_stream);
#endif // APP_MUXER_FLAGS_H_

View File

@ -193,6 +193,7 @@ EncryptionOptions GetEncryptionOptions() {
MuxerOptions GetMuxerOptions() {
MuxerOptions muxer_options;
muxer_options.num_subsegments_per_sidx = FLAGS_num_subsegments_per_sidx;
muxer_options.mp4_include_pssh_in_stream = FLAGS_mp4_include_pssh_in_stream;
if (FLAGS_mp4_use_decoding_timestamp_in_timeline) {
LOG(WARNING) << "Flag --mp4_use_decoding_timestamp_in_timeline is set. "
"Note that it is a temporary hack to workaround Chromium "

View File

@ -187,6 +187,16 @@ class PackagerAppTest(unittest.TestCase):
self._VerifyDecryption(self.output[0], 'bear-640x360-a-golden.mp4')
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
def testPackageWithEncryptionAndNoPsshInStream(self):
self.packager.Package(
self._GetStreams(['audio', 'video']),
self._GetFlags(encryption=True, include_pssh_in_stream=False))
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-no-pssh-golden.mp4')
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-no-pssh-golden.mp4')
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-no-pssh-golden.mpd')
self._VerifyDecryption(self.output[0], 'bear-640x360-a-golden.mp4')
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
def testPackageWithEncryptionCbc1(self):
self.packager.Package(
self._GetStreams(['audio', 'video']),
@ -432,6 +442,19 @@ class PackagerAppTest(unittest.TestCase):
self._DiffLiveMpdGold(self.mpd_output,
'bear-640x360-av-live-cenc-rotation-golden.mpd')
def testPackageWithLiveProfileAndKeyRotationAndNoPsshInStream(self):
self.packager.Package(
self._GetStreams(['audio', 'video'], live=True),
self._GetFlags(
encryption=True, key_rotation=True, include_pssh_in_stream=False))
self._DiffLiveGold(self.output[0],
'bear-640x360-a-live-cenc-rotation-no-pssh-golden')
self._DiffLiveGold(self.output[1],
'bear-640x360-v-live-cenc-rotation-no-pssh-golden')
self._DiffLiveMpdGold(
self.mpd_output,
'bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd')
def testPackageWithLiveProfileAndKeyRotationAndNonDashIfIop(self):
self.packager.Package(
self._GetStreams(['audio', 'video'], live=True),
@ -550,6 +573,7 @@ class PackagerAppTest(unittest.TestCase):
random_iv=False,
widevine_encryption=False,
key_rotation=False,
include_pssh_in_stream=True,
dash_if_iop=True,
output_media_info=False,
output_hls=False,
@ -587,6 +611,9 @@ class PackagerAppTest(unittest.TestCase):
if key_rotation:
flags.append('--crypto_period_duration=1')
if not include_pssh_in_stream:
flags.append('--mp4_include_pssh_in_stream=false')
if not dash_if_iop:
flags.append('--generate_dash_if_iop_compliant_mpd=false')
if output_media_info:

View File

@ -7,11 +7,11 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="81545" codecs="opus" mimeType="audio/mp4" audioSamplingRate="48000">
<Representation id="0" bandwidth="81568" codecs="opus" mimeType="audio/mp4" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="967-1034" timescale="1000000">
<Initialization range="0-966"/>
<SegmentBase indexRange="975-1042" timescale="1000000">
<Initialization range="0-974"/>
</SegmentBase>
</Representation>
</AdaptationSet>
@ -20,10 +20,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="210170" codecs="vp09.00.00.08.00.01.00.00" mimeType="video/mp4" sar="427:320">
<Representation id="1" bandwidth="210193" codecs="vp09.00.00.08.00.01.00.00" mimeType="video/mp4" sar="427:320">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1051-1118" timescale="1000000">
<Initialization range="0-1050"/>
<SegmentBase indexRange="1059-1126" timescale="1000000">
<Initialization range="0-1058"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -1,4 +1,4 @@
bandwidth: 129139
bandwidth: 129162
audio_info {
codec: "mp4a.40.2"
sampling_frequency: 44100
@ -8,11 +8,11 @@ audio_info {
}
init_range {
begin: 0
end: 958
end: 966
}
index_range {
begin: 959
end: 1026
begin: 967
end: 1034
}
media_file_name: "place_holder"
media_duration_seconds: 2.7631745

Binary file not shown.

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="885567" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="885590" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1083-1150" timescale="30000">
<Initialization range="0-1082"/>
<SegmentBase indexRange="1091-1158" timescale="30000">
<Initialization range="0-1090"/>
</SegmentBase>
</Representation>
</AdaptationSet>
@ -19,11 +19,11 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="129139" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="129162" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="959-1026" timescale="44100">
<Initialization range="0-958"/>
<SegmentBase indexRange="967-1034" timescale="44100">
<Initialization range="0-966"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="884377" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="884400" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1092-1159" timescale="30000">
<Initialization range="0-1091"/>
<SegmentBase indexRange="1100-1167" timescale="30000">
<Initialization range="0-1099"/>
</SegmentBase>
</Representation>
</AdaptationSet>
@ -19,11 +19,11 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="127214" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="127237" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="968-1035" timescale="44100">
<Initialization range="0-967"/>
<SegmentBase indexRange="976-1043" timescale="44100">
<Initialization range="0-975"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="885567" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="885590" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1083-1150" timescale="30000">
<Initialization range="0-1082"/>
<SegmentBase indexRange="1091-1158" timescale="30000">
<Initialization range="0-1090"/>
</SegmentBase>
</Representation>
</AdaptationSet>
@ -19,11 +19,11 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="129139" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="129162" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="959-1026" timescale="44100">
<Initialization range="0-958"/>
<SegmentBase indexRange="967-1034" timescale="44100">
<Initialization range="0-966"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<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.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="885438" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1039-1106" timescale="30000">
<Initialization range="0-1038"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" subsegmentAlignment="true">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="129012" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="915-982" timescale="44100">
<Initialization range="0-914"/>
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>

View File

@ -3,27 +3,27 @@
<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.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="885567" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="885590" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1083-1150" timescale="30000">
<Initialization range="0-1082"/>
<SegmentBase indexRange="1091-1158" timescale="30000">
<Initialization range="0-1090"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" subsegmentAlignment="true">
<Representation id="1" bandwidth="129139" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="129162" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="959-1026" timescale="44100">
<Initialization range="0-958"/>
<SegmentBase indexRange="967-1034" timescale="44100">
<Initialization range="0-966"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="885567" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="885590" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1083-1150" timescale="30000">
<Initialization range="0-1082"/>
<SegmentBase indexRange="1091-1158" timescale="30000">
<Initialization range="0-1090"/>
</SegmentBase>
</Representation>
</AdaptationSet>
@ -19,11 +19,11 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="129139" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="129162" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="959-1026" timescale="44100">
<Initialization range="0-958"/>
<SegmentBase indexRange="967-1034" timescale="44100">
<Initialization range="0-966"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -3,19 +3,19 @@
<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.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="882040" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="815-882" timescale="30000">
<Initialization range="0-814"/>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" subsegmentAlignment="true">
<Representation id="1" bandwidth="126487" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="126510" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="749-816" timescale="44100">
<Initialization range="0-748"/>
<SegmentBase indexRange="757-824" timescale="44100">
<Initialization range="0-756"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,7 +7,7 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="875620" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="875692" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="2002" d="30030" r="1"/>
@ -21,7 +21,7 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="1" bandwidth="124560" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="124634" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline>

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-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="875620" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="875692" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
@ -17,7 +17,7 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<Representation id="1" bandwidth="124560" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="124634" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">

View File

@ -5,7 +5,7 @@
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="0" bandwidth="876506" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="2002" d="30030" r="1"/>
@ -17,7 +17,7 @@
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="1" bandwidth="125525" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>-->
<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-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="0" bandwidth="876109" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="2002" d="30030" r="1"/>
<S t="62062" d="22022"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<Representation id="1" bandwidth="125122" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="45056"/>
<S t="45056" d="44032"/>
<S t="89088" d="32768"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
</MPD>

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-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="876506" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="876578" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
@ -15,7 +15,7 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<Representation id="1" bandwidth="125525" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="125598" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="00000000-0000-0000-0000-000000000000"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"/>

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-live:2011" minBufferTime="PT2S" type="dynamic" publishTime="some_publish_time" availabilityStartTime="some_availability_start_time" minimumUpdatePeriod="PT5S" timeShiftBufferDepth="PT1800S">
<Period id="0" start="PT0S">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="872999" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="873071" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="2002" d="30030" r="1"/>
@ -13,7 +13,7 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<Representation id="1" bandwidth="122235" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="122308" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline>

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-live:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" segmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="872999" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="873071" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<SegmentTemplate timescale="30000" initialization="output_video-init.mp4" media="output_video-$Number$.m4s" startNumber="1">
<SegmentTimeline>
<S t="2002" d="30030" r="1"/>
@ -13,7 +13,7 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" segmentAlignment="true">
<Representation id="1" bandwidth="122235" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="122308" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="44100" initialization="output_audio-init.mp4" media="output_audio-$Number$.m4s" startNumber="1">
<SegmentTimeline>

View File

@ -3,19 +3,19 @@
<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.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="882040" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="815-882" timescale="30000">
<Initialization range="0-814"/>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" lang="pt-BR" subsegmentAlignment="true">
<Representation id="1" bandwidth="126487" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="126510" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="749-816" timescale="44100">
<Initialization range="0-748"/>
<SegmentBase indexRange="757-824" timescale="44100">
<Initialization range="0-756"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -3,19 +3,19 @@
<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.76317S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="882040" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="815-882" timescale="30000">
<Initialization range="0-814"/>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" lang="pt-BR" subsegmentAlignment="true">
<Representation id="1" bandwidth="126487" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="1" bandwidth="126510" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="749-816" timescale="44100">
<Initialization range="0-748"/>
<SegmentBase indexRange="757-824" timescale="44100">
<Initialization range="0-756"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -8,19 +8,19 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="1" bandwidth="882040" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="1" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="815-882" timescale="30000">
<Initialization range="0-814"/>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="2" contentType="audio" subsegmentAlignment="true">
<Representation id="2" bandwidth="126487" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<Representation id="2" bandwidth="126510" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<BaseURL>output_audio.mp4</BaseURL>
<SegmentBase indexRange="749-816" timescale="44100">
<Initialization range="0-748"/>
<SegmentBase indexRange="757-824" timescale="44100">
<Initialization range="0-756"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="264870" codecs="hev1.1.6.L63.90" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="264881" codecs="hev1.1.6.L63.90" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="3171-3238" timescale="30000">
<Initialization range="0-3170"/>
<SegmentBase indexRange="3175-3242" timescale="30000">
<Initialization range="0-3174"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -1,4 +1,4 @@
bandwidth: 885567
bandwidth: 885590
video_info {
codec: "avc1.64001e"
width: 640
@ -11,11 +11,11 @@ video_info {
}
init_range {
begin: 0
end: 1082
end: 1090
}
index_range {
begin: 1083
end: 1150
begin: 1091
end: 1158
}
media_file_name: "place_holder"
media_duration_seconds: 2.7360666

Binary file not shown.

View File

@ -3,10 +3,10 @@
<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.73607S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<Representation id="0" bandwidth="882040" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="882064" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1">
<BaseURL>output_0.mp4</BaseURL>
<SegmentBase indexRange="815-882" timescale="30000">
<Initialization range="0-814"/>
<SegmentBase indexRange="823-890" timescale="30000">
<Initialization range="0-822"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -7,10 +7,10 @@
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<Representation id="0" bandwidth="340983" codecs="vp08.00.00.08.01.01.00.00" mimeType="video/mp4" sar="1:1">
<Representation id="0" bandwidth="341006" codecs="vp08.00.00.08.01.01.00.00" mimeType="video/mp4" sar="1:1">
<BaseURL>output_video.mp4</BaseURL>
<SegmentBase indexRange="1019-1086" timescale="1000000">
<Initialization range="0-1018"/>
<SegmentBase indexRange="1027-1094" timescale="1000000">
<Initialization range="0-1026"/>
</SegmentBase>
</Representation>
</AdaptationSet>

View File

@ -103,6 +103,11 @@ std::unique_ptr<FixedKeySource> FixedKeySource::CreateFromHexStrings(
if (!base::HexStringToBytes(key_hex, &encryption_key->key)) {
LOG(ERROR) << "Cannot parse key_hex " << key_hex;
return std::unique_ptr<FixedKeySource>();
} else if (encryption_key->key.size() != 16) {
// CENC only supports AES-128, i.e. 16 bytes.
LOG(ERROR) << "Invalid key size '" << encryption_key->key.size()
<< "', must be 16 bytes.";
return std::unique_ptr<FixedKeySource>();
}
std::vector<uint8_t> pssh_boxes;

View File

@ -32,6 +32,8 @@ enum FourCC : uint32_t {
FOURCC_cenc = 0x63656e63,
FOURCC_cens = 0x63656e73,
FOURCC_co64 = 0x636f3634,
FOURCC_cmfc = 0x636d6663,
FOURCC_cmfs = 0x636d6673,
FOURCC_ctim = 0x6374696d,
FOURCC_ctts = 0x63747473,
FOURCC_dOps = 0x644f7073,
@ -63,6 +65,8 @@ enum FourCC : uint32_t {
FOURCC_hvcC = 0x68766343,
FOURCC_iden = 0x6964656e,
FOURCC_iso6 = 0x69736f36,
FOURCC_iso8 = 0x69736f38,
FOURCC_isom = 0x69736f6d,
FOURCC_iods = 0x696f6473,
FOURCC_mdat = 0x6d646174,
FOURCC_mdhd = 0x6d646864,

View File

@ -50,6 +50,12 @@ struct MuxerOptions {
/// User-specified bit rate for the media stream. If zero, the muxer will
/// attempt to estimate.
uint32_t bandwidth = 0;
// MP4 only: include pssh in the encrypted stream. CMAF recommends carrying
// license acquisition information in the manifest and not duplicate the
// information in the stream. (This is not a hard requirement so we are still
// CMAF compatible even if pssh is included in the stream.)
bool mp4_include_pssh_in_stream = true;
};
} // namespace media

View File

@ -463,8 +463,12 @@ bool EncryptionHandler::EncryptNalFrame(MediaSample* sample,
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
// avoid partial blocks in Subsamples.
// CMAF requires 'cenc' scheme BytesOfProtectedData SHALL be a multiple
// of 16 bytes; while 'cbcs' scheme BytesOfProtectedData SHALL start on
// the first byte of video data following the slice header.
if (encryption_options_.protection_scheme == FOURCC_cbc1 ||
encryption_options_.protection_scheme == FOURCC_cens) {
encryption_options_.protection_scheme == FOURCC_cens ||
encryption_options_.protection_scheme == FOURCC_cenc) {
const uint16_t misalign_bytes = cipher_bytes % kCencBlockSize;
current_clear_bytes += misalign_bytes;
cipher_bytes -= misalign_bytes;

View File

@ -237,7 +237,8 @@ class EncryptionHandlerEncryptionTest
subsamples.emplace_back(static_cast<uint16_t>(kSubsampleSize3), 0u);
} else {
if (codec_ == kCodecVP9 || protection_scheme_ == FOURCC_cbc1 ||
protection_scheme_ == FOURCC_cens) {
protection_scheme_ == FOURCC_cens ||
protection_scheme_ == FOURCC_cenc) {
// Align the encrypted bytes to multiple of 16 bytes.
subsamples.emplace_back(static_cast<uint16_t>(kAlignedClearSize1),
static_cast<uint32_t>(kAlignedCipherSize1));

View File

@ -562,7 +562,7 @@ TrackHeader::TrackHeader()
volume(-1),
width(0),
height(0) {
flags = kTrackEnabled | kTrackInMovie;
flags = kTrackEnabled | kTrackInMovie | kTrackInPreview;
}
TrackHeader::~TrackHeader() {}
FourCC TrackHeader::BoxType() const { return FOURCC_tkhd; }
@ -2219,16 +2219,17 @@ bool Movie::ReadWriteInternal(BoxBuffer* buffer) {
RCHECK(ReadWriteHeaderInternal(buffer) &&
buffer->PrepareChildren() &&
buffer->ReadWriteChild(&header) &&
buffer->TryReadWriteChild(&metadata) &&
buffer->TryReadWriteChild(&extends));
buffer->TryReadWriteChild(&metadata));
if (buffer->Reading()) {
BoxReader* reader = buffer->reader();
DCHECK(reader);
RCHECK(reader->ReadChildren(&tracks) &&
reader->TryReadChild(&extends) &&
reader->TryReadChildren(&pssh));
} else {
for (uint32_t i = 0; i < tracks.size(); ++i)
RCHECK(buffer->ReadWriteChild(&tracks[i]));
RCHECK(buffer->TryReadWriteChild(&extends));
for (uint32_t i = 0; i < pssh.size(); ++i)
RCHECK(buffer->ReadWriteChild(&pssh[i]));
}

View File

@ -115,15 +115,27 @@ Status MP4Muxer::InitializeMuxer() {
std::unique_ptr<FileType> ftyp(new FileType);
std::unique_ptr<Movie> moov(new Movie);
ftyp->major_brand = FOURCC_dash;
ftyp->compatible_brands.push_back(FOURCC_iso6);
ftyp->major_brand = FOURCC_isom;
ftyp->compatible_brands.push_back(FOURCC_iso8);
ftyp->compatible_brands.push_back(FOURCC_mp41);
if (streams().size() == 1 && streams()[0]->stream_type() == kStreamVideo) {
const FourCC codec_fourcc = CodecToFourCC(
streams()[0]->codec(), static_cast<VideoStreamInfo*>(streams()[0].get())
->h26x_stream_format());
if (codec_fourcc != FOURCC_NULL)
ftyp->compatible_brands.push_back(codec_fourcc);
ftyp->compatible_brands.push_back(FOURCC_dash);
if (streams().size() == 1) {
FourCC codec_fourcc = FOURCC_NULL;
if (streams()[0]->stream_type() == kStreamVideo) {
codec_fourcc =
CodecToFourCC(streams()[0]->codec(),
static_cast<VideoStreamInfo*>(streams()[0].get())
->h26x_stream_format());
if (codec_fourcc != FOURCC_NULL)
ftyp->compatible_brands.push_back(codec_fourcc);
}
// CMAF allows only one track/stream per file.
// CMAF requires single initialization switching for AVC3/HEV1, which is not
// supported yet.
if (codec_fourcc != FOURCC_avc3 && codec_fourcc != FOURCC_hev1)
ftyp->compatible_brands.push_back(FOURCC_cmfc);
}
moov->header.creation_time = IsoTimeNow();
@ -160,7 +172,7 @@ Status MP4Muxer::InitializeMuxer() {
<< streams()[i]->stream_type();
}
if (streams()[i]->is_encrypted()) {
if (streams()[i]->is_encrypted() && options().mp4_include_pssh_in_stream) {
const auto& key_system_info =
streams()[i]->encryption_config().key_system_info;
moov->pssh.resize(key_system_info.size());

View File

@ -30,6 +30,9 @@ MultiSegmentSegmenter::MultiSegmentSegmenter(const MuxerOptions& options,
// Use the same brands for styp as ftyp.
styp_->major_brand = Segmenter::ftyp()->major_brand;
styp_->compatible_brands = Segmenter::ftyp()->compatible_brands;
// Replace 'cmfc' with 'cmfs' for CMAF segments compatibility.
std::replace(styp_->compatible_brands.begin(), styp_->compatible_brands.end(),
FOURCC_cmfc, FOURCC_cmfs);
}
MultiSegmentSegmenter::~MultiSegmentSegmenter() {}

View File

@ -42,11 +42,7 @@ Segmenter::Segmenter(const MuxerOptions& options,
moov_(std::move(moov)),
moof_(new MovieFragment()),
fragment_buffer_(new BufferWriter()),
sidx_(new SegmentIndex()),
progress_listener_(NULL),
progress_target_(0),
accumulated_progress_(0),
sample_duration_(0u) {}
sidx_(new SegmentIndex()) {}
Segmenter::~Segmenter() {}
@ -61,6 +57,7 @@ Status Segmenter::Initialize(
moof_->tracks.resize(streams.size());
fragmenters_.resize(streams.size());
stream_durations_.resize(streams.size());
for (uint32_t i = 0; i < streams.size(); ++i) {
moof_->tracks[i].header.track_id = i + 1;
@ -101,20 +98,17 @@ Status Segmenter::Initialize(
}
Status Segmenter::Finalize() {
// Set tracks and moov durations.
// Note that the updated moov box will be written to output file for VOD case
// only.
for (std::vector<Track>::iterator track = moov_->tracks.begin();
track != moov_->tracks.end();
++track) {
track->header.duration = Rescale(track->media.header.duration,
track->media.header.timescale,
moov_->header.timescale);
if (track->header.duration > moov_->header.duration)
moov_->header.duration = track->header.duration;
// Set movie duration. Note that the duration in mvhd, tkhd, mdhd should not
// be touched, i.e. kept at 0. The updated moov box will be written to output
// file for VOD case only.
moov_->extends.header.fragment_duration = 0;
for (size_t i = 0; i < stream_durations_.size(); ++i) {
uint64_t duration =
Rescale(stream_durations_[i], moov_->tracks[i].media.header.timescale,
moov_->header.timescale);
if (duration > moov_->extends.header.fragment_duration)
moov_->extends.header.fragment_duration = duration;
}
moov_->extends.header.fragment_duration = moov_->header.duration;
return DoFinalize();
}
@ -139,7 +133,7 @@ Status Segmenter::AddSample(size_t stream_id,
if (sample_duration_ == 0)
sample_duration_ = sample->duration();
moov_->tracks[stream_id].media.header.duration += sample->duration();
stream_durations_[stream_id] += sample->duration();
return Status::OK;
}
@ -220,12 +214,12 @@ uint32_t Segmenter::GetReferenceTimeScale() const {
}
double Segmenter::GetDuration() const {
if (moov_->header.timescale == 0) {
uint64_t duration = moov_->extends.header.fragment_duration;
if (duration == 0) {
// Handling the case where this is not properly initialized.
return 0.0;
}
return static_cast<double>(moov_->header.duration) / moov_->header.timescale;
return static_cast<double>(duration) / moov_->header.timescale;
}
void Segmenter::UpdateProgress(uint64_t progress) {
@ -258,11 +252,16 @@ void Segmenter::FinalizeFragmentForKeyRotation(
size_t stream_id,
bool fragment_encrypted,
const EncryptionConfig& encryption_config) {
const std::vector<ProtectionSystemSpecificInfo>& system_info =
encryption_config.key_system_info;
moof_->pssh.resize(system_info.size());
for (size_t i = 0; i < system_info.size(); i++)
moof_->pssh[i].raw_box = system_info[i].CreateBox();
if (options_.mp4_include_pssh_in_stream) {
const std::vector<ProtectionSystemSpecificInfo>& system_info =
encryption_config.key_system_info;
moof_->pssh.resize(system_info.size());
for (size_t i = 0; i < system_info.size(); i++)
moof_->pssh[i].raw_box = system_info[i].CreateBox();
} else {
LOG(WARNING)
<< "Key rotation and no pssh in stream may not work well together.";
}
// Skip the following steps if the current fragment is not going to be
// encrypted. 'pssh' box needs to be included in the fragment, which is

View File

@ -127,11 +127,12 @@ class Segmenter {
std::unique_ptr<BufferWriter> fragment_buffer_;
std::unique_ptr<SegmentIndex> sidx_;
std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
MuxerListener* muxer_listener_;
ProgressListener* progress_listener_;
uint64_t progress_target_;
uint64_t accumulated_progress_;
uint32_t sample_duration_;
MuxerListener* muxer_listener_ = nullptr;
ProgressListener* progress_listener_ = nullptr;
uint64_t progress_target_ = 0u;
uint64_t accumulated_progress_ = 0u;
uint32_t sample_duration_ = 0u;
std::vector<uint64_t> stream_durations_;
DISALLOW_COPY_AND_ASSIGN(Segmenter);
};