[MP4] Allow not to generate 'sidx' box for single-segment too
I.e. the flag --generate_sidx_in_media_segments, --nogenerate_sidx_in_media_segments work for both single-segment and multi-segment mode with this change. Related to #862. Change-Id: Icd27fd00e8e036ba0c4709b48650372429cc0351
This commit is contained in:
parent
516430bde1
commit
10daa39901
|
@ -12,6 +12,8 @@ MP4 output options
|
||||||
--generate_sidx_in_media_segments
|
--generate_sidx_in_media_segments
|
||||||
--nogenerate_sidx_in_media_segments
|
--nogenerate_sidx_in_media_segments
|
||||||
|
|
||||||
For MP4 with DASH live profile only: Indicates whether to generate 'sidx'
|
Indicates whether to generate 'sidx' box in media segments. Note
|
||||||
box in media segments. Note that it is reuqired by spec if segment template
|
that it is required for DASH on-demand profile (not using segment
|
||||||
contains $Time$ specifier.
|
template).
|
||||||
|
|
||||||
|
Default enabled.
|
||||||
|
|
|
@ -36,9 +36,9 @@ DEFINE_bool(fragment_sap_aligned,
|
||||||
"implies segment_sap_aligned.");
|
"implies segment_sap_aligned.");
|
||||||
DEFINE_bool(generate_sidx_in_media_segments,
|
DEFINE_bool(generate_sidx_in_media_segments,
|
||||||
true,
|
true,
|
||||||
"For ISO BMFF with DASH live profile only. Indicates whether to "
|
"Indicates whether to generate 'sidx' box in media segments. Note "
|
||||||
"generate 'sidx' box in media segments. Note that it is required "
|
"that it is required for DASH on-demand profile (not using segment "
|
||||||
"by spec if segment template contains $Time$ specifier.");
|
"template).");
|
||||||
DEFINE_string(temp_dir,
|
DEFINE_string(temp_dir,
|
||||||
"",
|
"",
|
||||||
"Specify a directory in which to store temporary (intermediate) "
|
"Specify a directory in which to store temporary (intermediate) "
|
||||||
|
|
|
@ -45,14 +45,18 @@ bool SingleSegmentSegmenter::GetIndexRange(size_t* offset, size_t* size) {
|
||||||
// Index range is right after init range so the offset must be the size of
|
// Index range is right after init range so the offset must be the size of
|
||||||
// ftyp and moov.
|
// ftyp and moov.
|
||||||
*offset = ftyp()->ComputeSize() + moov()->ComputeSize();
|
*offset = ftyp()->ComputeSize() + moov()->ComputeSize();
|
||||||
*size = vod_sidx_->ComputeSize();
|
*size = options().mp4_params.generate_sidx_in_media_segments
|
||||||
|
? vod_sidx_->ComputeSize()
|
||||||
|
: 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Range> SingleSegmentSegmenter::GetSegmentRanges() {
|
std::vector<Range> SingleSegmentSegmenter::GetSegmentRanges() {
|
||||||
std::vector<Range> ranges;
|
std::vector<Range> ranges;
|
||||||
uint64_t next_offset =
|
uint64_t next_offset = ftyp()->ComputeSize() + moov()->ComputeSize() +
|
||||||
ftyp()->ComputeSize() + moov()->ComputeSize() + vod_sidx_->ComputeSize() +
|
(options().mp4_params.generate_sidx_in_media_segments
|
||||||
|
? vod_sidx_->ComputeSize()
|
||||||
|
: 0) +
|
||||||
vod_sidx_->first_offset;
|
vod_sidx_->first_offset;
|
||||||
for (const SegmentReference& segment_reference : vod_sidx_->references) {
|
for (const SegmentReference& segment_reference : vod_sidx_->references) {
|
||||||
Range r;
|
Range r;
|
||||||
|
@ -111,7 +115,10 @@ Status SingleSegmentSegmenter::DoFinalize() {
|
||||||
std::unique_ptr<BufferWriter> buffer(new BufferWriter());
|
std::unique_ptr<BufferWriter> buffer(new BufferWriter());
|
||||||
ftyp()->Write(buffer.get());
|
ftyp()->Write(buffer.get());
|
||||||
moov()->Write(buffer.get());
|
moov()->Write(buffer.get());
|
||||||
|
|
||||||
|
if (options().mp4_params.generate_sidx_in_media_segments)
|
||||||
vod_sidx_->Write(buffer.get());
|
vod_sidx_->Write(buffer.get());
|
||||||
|
|
||||||
Status status = buffer->WriteToFile(file.get());
|
Status status = buffer->WriteToFile(file.get());
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -24,8 +24,7 @@ namespace mp4 {
|
||||||
/// may not match the requested duration exactly, but will be approximated. That
|
/// may not match the requested duration exactly, but will be approximated. That
|
||||||
/// is, the Segmenter tries to end subsegment/fragment at the first sample with
|
/// is, the Segmenter tries to end subsegment/fragment at the first sample with
|
||||||
/// overall subsegment/fragment duration not smaller than defined duration and
|
/// overall subsegment/fragment duration not smaller than defined duration and
|
||||||
/// yet meet SAP requirements. SingleSegmentSegmenter ignores @b
|
/// yet meet SAP requirements.
|
||||||
/// MuxerOptions.mp4_params.generate_sidx_in_media_segments.
|
|
||||||
class SingleSegmentSegmenter : public Segmenter {
|
class SingleSegmentSegmenter : public Segmenter {
|
||||||
public:
|
public:
|
||||||
SingleSegmentSegmenter(const MuxerOptions& options,
|
SingleSegmentSegmenter(const MuxerOptions& options,
|
||||||
|
|
|
@ -351,6 +351,14 @@ Status ValidateParams(const PackagingParams& packaging_params,
|
||||||
"(not using segment_template).");
|
"(not using segment_template).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (on_demand_dash_profile &&
|
||||||
|
!packaging_params.mpd_params.mpd_output.empty() &&
|
||||||
|
!packaging_params.mp4_output_params.generate_sidx_in_media_segments) {
|
||||||
|
return Status(error::UNIMPLEMENTED,
|
||||||
|
"--generate_sidx_in_media_segments is required for DASH "
|
||||||
|
"on-demand profile (not using segment_template).");
|
||||||
|
}
|
||||||
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue