Commit Graph

394 Commits

Author SHA1 Message Date
Jacob Trimble f4c07b9ce0 Work around non-deterministic tests.
We currently have a bug about non-deterministic output in the MPD
generator.  This works around that bug by optionally doing everything
in a single thread.  This allows us to run manifest comparisons without
making the major changes needed to add that feature.

Issue #177

Change-Id: I10e1084dac77841220161fbd2575cdcb5c13c00e
2020-10-20 22:00:39 +00:00
Jacob Trimble c169c83613 Add integration test for WebVTT in MP4.
Change-Id: Ic8cd785d1fefde4004f27cfce346df2b2a8f643e
2020-10-19 10:55:35 -07:00
Jacob Trimble 56908a83a7 Convert text WebVTT output to muxer.
Now text-based WebVTT also uses the generic media pipeline.  This
converts the WebVttTextOutputHandler to a WebVttMuxer to be more
consistent with the other muxer types.

This also allows choosing between single-segment text and multi-segment.
Before, we would generate both and use single-segment for DASH and
multi-segment for HLS; but now you can choose between either and either
are supported in both DASH and HLS.

Change-Id: I6f7edda09e01b5f40e819290d3fe6e88677018d9
2020-10-19 17:24:38 +00:00
Jacob Trimble 2909ca0c77 Handle segmented text same as audio/video.
Now the same pipeline for handling the audio/videos streams will handle
the segmented text streams too.  This doesn't apply to the text output,
only to the MP4 variants.  This also fixes a bug where we added the
X-TIMESTAMP-MAP tag even when there wasn't TS streams; this doesn't
otherwise change the behavior around that tag.

Change-Id: I03f7cea56efa42e96311c00841330629a14aa053
2020-10-07 17:49:03 +00:00
Jacob Trimble 9babfb883b Fix segmented WebVTT test.
The test added in the previous CL was broken due to a rebase on another
change.  This subtly changed some of the byte offsets that broke the
test.  This wasn't caught since I didn't rebase and re-run the tests
before merging.

Change-Id: Id7e4c7688278eae37da1a14f1648263b4dda98cd
2020-09-16 13:24:16 -07:00
Jacob Trimble e3bc85f12d Make WebVttParser a MediaParser.
This changes it from an OriginHandler to a MediaParser and moves the
handling of it to the Demuxer.  This will allow more generic handling
of text by giving it the same abstractions as video/audio handling.

Change-Id: Ibbde3c84d228ec8e83af1ed266ea97dbc9589c24
2020-09-16 20:12:48 +00:00
koln67 5b9fd409a5
[MP4] Change major brand from isom to mp41
This fixes warnings that 'isom' can only be a compatible instead of major brand.

Issue #755.
2020-09-08 15:45:21 -07:00
koln67 562040e000
[TS] Calculate frame rate using the second sample
Related to #751.
2020-09-02 14:27:02 -07:00
koln67 54bf394c03
[HLS] Ensure playlists with TS streams include FRAME-RATE
It fixes the FRAME-RATE missing issue in #816.
2020-08-21 12:04:24 -07:00
koln67 28074e5c96
[HLS] Add support for independent segments tag
Fixes #564.
2020-08-19 11:17:21 -07:00
koln67 5c91e54b8b
[HLS] Don't include FRAME-RATE in EXT-X-STREAM-INF
Part of #816.
2020-08-06 21:51:35 -07:00
koln67 caa47e374d
Properly handle AVC profiles with SPS extension
Part of #755 to improve DASH spec compliance.
2020-08-05 17:08:53 -07:00
koln67 a8ea7fd085
Always set ES_ID to 0 when writing ES Descriptor in mp4 (#798)
Required by ISO/IEC 14496-14:2018 and ISO/IEC 23000-19:2018.

Issue #755.
2020-07-15 14:14:15 -07:00
Joe Foraci 6b036b9bb1
Support different IVs for each track (#793)
This is supported by allowing IV to be specified in the "key_info_string".

Fixes #543.
2020-06-25 20:37:50 -07:00
Jacob Trimble 1911c1beaa Add flag for extra PlayReady header data.
Fixes #756

Change-Id: I4fa6328480130675a0257fd2c6663d91729cf72c
2020-06-22 22:55:25 +00:00
Jacob Trimble 665e784cbd Move PSSH generation to EncryptionHandler.
The KeySource now only handles fetching the keys and loading any PSSH
info from the license; it will not handle generating new PSSH info
based on the config.

This will allow the PSSH generation to access to the full
EncryptionConfig so we can add additional options to it.

Issue #756

Change-Id: Ia67387aa3d5ec0d723b7f5f21fc517f64c840393
2020-06-22 22:51:44 +00:00
Jacob Trimble 51fe84f9d5 Provide better diffs for MP4 failures.
If the user has the GPAC MP4 tools installed, this will use that to
provide a better, text-based diff of the MP4 files.  This makes looking
at test failures much better than just "binary files differ".

Change-Id: Ifdca54c02226a9f0fe9ddcf9c6b28e960e568111
2020-06-10 17:12:24 +00:00
Jacob Trimble f0107beb9e Make some of the test args better.
Change-Id: I473f3318c6913e78f60a19166a54f7c873078b73
2020-06-04 15:05:40 -07:00
Jacob Trimble 719668aa1c Fix output in Python3 when tests fail.
Change-Id: Icd7552cee1336c10fe42f9f0bae175171347d369
2020-06-04 14:59:40 -07:00
Jacob Trimble 7e41937bb1 Consolidate key system enums.
There were several enum types that all were used for key systems.  This
combines them into one to make it more clear and only needing to update
one.  This also uses a bit field to specify multiple key systems instead
of using a std::vector.

Change-Id: Ia88039835492a5bd47f449ba4b76187046deeec0
2020-06-04 17:19:18 +00:00
KongQun Yang 1b262b5784 Fix failures with latest gpylint
Change-Id: Id80000b530b0582b907730db9311075a7f5307fa
2020-06-03 22:59:22 +00:00
Zajcev Evgeny 98a9d1baf6
Support for MPEG-1 Audio in mpeg2ts I/O and packed-audio output (#778)
Implemented according to https://www.datavoyage.com/mpgscript/mpeghdr.htm.

Closes #779.
2020-06-02 17:32:19 -07:00
sr90 7aefbeb27f
Adding check for creating captions with dash_only and hls_only. (#761)
Fix the problems in the previous CL for #651.
2020-04-29 17:39:12 -07:00
Tim Lansen 8e113af215
[DASH] Include <mspr:pro> alongside to <cenc:pssh> for PlayReady (#749)
Configurable under flag --include_mspr_pro_for_playready. True by default.

Closes #743.
2020-04-17 10:20:03 -07:00
sr90 fbcc8f31e3
Consider DASH stream descriptor field "roles" for WebVTT text streams. (#740)
Fixes #708.
2020-03-26 23:16:07 -07:00
Joey Parrish 9a3ea747a4 Fix python style errors
Change-Id: I78d387329cf4d9b4bead30e4df5d684b31ef104e
2020-03-19 15:50:25 -07:00
sr90 55349aa4c8
Adding --allow_codec_switching (#726)
To allow adaptive switching between different codecs.

Closes #542.
2020-03-17 19:33:44 -07:00
Tomohiro IKEDA c576814d30
Clean up descriptions in mpd command line flags (#730)
Remove the 'Exclusive' statements on --mpd_output and --output_media_info as they
can already work together.
2020-03-11 10:25:33 -07:00
sr90 a1dd82d478
Support dash_only and hls_only parameters (#721)
This allows conditional stream descriptors which apply to DASH or HLS only.

Closes #651.
2020-03-06 10:19:47 -08:00
KongQun Yang 4028bf727b Allow specifying protection pattern for pattern encryption
Added --crypt_byte_block, --skip_byte_block to allow users to specify
protection pattern other than 1:9 for pattern based encryption scheme,
e.g. cbcs and cens.

Closes #710.
b/147307451

Change-Id: I9f64a7639170c737f138572689b28d17286325c7
2020-02-28 00:50:58 +00:00
KongQun Yang b900565a0f Support Dolby Vision backward compatible profiles
Added Dolby Vision backward compatible signalling, i.e. for Dolby Vision
profile 8, both base codec without Dolby Vision and HDR codec with Dolby
Vision are signalled.

This is achieved by using a new MuxerListener implementation
MultiCodecMuxerListener, which wraps multiple child MuxerListeners and
is able to delegate to the child MuxerListeners based on the codecs in
the stream.

Closes #341.

Change-Id: I1967bb1ed503087cdd011c364e5fb5647d516ca4
2020-02-11 05:24:09 +00:00
Daniel Cantarín 7aab7a8b50
Add --hls_media_sequence_number to support custom value in HLS
HLS uses the EXT-X-MEDIA-SEQUENCE tag at the start of a live playlist in
order to specify the first segment sequence number. This is because any
live playlist have a limited number of segments, and they also keep
updating with new segments while removing old ones. When a player refreshes
the playlist, this information is important for keeping track of segments
positions.

When the packager starts, it naturally starts this count from zero. However,
there are many situations where the packager may be restarted, without this
meaning starting this value from zero (but continuing a previous sequence).
The most common situations are problems in the encoder feeding the packager.

With those cases in mind, this parameter allows to set the initial
EXT-X-MEDIA-SEQUENCE value. This way, it's possible to continue the sequence
number from previous packager run.

Closes #691.
2020-01-31 10:25:19 -08:00
Tomohiro IKEDA 0b53b40428 Change --generate_static_mpd to --generate_static_live_mpd (#672) 2019-11-15 11:53:47 -08:00
Vladimir Kazakov 981515e6c8 Generate correct PlayReady PSSH data when AES-CBC encryption is used
Fixes #602.
2019-11-15 11:48:48 -08:00
KongQun Yang 1bcaf0a835 Add an end to end test for non square pixels
Issue #663.

Change-Id: Iaba52f0fc6c97d413e973f9a3d8c74cf8c83aa03
2019-10-23 18:41:18 +00:00
KongQun Yang 0342adb132 Fix possible packager hangs when reading mp4 from FIFO
For MP4 files, mp4 parser tries to open and read the same file again
to handle trailing MOOV box.

Open FIFO again may result in packager hang.

Update the code to only attempt to load MOOV for local regular files,
as FIFO and remote files are unseekable anyway.

Fixes #664.

Change-Id: Ib286d2876d202cd5a248ffe70b13589b3cc74bc9
2019-10-21 18:49:52 -07:00
KongQun Yang 7973c5396f Replace Dolby Vision test content
Issue #341

Change-Id: I530b0768341e352f6ee0a1326540cd5712f01638
2019-10-09 21:34:53 +00:00
KongQun Yang 4f14a6f973 [HLS] Always set FRAME-RATE attribute
Although FRAME-RATE is optional per HLS specification, but per HLS
Authoring Specification for Apple Devices (https://apple.co/30n90DC):
  Each EXT-X-STREAM-INF tag MUST have a FRAME-RATE attribute.

Also, iOS and TVos refuse to play the content if VIDEO-RANGE is
present but FRAME-RATE is missing.

Issue #632, #634.

Change-Id: Ica282f023a7e8538f7b506094e2286840cf5c193
2019-10-09 21:20:32 +00:00
KongQun Yang b70da0ed93 Add --quiet to suppress LOG(INFO) outputs
Closes #661.

Change-Id: Ic75479fba4f8dc26146b42b85ab95af6151302b6
2019-10-08 10:20:51 -07:00
KongQun Yang ab8fa87d18 [HLS] Always signal Dolby Vision as PQ
Issue #341.

Change-Id: I9665ba032b1e069500d866281cb8569ce59876f9
2019-10-04 16:19:07 -07:00
KongQun Yang 3f909fa551 [HLS] Support HDR signaling, i.e. VIDEO-RANGE attribute
- Parse and extract transfer_characteristics from H264/H265 VUI
  parameters.
- Set VIDEO-RANGE attribute in HLS according to HLS specification:
  https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-02#section-4.4.4.2
- Also added an end to end test.

Fixes #632.

Change-Id: Iadf557d967b42ade321fb0b152e8e7b64fe9ff3e
2019-10-04 22:50:20 +00:00
KongQun Yang 8029004c6b Add HEVC Dolby Vision support
- Add relevant FOURCCs for Dolby Vision.
- Parse DOVIDecoderConfigurationRecord (dvcC, dvvC) to generate
  Dolby Vision codec string.
- Propagate Dolby Vision configs (dvcC, dvvC, hvcE) from Demuxer
  to Muxer.
- Add a Dolby Vision end to end test.

Support for backward compatibility signaling in DASH and HLS will be
added in a later CL.

Issue #341

Change-Id: If1385df5f48e04b59cb7661130bea48e26b453bf
2019-10-03 23:04:15 +00:00
KongQun Yang 796974d2a1 [DASH] Support custom Accessibility and Role elements
Add dash_accessibilities stream descriptor, which is a semi-colon
separated list of accessibility_scheme_id_uri=value. It is optional.

Add dash_roles stream descriptor, which is a semi-colon separated
list of strings. It is optional.

Closes #565.

Change-Id: Idb1c20bb410fdd016db07e11fe507c102a3dd8ea
2019-06-13 15:43:32 -07:00
KongQun Yang 4b8e9a662f Fix problems that target duration is not set in mpd/hls params
We have logics in bandwidth calculation to ignore segments that is
smaller than half of target duration. The logic does not have any
effect right now as the target duration in mpd/hls params is always
zero.

This change will set target duration in mpd/hls params, thus it can fix
part of issue #581 as the last segment which is less than half of
target duration.

Issue #581.
Fixes #498.

Change-Id: Ieb2dbf4da9fc72a7b9de802cda4294f1954d29b4
2019-04-30 22:41:14 +00:00
KongQun Yang 57046be126 Make packager_test.py work with python 3.5
Addresses binary/str conversion problems like
'can't use a string pattern on a bytes-like object'.

With this change, packager_test.py will work with any version of python
after python2.5.

Fixes #553.

Change-Id: I02066942e4bcdddc1db1daf761abab4cc46169a9
2019-02-13 19:07:56 +00:00
KongQun Yang de534f8550 Make packager_test.py work with python 3.0
Use logging instead of print.

Fixes #553.

Change-Id: I46b9a5bb9bb5d4cb03ddd94163905aebc4b4e9dd
2019-02-01 22:52:59 +00:00
KongQun Yang 89611a526b [HLS] Support audio only master playlist
Generate an audio only master playlist if there are no videos and
subtitles.

We do not support mixing audio only EXT-X-STREAM-INF with video
EXT-X-STREAM-INF right now.

Fixes #461.

Change-Id: I999b335ad7abbe183ffcb0f5d471948977c2772f
2018-12-13 23:52:35 +00:00
KongQun Yang cd7640a5bd Support trick play with Ad cues
Fixes #528.

Change-Id: I558285a2fae3d2048ef7cefabcd4761e35be47a8
2018-12-13 00:27:11 +00:00
KongQun Yang 492f55a018 Use upper case for Marlin uuid
This is required by Marlin although it is against uuid specification
(ITU-T X.667).

Issue #525.

Change-Id: I1592d6abe24ae09bfbb2f80931a330ee6fd61eb5
2018-12-05 13:03:25 -08:00
KongQun Yang 4b97a6d8a2 Add support for --default_text_language
It allows users to override the default language for text tracks.

If not specified, --default_language applies to both audio and text
tracks.

Issue #430.

Change-Id: I86a9baba2072be27b6661fa7b65a8bc8b6adb3cc
2018-11-26 13:42:58 -08:00
KongQun Yang 273ab09f05 Support HLS characteristics
Add hls_characteristics stream descriptor, which is a colon or semi-colon
separated list of strings. It is optional.

Fixes #430.

Change-Id: Ifcf79316e68768ff065891933de565cd0ff32ec4
2018-11-26 20:02:43 +00:00
KongQun Yang 74df8d30cc Exclude short segments from peak bandwidth computation
https://tools.ietf.org/html/rfc8216#section-4.1
The peak segment bit rate of a Media Playlist is the largest bit rate
of any contiguous set of segments whose total duration is between 0.5
and 1.5 times the target duration.

Fixes #498.

Change-Id: I1f28972b9cc5977735e47906bdcd88ba3942db5a
2018-11-26 20:02:09 +00:00
KongQun Yang 53aa775ea4 Omit all optional fields in AV1 codec string
The spec requires the optional fields to be mutually inclusive
(all or none).

Issue #453.

Change-Id: I6d62bb862957abe7a3517058510f614995a92dd9
2018-10-12 13:20:11 -07:00
KongQun Yang 4b19905bc2 Support subsample encryption in AV1
Closes #453.

Change-Id: I68e46fb83cbf7e62a19fa83698cb66bfc0acd98d
2018-10-11 11:35:00 -07:00
KongQun Yang 8d11e5ea64 Support Marlin DRM signaling in DASH
Only Marlin Adaptive Streaming Specification – Simple Profile is
supported.

Two additional updates:
- Remove FairPlay ContentProtection element from DASH mpd as FairPlay
  does not define a signaling in DASH.
- Updated end to end test to include all DRMs we support.

Closes #381.

Change-Id: Id12269b471ea34983b782cbd92f687332292ef59
2018-10-01 20:22:58 +00:00
KongQun Yang 19f80d8478 Put namespace URIs in DASH mpd only if needed
Change-Id: I31284b665599a8ee8f0b1aa11b58d6797dbe2884
2018-09-25 15:45:48 -07:00
KongQun Yang 08aa9b6b2b Remove FairPlayPsshGenerator
This was introduced earlier to indicate FairPlay protection system. But
in fact, it is sufficient to just use the system id for the indication.

- Also updated various parts of the pipeline to support empty PSSH.
- Added an additional FairPlay end to end test using fMP4.

Change-Id: Ica48b7b5235e9a2b5a7f722bcd0fc1ef2073ac13
2018-09-21 00:49:35 +00:00
KongQun Yang 42083d205d [DASH] Fix TTML text input passthrough (regression)
Note that TTML in ISO-BMFF is not supported yet.

Also updated packager_test.py:
- Added a test using TTML passthrough.
- Computed output extension from input extension unless output_format
  is specified.

Fixes #478.

Change-Id: Ia917fc4ed3c326782791ed67601fba02ea28b11d
2018-09-19 23:27:48 +00:00
KongQun Yang 31e5f129b5 Fix incorrrect segment name with $Time$ in segment_template
The time for the previous segment was used when generating the segment
name. This resulted in the first segment being overwritten and
mismatching manifest and media files. It led to playback problems.

Issue #472.

Change-Id: Ia8130ce261585e1a2ede83b26de3e32508de087f
2018-09-13 00:56:28 +00:00
KongQun Yang d0978b3937 Compute and set VP9 Level if it is not already set
The VP9 level is computed when the container is missing a codec config
or if the level is missing from the codec config.

This fixes VP9 in ISO-BMFF files generated by FFmpeg v4.0.2 or earlier
which does not have level set in the codec config.

Fixes #469.

Change-Id: I685bfd48be16ee6b2209da1c3173f7d6bb02b36a
2018-09-13 00:37:30 +00:00
KongQun Yang 0709db4bbc Add support for AV1
Implemented per AV1 Codec ISO Media File Format Binding at
  https://aomediacodec.github.io/av1-isobmff/
And AOM AV1 codec mapping in Matroska/WebM at
  https://github.com/Matroska-Org/matroska-specification/blob/av1-mappin/codec/av1.md

Note that AV1 specific boxes are not supported in this CL, i.e.
AV1 Forward Key Frame sample group entry 'av1f', AV1 Multi-Frame
sample group entry 'av1m' etc are not supported. These boxes are optional.
We will add support later if they are useful to the clients / players.

Encryption is not supported yet.

Issue #453.

Change-Id: I630432d0a9bf82d263ffaf40e57f67fc65eee902
2018-08-31 19:16:04 +00:00
KongQun Yang 40a3b42980 Fix pattern signaling in seig for key rotation with cbcs
Closes #460.
Bug: 112769382

Change-Id: Id2277edf9ac1ca637354f3a585666ad139ed8ee2
2018-08-24 23:20:06 +00:00
KongQun Yang e5b8b3ec64 Add support for seek preroll in AAC and other audio codecs
Closes #452.

Change-Id: I0f648c4fa6c861540b050a5b4e9878987c8383e5
2018-08-23 18:58:04 -07:00
KongQun Yang f49b89280c Support STYLE and REGION in WebVTT
Note that STYLE and REGION are not supported in mp4 container due to
spec limitation as 14496-30:2014 does not specify a way to signal
styles/regions inside mp4.

Closes #344.

Change-Id: I05c14df916f7b2c7ca4364ee9407e0eda4dc7a3f
2018-08-20 14:12:07 -07:00
KongQun Yang 5602050ba4 Set default clear lead to 5 seconds
Change-Id: Ic9ec564659c9df983c8dd885a0cafd45d20cb2fd
2018-08-14 22:59:37 +00:00
KongQun Yang 8612798de1 Change --additional_protection_systems to --protection_systems
Issue: #245.

Change-Id: Ib7da3b874207623e3ee0b1a942ecb2509e750669
2018-08-14 22:12:55 +00:00
KongQun Yang fd41ef0032 Properly handle failures when using PlayReady key source
Change-Id: I0a50ae67fcde1fa4a99b91ad7c2642bbfc90b73a
2018-08-14 21:17:45 +00:00
KongQun Yang 6f66132aa9 Support Widevine PSSH with protection scheme generation
Issue #245.

Change-Id: Ieabdd3cdc55eb5bd4b7a145c9d041cc918101f18
2018-08-10 00:00:21 +00:00
KongQun Yang db076d6892 Support Fairplay in --additional_protection_systems
Issue: #245.

Change-Id: I15187c1d3463534bf5e11ff97032311bb1d0c3bf
2018-08-09 23:59:40 +00:00
KongQun Yang 0fe31423cb Multi-DRM flag refactoring
- Added flag --additional_protection_systems to specify multi-DRM
  options.
- Deprecated old multi-DRM flags: --generate_widevine_pssh
                                  --generate_playready_pssh
                                  --generate_common_pssh

Issue: #245.

Change-Id: If926bc9d481e941aa2269b6672bf2ba5411c3a50
2018-08-09 22:01:46 +00:00
KongQun Yang ca810e06d5 Order trickplay outputs in trickplay factor ASC order
This also ensures that it does not violate std::sort() requirement on
strict ordering, which is enforced in gcc/g++ though not in clang.

std::sort() strict ordering requirement:
std::sort() need a comparator that return true iff the first argument is
strictly lower than the second one. That is: must return false when they
are equal.

Change-Id: I781cf4ed4125fcad212eba5430a264f3a3d71c16
2018-08-01 15:06:21 -07:00
KongQun Yang 32e3ff3e25 Set default --segment_duration to 6 seconds
This is recommended by Apple and other content providers:
https://apple.co/2uTTAc4

- Set default --clear_lead to 12 seconds, i.e. about 2 segments.
- Set default --fragment_duration to 0 so fragment (sub-segment) is not
  generated by default.

Change-Id: Ie6ec3ab6f0ce973547989c663a92b637a2fdc47c
2018-07-31 20:49:43 +00:00
KongQun Yang bd98436241 Normalize crypto_period_index to 0 for negative timestamp
It is possible to see a negative timestamp if the input mp4 file
contains EditList.

Also increase the queue size for EncryptionKey to be able to handle
smaller crypto_period_duration during testing.

Change-Id: I68278bf482d6662e771d9b80f4d5409605065aac
2018-07-31 12:56:33 -07:00
KongQun Yang 51d39d96a1 Add offset to tranport streams (MPEG2-TS, HLS Packed Audio)
Configurable with --transport_stream_offset_ms.

This is needed to compensate for possible negative timestamps in
inputs, which could happen on ISO-BMFF with EditLists.

Issue #112.

Change-Id: I0fce8766c9df2911b9bb859c1e54052a8ed2abfb
2018-07-26 23:20:21 +00:00
KongQun Yang 9a55d4033f Adjust timestamps in mp4 if there is an initial composition offset
In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Fixes: b/110782437.

Change-Id: I23d33810ce536b09a1e22a2644828d824c1314f5
2018-07-26 23:20:21 +00:00
KongQun Yang 40ea1286b9 Add support for EditLists in ISO-BMFF
- EditLists in input files are parsed and applied to sample timestamps.
- An EditList will be inserted in the ISO-BMFF output if
  - There is an offset between the initial presentation timestamp (pts)
    and decoding timestamp (dts). Chrome, as of M67, still uses dts in
    buffered range API [1], which creates various problems when buffered
    range by pts does not align with buffered range by dts. There is
    another bug in Chrome that applies EditList to pts only [2]. This
    means that we can insert an EditList to align pts range and dts range.
  - MediaSamples have negative timestamps (e.g. for Audio Priming).

You may notice the below change on some contents:
- Some media duration is reduced by one or two frames. This is because
  EditList in the input file was ignored in the previous code, so video
  streams start with a zero dts and a non-zero pts; the smaller of dts
  and pts was used as the starting timestamp (related to the earlier
  workaround for Chrome's dts bug), so the calculated duration was
  actually a bit larger than the actual duration. Now with EditList
  applied, the initial pts is reduced to zero, so the media duration is
  also reduced to reflect the actual and correct media duration.

It may also result in negative timestamps in TS/HLS Packed Audio, which
will be addressed in a follow up CL.

Fixes #112.
Partially address b/110782437.

[1] https://crbug.com/718641, fixed but behind MseBufferByPts.
[2] https://crbug.com/354518. Chrome is planning to enable the fix for
    [1] before addressing this bug, so we are safe.

Change-Id: I59317740ad3807ca66fa74b3a18fdf7f32c96aeb
2018-07-26 23:20:21 +00:00
KongQun Yang 26997bb361 Fix flaky test in packager_test.py
MPD cannot be validated right now since we do not generate deterministic
mpd with multiple inputs due to thread racing.

Exclude mpd comparison in this case.

Change-Id: I03b68b4969a39e20927c8a9b1475f72493682696
2018-07-23 22:21:18 +00:00
KongQun Yang ff5945688d Generate DASH IF IOP compliant mpd with mpd_generator by default
I.e. enable --generate_dash_if_iop_compliant_mpd in mpd_generator by
default.

It was enabled in the main packager binary in v1.6.1.

Change-Id: Icfb19758c52c107e8ab17d3fb581923fa291cc0a
2018-07-23 22:11:00 +00:00
KongQun Yang 83f29ff964 packager_test.py: clean up output filename logic
Change-Id: I8df03d6ff6af0c621a7863d19d06e98b93fcb372
2018-07-16 23:06:08 +00:00
KongQun Yang 772400e2d5 Cleanup diff comparison in packager_test.py
Change-Id: I30ef75329060e15d54fdfa5fac44d499e3a6925a
2018-07-16 23:06:01 +00:00
KongQun Yang 71072d4e6d Combine some DASH/HLS tests into one
This saves some testing time and also make it easier to compare
DASH and HLS test results.

Change-Id: Ia4bdb39f1f5ef7ee7b3f8f37f83d7490109380c2
2018-07-16 14:59:16 -07:00
KongQun Yang b4ae6561f8 Cleanup packager_test.py
- Support decryption verification in _CheckTestResults
- Allow diff_files in _CheckTestResults
- Update all functional tests to use _CheckTestResults

Change-Id: I3f9c02f35808eba787becf9b1e5c1ce9238f943e
2018-07-16 19:13:02 +00:00
KongQun Yang 5dd21179ec Do not use harmonic mean in bandwidth calculation
Instead, caclulating average bandwidth by dividing the sum of the
sizes of every segment by the sum of the durations of every segment.
This aligns with the requirement in HLS spec:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23 4.1.

BandwidthEstimator is also simplified to handle all blocks only.

Fixes #361

Change-Id: I89e7d415a841f4d4048f199de8dae7ffa250467b
2018-07-12 10:46:47 -07:00
KongQun Yang 99a2ad03af [HLS] Support AVERAGE-BANDWIDTH
Issue #361

Change-Id: Id8eb8283675cba5ec7234d13c4ac235f34e3bec9
2018-07-12 10:43:49 -07:00
KongQun Yang 1742e03471 Drepcate --num_subsegments_per_sidx
This flag was designed for two purpose:
- Grouping fragments into subsegments, achieving three level hierarchy:
  segment < subsegment < fragment.
- Indicate whether to generate 'sidx' box in media segments (when the
  value is set to a negative number).

There are no practical use case for the first purpose. Removing it to
simplify the code and reduce the confusion.

Introduce another flag --generate_sidx_in_media_segments for the second
purpose.

Change-Id: I4be7cd42662fb324c1158b978e05768ee49dd048
2018-07-02 21:59:14 +00:00
KongQun Yang f089d1d0d4 Deprecate --mp4_use_decoding_timestamp_in_timeline
It was implemented to workaround Chromium's DTS
https://crbug.com/398130, but the workaround does not really work in
all situations.

Remove it now as we already have another workaround available.

Change-Id: I291f559d78120fb743a6679b7d927e5bbc5b6b4e
2018-07-02 21:59:01 +00:00
KongQun Yang 571ee24f3e Use PTS instead of DTS in ChunkingHandler
DTS was used in ChunkingHandler. As a result, SegmentInfo contained
timestamp in DTS. MP4Muxer has a logic to change SegmentInfo to use
PTS but not in other muxers.

Benefits of using PTS in ChunkingHandler:

- De-dup the redundant logic in MP4Muxer
- Ensure consistent behavior in different output containers
- Consistent with other timestamps, e.g. Ad Cue timestamps

Issue #413

Change-Id: Ib671badf144e0c0866d60f4ff0ac0cbbdd33817e
2018-07-02 21:58:45 +00:00
KongQun Yang 6b4a75b6ba Changed to use BandwidthEstimator in MediaPlaylist
Preparing for addressing #361.

Change-Id: I4b2e834948e681bc790efc61b63a24d44f70015d
2018-06-22 11:12:23 -07:00
Aaron Vaage d8830e3168 Remove "wvtt" from Master Playlist Codec String
Having "wvtt" in the codec string (in the master playlist) causes
errors on some older Apple products. As including it is optional,
we are opted to omit it to ensure support for all Apple products.

Close #402

Change-Id: Ib1072bcc26a3ff66e3a6d3204789c0c8c678d4db
2018-06-20 17:31:51 +00:00
KongQun Yang 55cc50baa0 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
2018-06-12 23:31:28 +00:00
KongQun Yang 55050fe6b5 [Ad Insertion] Avoid adjusting EPT except for the first file
EPT (earliest presentation time) may be adjusted not to be lower than
the decoding timestamp (dts), but the adjustment should only be done
on the first file when there is one file per Representation per Period.
The second file and onwards should not be adjusted otherwise a GAP
would be created.

Closes #384
Closes b/78517422

Change-Id: I56771ad8fbbe6a87b832ec58854cfbf37d5f1817
2018-06-01 15:53:02 -07:00
Aaron Vaage b9dee56294 Rebuild Text WebVtt to MP4 WebVtt
The previous text to mp4 webvtt pipeline was incomplete. It
did not insert ad cues and it could only insert a segment
after a sample ended.

Now the pipeline supports ad cue insert and segment insertion
mid text sample. This required the pipeline to use the text
chunker (to split samples and insert segments) and required
a major overhaul of the text to mp4 converter.

Before the converter came before the chunker. This meant that
the converter only expected to see stream info and text samples.
Moving the converter after the cue aligner and chunker means
that the convert had to be aware of segments and cues.

The general approach is the same, however the converter will
convert the samples per-segment as the chunker will introduce
duplicate samples if a sample spans across segments.

Closes #362
Closes #382

Change-Id: I0f54a40524c36a602ad3804a0da26e80851c92fd
2018-06-01 19:49:56 +00:00
KongQun Yang 6e4820eedc [Ad Insertion] Support one file per Representation per Period
Allow the output file to contain template identifiers like $Number$,
$Time$ etc. Unlike the actual template used in SegmentTemplate, the
identifiers in output will be populated before pushing to the DASH
manifest.

Issue: #384

Change-Id: Ife1caadb6fccd32167fa1bc83fe2afcb2d2ad087
2018-05-31 23:59:21 +00:00
KongQun Yang 1b70c6772a Fix MPD@duration not set with MpdGenerator
Fixes: #401.

Change-Id: I5cd7c691d9cf4f187d12e5de60bf641e753f800c
2018-05-30 13:19:45 -07:00
KongQun Yang fe944f0656 Update MpdGenerator to allow inject version for testing
- Add command line flag --test_packager_version to inject packager
  version; packager_main.cc is also updated to use the same flag.
- Also add a MpdGenerator test in packager_test.py.

Change-Id: I9a11a0ee5502ba30a8acc4d44ebbfaabbe0f2f6e
2018-05-30 13:16:33 -07:00
KongQun Yang cf40accaa8 [HLS] Fixing AdCues handling in iframe playlists
Previously for the last iframe in a segment, we wait for the next
segment to arrive before writing the EXTINF tag. If an Ad Cue comes
in before the next segment, the EXT-X-PLACEMENT_OPPORTUNITY tag would
be inserted before the iframe in previous segment.

Fixes #378, #396.

Change-Id: I1ede72a4d4edca94781c7b05bc25397d67916d1a
2018-05-22 16:02:28 -07:00
KongQun Yang 4d8ce0ff5d Extract bitrates in ES descriptor for AAC if available
Change-Id: I1aa53b519e8751400bea6b33936cb2e7a05958dc
2018-05-22 11:59:58 -07:00
KongQun Yang 317425d92f Fix TS mimetype in DASH
Change-Id: I64235d02206bda9a7c18d396b2889bb28091ab5d
2018-05-21 20:31:40 +00:00
KongQun Yang b58753278c Add end to end tests for packed audio
Issue: #342.

Change-Id: Iaa890450615573da84b8934b2ba3ee3602d6fb74
2018-05-21 20:30:26 +00:00
KongQun Yang 8fc17c3653 Remove 'Package' from py.test names
Change-Id: Ifd4400c797eee3573fe732e017e2a05354d35a29
2018-05-18 20:34:18 +00:00