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
This commit is contained in:
KongQun Yang 2018-07-03 16:52:05 -07:00
parent 9a55d4033f
commit 51d39d96a1
128 changed files with 200 additions and 40 deletions

View File

@ -48,6 +48,8 @@ Synopsis
.. include:: /options/mp4_output_options.rst
.. include:: /options/transport_stream_output_options.rst
.. include:: /options/dash_options.rst
.. include:: /options/hls_options.rst

View File

@ -0,0 +1,10 @@
Transport stream output options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--transport_stream_timestamp_offset_ms
Transport stream only (MPEG2-TS, HLS Packed Audio): A positive value, in
milliseconds, by which output timestamps are offset to compensate for
possible negative timestamps in the input. For example, timestamps from
ISO-BMFF after adjusted by EditList could be negative. In transport streams,
timestamps are not allowed to be less than zero. Default: 100ms.

View File

@ -20,6 +20,8 @@ namespace media {
MuxerFactory::MuxerFactory(const PackagingParams& packaging_params)
: mp4_params_(packaging_params.mp4_output_params),
transport_stream_timestamp_offset_ms_(
packaging_params.transport_stream_timestamp_offset_ms),
temp_dir_(packaging_params.temp_dir) {}
std::shared_ptr<Muxer> MuxerFactory::CreateMuxer(
@ -27,6 +29,8 @@ std::shared_ptr<Muxer> MuxerFactory::CreateMuxer(
const StreamDescriptor& stream) {
MuxerOptions options;
options.mp4_params = mp4_params_;
options.transport_stream_timestamp_offset_ms =
transport_stream_timestamp_offset_ms_;
options.temp_dir = temp_dir_;
options.output_file_name = stream.output;
options.segment_template = stream.segment_template;

View File

@ -46,8 +46,9 @@ class MuxerFactory {
MuxerFactory(const MuxerFactory&) = delete;
MuxerFactory& operator=(const MuxerFactory&) = delete;
Mp4OutputParams mp4_params_;
std::string temp_dir_;
const Mp4OutputParams mp4_params_;
const uint32_t transport_stream_timestamp_offset_ms_ = 0;
const std::string temp_dir_;
base::Clock* clock_ = nullptr;
};

View File

@ -41,3 +41,10 @@ DEFINE_string(temp_dir,
DEFINE_bool(mp4_include_pssh_in_stream,
true,
"MP4 only: include pssh in the encrypted stream.");
DEFINE_int32(transport_stream_timestamp_offset_ms,
100,
"A positive value, in milliseconds, by which output timestamps "
"are offset to compensate for possible negative timestamps in the "
"input. For example, timestamps from ISO-BMFF after adjusted by "
"EditList could be negative. In transport streams, timestamps are "
"not allowed to be less than zero.");

View File

@ -19,5 +19,6 @@ DECLARE_bool(fragment_sap_aligned);
DECLARE_bool(generate_sidx_in_media_segments);
DECLARE_string(temp_dir);
DECLARE_bool(mp4_include_pssh_in_stream);
DECLARE_int32(transport_stream_timestamp_offset_ms);
#endif // APP_MUXER_FLAGS_H_

View File

@ -381,6 +381,9 @@ base::Optional<PackagingParams> GetPackagingParams() {
FLAGS_generate_sidx_in_media_segments;
mp4_params.include_pssh_in_stream = FLAGS_mp4_include_pssh_in_stream;
packaging_params.transport_stream_timestamp_offset_ms =
FLAGS_transport_stream_timestamp_offset_ms;
packaging_params.output_media_info = FLAGS_output_media_info;
MpdParams& mpd_params = packaging_params.mpd_params;

View File

@ -1486,7 +1486,8 @@ class PackagerFunctionalTest(PackagerAppTest):
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
def testHlsSegmentedWebVtt(self):
streams = self._GetStreams(['audio', 'video'], segmented=True)
streams = self._GetStreams(
['audio', 'video'], output_format='ts', segmented=True)
streams += self._GetStreams(
['text'], test_files=['bear-subtitle-english.vtt'], segmented=True)

View File

@ -6,8 +6,8 @@
<Representation id="0" bandwidth="1023201" codecs="avc1.64001e" mimeType="video/MP2T" sar="1:1" frameRate="90000/0">
<SegmentTemplate timescale="90000" media="bear-640x360-video-$Number$.ts" startNumber="1">
<SegmentTimeline>
<S t="6006" d="90090" r="1"/>
<S t="186186" d="66066"/>
<S t="15006" d="90090" r="1"/>
<S t="195186" d="66066"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
@ -17,9 +17,9 @@
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate timescale="90000" media="bear-640x360-audio-$Number$.ts" startNumber="1">
<SegmentTimeline>
<S t="3916" d="87771"/>
<S t="91688" d="89860"/>
<S t="181549" d="71052"/>
<S t="12916" d="87771"/>
<S t="100688" d="89860"/>
<S t="190549" d="71052"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>

Some files were not shown because too many files have changed in this diff Show More