feat: default text zero bias (#1330)
A positive value, in milliseconds. It is the threshold used to determine if we should assume that the text stream actually starts at time zero. If the first sample comes before default_text_zero_bias_ms, then the start will be padded as the stream is assumed to start at zero. If the first sample comes after default_text_zero_bias_ms then the start of the stream will not be padded as we cannot assume the start time of the stream.
This commit is contained in:
parent
db59ad582a
commit
2ba67bc24c
|
@ -46,6 +46,10 @@ struct PackagingParams {
|
||||||
/// audio) timestamps to compensate for possible negative timestamps in the
|
/// audio) timestamps to compensate for possible negative timestamps in the
|
||||||
/// input.
|
/// input.
|
||||||
int32_t transport_stream_timestamp_offset_ms = 0;
|
int32_t transport_stream_timestamp_offset_ms = 0;
|
||||||
|
// the threshold used to determine if we should assume that the text stream
|
||||||
|
// actually starts at time zero
|
||||||
|
int32_t default_text_zero_bias_ms = 0;
|
||||||
|
|
||||||
/// Chunking (segmentation) related parameters.
|
/// Chunking (segmentation) related parameters.
|
||||||
ChunkingParams chunking_params;
|
ChunkingParams chunking_params;
|
||||||
|
|
||||||
|
|
|
@ -62,3 +62,14 @@ ABSL_FLAG(int32_t,
|
||||||
"input. For example, timestamps from ISO-BMFF after adjusted by "
|
"input. For example, timestamps from ISO-BMFF after adjusted by "
|
||||||
"EditList could be negative. In transport streams, timestamps are "
|
"EditList could be negative. In transport streams, timestamps are "
|
||||||
"not allowed to be less than zero.");
|
"not allowed to be less than zero.");
|
||||||
|
ABSL_FLAG(
|
||||||
|
int32_t,
|
||||||
|
default_text_zero_bias_ms,
|
||||||
|
0,
|
||||||
|
"A positive value, in milliseconds. It is the threshold used to "
|
||||||
|
"determine if we should assume that the text stream actually starts "
|
||||||
|
"at time zero. If the first sample comes before default_text_zero_bias_ms, "
|
||||||
|
"then the start will be padded as the stream is assumed to start at zero. "
|
||||||
|
"If the first sample comes after default_text_zero_bias_ms then the start "
|
||||||
|
"of the stream will not be padded as we cannot assume the start time of "
|
||||||
|
"the stream.");
|
||||||
|
|
|
@ -21,5 +21,6 @@ ABSL_DECLARE_FLAG(bool, generate_sidx_in_media_segments);
|
||||||
ABSL_DECLARE_FLAG(std::string, temp_dir);
|
ABSL_DECLARE_FLAG(std::string, temp_dir);
|
||||||
ABSL_DECLARE_FLAG(bool, mp4_include_pssh_in_stream);
|
ABSL_DECLARE_FLAG(bool, mp4_include_pssh_in_stream);
|
||||||
ABSL_DECLARE_FLAG(int32_t, transport_stream_timestamp_offset_ms);
|
ABSL_DECLARE_FLAG(int32_t, transport_stream_timestamp_offset_ms);
|
||||||
|
ABSL_DECLARE_FLAG(int32_t, default_text_zero_bias_ms);
|
||||||
|
|
||||||
#endif // APP_MUXER_FLAGS_H_
|
#endif // APP_MUXER_FLAGS_H_
|
||||||
|
|
|
@ -461,6 +461,8 @@ std::optional<PackagingParams> GetPackagingParams() {
|
||||||
|
|
||||||
packaging_params.transport_stream_timestamp_offset_ms =
|
packaging_params.transport_stream_timestamp_offset_ms =
|
||||||
absl::GetFlag(FLAGS_transport_stream_timestamp_offset_ms);
|
absl::GetFlag(FLAGS_transport_stream_timestamp_offset_ms);
|
||||||
|
packaging_params.default_text_zero_bias_ms =
|
||||||
|
absl::GetFlag(FLAGS_default_text_zero_bias_ms);
|
||||||
|
|
||||||
packaging_params.output_media_info = absl::GetFlag(FLAGS_output_media_info);
|
packaging_params.output_media_info = absl::GetFlag(FLAGS_output_media_info);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,9 @@ Status TextPadder::OnTextSample(std::unique_ptr<StreamData> data) {
|
||||||
// start at time zero.
|
// start at time zero.
|
||||||
if (max_end_time_ms_ < 0) {
|
if (max_end_time_ms_ < 0) {
|
||||||
max_end_time_ms_ =
|
max_end_time_ms_ =
|
||||||
sample.start_time() > zero_start_bias_ms_ ? sample.start_time() : 0;
|
zero_start_bias_ms_ && sample.start_time() > zero_start_bias_ms_
|
||||||
|
? sample.start_time()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there will be a gap between samples if we just dispatch this
|
// Check if there will be a gap between samples if we just dispatch this
|
||||||
|
|
|
@ -59,8 +59,6 @@ namespace {
|
||||||
|
|
||||||
const char kMediaInfoSuffix[] = ".media_info";
|
const char kMediaInfoSuffix[] = ".media_info";
|
||||||
|
|
||||||
const int64_t kDefaultTextZeroBiasMs = 10 * 60 * 1000; // 10 minutes
|
|
||||||
|
|
||||||
MuxerListenerFactory::StreamData ToMuxerListenerData(
|
MuxerListenerFactory::StreamData ToMuxerListenerData(
|
||||||
const StreamDescriptor& stream) {
|
const StreamDescriptor& stream) {
|
||||||
MuxerListenerFactory::StreamData data;
|
MuxerListenerFactory::StreamData data;
|
||||||
|
@ -662,8 +660,8 @@ Status CreateAudioVideoJobs(
|
||||||
|
|
||||||
std::vector<std::shared_ptr<MediaHandler>> handlers;
|
std::vector<std::shared_ptr<MediaHandler>> handlers;
|
||||||
if (is_text) {
|
if (is_text) {
|
||||||
handlers.emplace_back(
|
handlers.emplace_back(std::make_shared<TextPadder>(
|
||||||
std::make_shared<TextPadder>(kDefaultTextZeroBiasMs));
|
packaging_params.default_text_zero_bias_ms));
|
||||||
}
|
}
|
||||||
if (sync_points) {
|
if (sync_points) {
|
||||||
handlers.emplace_back(cue_aligner);
|
handlers.emplace_back(cue_aligner);
|
||||||
|
|
Loading…
Reference in New Issue