libgpac
Documentation of the core library of GPAC
|
MPEG-DASH creation. More...
Data Structures | |
struct | GF_DashSegmenterInput |
Functions | |
GF_DASHSegmenter * | gf_dasher_new (const char *mpdName, GF_DashProfile profile, const char *tmp_dir, u32 timescale, const char *dasher_context_file) |
void | gf_dasher_del (GF_DASHSegmenter *dasher) |
void | gf_dasher_clean_inputs (GF_DASHSegmenter *dasher) |
GF_Err | gf_dasher_set_info (GF_DASHSegmenter *dasher, const char *title, const char *copyright, const char *moreInfoURL, const char *sourceInfo, const char *lang) |
GF_Err | gf_dasher_set_location (GF_DASHSegmenter *dasher, const char *location) |
GF_Err | gf_dasher_add_base_url (GF_DASHSegmenter *dasher, const char *base_url) |
GF_Err | gf_dasher_enable_url_template (GF_DASHSegmenter *dasher, Bool enable, const char *default_template, const char *default_extension, const char *default_init_extension) |
GF_Err | gf_dasher_enable_segment_timeline (GF_DASHSegmenter *dasher, Bool enable) |
GF_Err | gf_dasher_enable_single_segment (GF_DASHSegmenter *dasher, Bool enable) |
GF_Err | gf_dasher_enable_single_file (GF_DASHSegmenter *dasher, Bool enable) |
GF_Err | gf_dasher_set_switch_mode (GF_DASHSegmenter *dasher, GF_DashSwitchingMode bitstream_switching) |
GF_Err | gf_dasher_set_durations (GF_DASHSegmenter *dasher, Double default_segment_duration, Double default_fragment_duration, Double sub_duration) |
GF_Err | gf_dasher_enable_rap_splitting (GF_DASHSegmenter *dasher, Bool segments_start_with_rap, Bool fragments_start_with_rap) |
GF_Err | gf_dasher_set_segment_marker (GF_DASHSegmenter *dasher, u32 segment_marker_4cc) |
GF_Err | gf_dasher_enable_sidx (GF_DASHSegmenter *dasher, Bool enable_sidx, u32 subsegs_per_sidx, Bool daisy_chain_sidx, Bool use_ssix) |
GF_Err | gf_dasher_set_dynamic_mode (GF_DASHSegmenter *dasher, GF_DashDynamicMode dash_mode, Double mpd_update_time, s32 time_shift_depth, Double mpd_live_duration) |
GF_Err | gf_dasher_set_min_buffer (GF_DASHSegmenter *dasher, Double min_buffer) |
GF_Err | gf_dasher_set_ast_offset (GF_DASHSegmenter *dasher, s32 ast_offset) |
GF_Err | gf_dasher_enable_memory_fragmenting (GF_DASHSegmenter *dasher, Bool enable) |
GF_Err | gf_dasher_set_initial_isobmf (GF_DASHSegmenter *dasher, u32 initial_moof_sn, u64 initial_tfdt) |
GF_Err | gf_dasher_configure_isobmf_default (GF_DASHSegmenter *dasher, Bool no_fragments_defaults, GF_DASHPSSHMode pssh_mode, Bool samplegroups_in_traf, Bool single_traf_per_moof, Bool tfdt_per_traf, Bool mvex_after_traks, u32 sdtp_in_traf) |
GF_Err | gf_dasher_enable_utc_ref (GF_DASHSegmenter *dasher, Bool insert_utc) |
GF_Err | gf_dasher_enable_real_time (GF_DASHSegmenter *dasher, Bool real_time) |
GF_Err | gf_dasher_set_content_protection_location_mode (GF_DASHSegmenter *dasher, GF_DASH_ContentLocationMode mode) |
GF_Err | gf_dasher_set_profile_extension (GF_DASHSegmenter *dasher, const char *dash_profile_extension) |
GF_Err | gf_dasher_enable_cached_inputs (GF_DASHSegmenter *dasher, Bool no_cache) |
GF_Err | gf_dasher_enable_loop_inputs (GF_DASHSegmenter *dasher, Bool do_loop) |
GF_Err | gf_dasher_set_split_mode (GF_DASHSegmenter *dasher, GF_DASH_SplitMode split_mode) |
GF_Err | gf_dasher_set_last_segment_merge (GF_DASHSegmenter *dasher, Bool merge_last_seg) |
GF_Err | gf_dasher_set_hls_clock (GF_DASHSegmenter *dasher, Bool insert_clock) |
GF_Err | gf_dasher_set_cues (GF_DASHSegmenter *dasher, const char *cues_file, Bool strict_cues) |
GF_Err | gf_dasher_add_input (GF_DASHSegmenter *dasher, const GF_DashSegmenterInput *input) |
GF_Err | gf_dasher_process (GF_DASHSegmenter *dasher) |
u32 | gf_dasher_next_update_time (GF_DASHSegmenter *dasher, u64 *ms_ins_session) |
void | gf_dasher_set_start_date (GF_DASHSegmenter *dasher, const char *dash_utc_start_date) |
GF_Err | gf_dasher_print_session_info (GF_DASHSegmenter *dasher, u32 fs_print_flags) |
GF_Err | gf_dasher_keep_source_utc (GF_DASHSegmenter *dasher, Bool keep_utc) |
GF_Err | gf_media_fragment_file (GF_ISOFile *isom_file, const char *output_file, Double max_duration_sec, Bool use_mfra) |
This section documents media functions for MPEG-DASH creation.
struct GF_DashSegmenterInput |
DASH segmenter information per source
Data Fields | ||
---|---|---|
char * | file_name |
source file to be used |
char * | representationID |
ID of the representation, may be NULL (assigned by dasher) |
char * | periodID |
ID of the period, may be NULL (assigned by dasher) |
u32 | asID |
ID of the adaptation set, may be 0 (assigned by dasher) |
GF_Fraction64 | media_duration |
forced media duration. |
u32 | nb_baseURL |
number of base URLs in the baseURL structure |
char ** | baseURL |
list of baseURL to be used for this representation |
char * | xlink |
xlink of the period if desired, NULL otherwise |
u32 | nb_roles |
number of items in roles |
char ** | roles |
role of the representation according to MPEG-DASH |
u32 | nb_rep_descs |
number of items in rep_descs |
char ** | rep_descs |
descriptors to be inserted in the representation |
u32 | nb_p_descs |
number of items in p_descs |
char ** | p_descs |
descriptors to be inserted in the period |
u32 | nb_as_descs |
number of items in nb_as_descs |
char ** | as_descs |
descriptors to be inserted in the adaptation set. Representation with non matching as_descs will be in different adaptation sets |
u32 | nb_as_c_descs |
number of items in nb_as_c_descs |
char ** | as_c_descs |
descriptors to be inserted in the adaptation set. Ignored when matching Representation to adaptation sets |
u32 | bandwidth |
forces bandwidth in bits per seconds of the source media. If 0, computed from file |
GF_Fraction | period_duration |
forced period duration (used when using empty periods or xlink periods without content) |
GF_Fraction | dash_duration |
forced dash target duration for this rep |
u32 | startNumber |
sets default start number for this representation. if not set, assigned automatically |
char * | seg_template |
overrides template for this input |
char * | hls_pl |
sets name of HLS playlist |
Bool | sscale |
if true and only one media stream in target segment, the moov will use the media stream timescale |
u32 | track_id |
only imports this track from the source |
char * | source_opts |
non legacy options passed to dasher for source |
char * | filter_chain |
filter chain to instantiate between this source and the dasher |
u32 | period_order |
period order, internal only |
enum GF_DashProfile |
DASH profile constants
Matches profile enum of dasher module: auto|live|onDemand|main|full|hbbtv1.5.live|dashavc264.live|dashavc264.onDemand
enum GF_DashSwitchingMode |
DASH bitstream switching selector
enum GF_DashDynamicMode |
DASH media presentation type
DASH selector for content protection descriptor location
enum GF_DASHPSSHMode |
DASH PSSH storage mode
enum GF_DASH_SplitMode |
DASH selector for segment split mode
GF_DASHSegmenter* gf_dasher_new | ( | const char * | mpdName, |
GF_DashProfile | profile, | ||
const char * | tmp_dir, | ||
u32 | timescale, | ||
const char * | dasher_context_file | ||
) |
Create a new DASH segmenter
mpdName | target MPD file name, cannot be changed |
profile | target DASH profile, cannot be changed |
tmp_dir | temp dir for file generation, if NULL uses libgpac default |
timescale | timescale used to specif most of the dash timings. If 0, 1000 is used |
dasher_context_file | config file used to store the context of the DASH segmenter. This allows destroying the segmenter and restarting it later on with the right DASH segquence numbers, MPD and and timing info |
void gf_dasher_del | ( | GF_DASHSegmenter * | dasher | ) |
Deletes a DASH segmenter
dasher | the DASH segmenter object |
void gf_dasher_clean_inputs | ( | GF_DASHSegmenter * | dasher | ) |
Removes the DASH inputs. Re-add new ones with gf_dasher_add_input()
dasher | the DASH segmenter object |
GF_Err gf_dasher_set_info | ( | GF_DASHSegmenter * | dasher, |
const char * | title, | ||
const char * | copyright, | ||
const char * | moreInfoURL, | ||
const char * | sourceInfo, | ||
const char * | lang | ||
) |
Sets MPD info
dasher | the DASH segmenter object |
title | MPD title |
copyright | MPD copyright |
moreInfoURL | MPD "more info" URL |
sourceInfo | MPD source info |
lang | MPD language for title |
GF_Err gf_dasher_set_location | ( | GF_DASHSegmenter * | dasher, |
const char * | location | ||
) |
Sets MPD Location. This is useful to distrubute a dynamic MPD by mail or any non-HTTP mean
dasher | the DASH segmenter object |
location | the URL where this MPD can be found |
GF_Err gf_dasher_add_base_url | ( | GF_DASHSegmenter * | dasher, |
const char * | base_url | ||
) |
Adds a base URL to the MPD
dasher | the DASH segmenter object |
base_url | base url to add |
GF_Err gf_dasher_enable_url_template | ( | GF_DASHSegmenter * | dasher, |
Bool | enable, | ||
const char * | default_template, | ||
const char * | default_extension, | ||
const char * | default_init_extension | ||
) |
Enable URL template - - may be overridden by the current profile
dasher | the DASH segmenter object |
enable | enable usage of URL template |
default_template | template for the segment name |
default_extension | extension for the segment name |
default_init_extension | extension for the initialization segment name |
Enable Segment Timeline template - may be overridden by the current profile
dasher | the DASH segmenter object |
enable | enable or disable |
Enables single segment - may be overridden by the current profile
dasher | the DASH segmenter object |
enable | enable or disable |
Enable single file (with multiple segments) - may be overridden by the current profile
dasher | the DASH segmenter object |
enable | enable or disable |
GF_Err gf_dasher_set_switch_mode | ( | GF_DASHSegmenter * | dasher, |
GF_DashSwitchingMode | bitstream_switching | ||
) |
Sets bitstream switching mode - may be overridden by the current profile
dasher | the DASH segmenter object |
bitstream_switching | mode to use for bitstream switching |
GF_Err gf_dasher_set_durations | ( | GF_DASHSegmenter * | dasher, |
Double | default_segment_duration, | ||
Double | default_fragment_duration, | ||
Double | sub_duration | ||
) |
Sets segment and fragment durations.
dasher | the DASH segmenter object |
default_segment_duration | the duration of a dash segment |
default_fragment_duration | the duration of a dash fragment - if 0, same as default_segment_duration |
sub_duration | the duration in seconds of media to DASH. If 0, the whole sources will be processed. |
GF_Err gf_dasher_enable_rap_splitting | ( | GF_DASHSegmenter * | dasher, |
Bool | segments_start_with_rap, | ||
Bool | fragments_start_with_rap | ||
) |
Enables splitting at RAP boundaries
dasher | the DASH segmenter object |
segments_start_with_rap | segments will be split at RAP boundaries |
fragments_start_with_rap | fragments will be split at RAP boundaries |
Enables segment marker
dasher | the DASH segmenter object |
segment_marker_4cc | 4CC code of the segment marker box |
GF_Err gf_dasher_enable_sidx | ( | GF_DASHSegmenter * | dasher, |
Bool | enable_sidx, | ||
u32 | subsegs_per_sidx, | ||
Bool | daisy_chain_sidx, | ||
Bool | use_ssix | ||
) |
Enables segment indexes
dasher | the DASH segmenter object |
enable_sidx | enable or disable |
subsegs_per_sidx | number of subsegments per segment |
daisy_chain_sidx | enable daisy chaining of sidx |
use_ssix | enables ssix generation, level 1 for I-frames, the rest of the segment not mapped |
GF_Err gf_dasher_set_dynamic_mode | ( | GF_DASHSegmenter * | dasher, |
GF_DashDynamicMode | dash_mode, | ||
Double | mpd_update_time, | ||
s32 | time_shift_depth, | ||
Double | mpd_live_duration | ||
) |
Sets mode for the dash segmenter.
dasher | the DASH segmenter object |
dash_mode | the mode to use. Currently switching from static mode to dynamic mode is not well supported and may produce non-compliant MPDs |
mpd_update_time | time between MPD refresh, in seconds. Used for dynamic mode, may be 0 if mpd_live_duration is set |
time_shift_depth | the depth of the time shift buffer in seconds, -1 for infinite time shift. |
mpd_live_duration | total duration of the DASH session in dynamic mode, in seconds. May be set to 0 if mpd_update_time is set |
Sets the minimal buffer desired.
dasher | the DASH segmenter object |
min_buffer | min buffer time in seconds for the DASH session. Currently the minimal buffer is NOT computed from the source material and must be set to an appropriate value. |
Sets the availability start time offset.
dasher | the DASH segmenter object |
ast_offset | ast offset in milliseconds. If >0, the DASH session availabilityStartTime will be earlier than UTC by the amount of seconds specified. If <0, the media representation will have an availabilityTimeOffset of the amount of seconds specified, instructing the client that segments may be accessed earlier. |
Enables memory fragmenting: fragments will be written to disk only once completed
dasher | the DASH segmenter object |
enable | Enables or disables. Default is disabled. |
GF_Err gf_dasher_set_initial_isobmf | ( | GF_DASHSegmenter * | dasher, |
u32 | initial_moof_sn, | ||
u64 | initial_tfdt | ||
) |
Sets initial values for ISOBMFF sequence number and TFDT in movie fragments.
dasher | the DASH segmenter object |
initial_moof_sn | sequence number of the first moof to be generated. Default value is 1. |
initial_tfdt | initial tfdt of the first traf to be generated, in DASH segmenter timescale units. Default value is 0. |
GF_Err gf_dasher_configure_isobmf_default | ( | GF_DASHSegmenter * | dasher, |
Bool | no_fragments_defaults, | ||
GF_DASHPSSHMode | pssh_mode, | ||
Bool | samplegroups_in_traf, | ||
Bool | single_traf_per_moof, | ||
Bool | tfdt_per_traf, | ||
Bool | mvex_after_traks, | ||
u32 | sdtp_in_traf | ||
) |
Configure how default values for ISOBMFF are stored
dasher | the DASH segmenter object |
no_fragments_defaults | if set, fragments default values are repeated in each traf and not set in trex. Default value is GF_FALSE |
pssh_mode | sets the storage mode of PSSH in moov/moof/mpd. |
samplegroups_in_traf | if set, all sample group definitions are stored in each traf and not set in init segment. Default value is GF_FALSE |
single_traf_per_moof | if set, each moof will contain a single traf, even if source media is multiplexed. Default value is GF_FALSE |
tfdt_per_traf | if set, each traf will contain a tfdt. Only applicable when single_traf_per_moof is GF_TRUE. Default value is GF_FALSE |
mvex_after_traks | if set, the mvex box will be written after all track boxes |
sdtp_in_traf | mode for sdtp storage in traf (smooth compatibility): 0: not allowed, 1: only stdp, no trun flags, 2: both (trun for sync, stdp for the rest) |
Enables insertion of UTC reference in the beginning of segments
dasher | the DASH segmenter object |
insert_utc | if set, UTC will be inserted. Default value is disabled. |
Enables real-time generation of media segments.
dasher | the DASH segmenter object |
real_time | if set, segments are generated in real time. Only supported for single representation (potentially multiplexed) DASH session. Default is disabled. |
GF_Err gf_dasher_set_content_protection_location_mode | ( | GF_DASHSegmenter * | dasher, |
GF_DASH_ContentLocationMode | mode | ||
) |
Sets where the ContentProtection element is inserted in an adaptation set.
dasher | the DASH segmenter object |
mode | ContentProtection element location mode. |
GF_Err gf_dasher_set_profile_extension | ( | GF_DASHSegmenter * | dasher, |
const char * | dash_profile_extension | ||
) |
Sets profile extension as used by DASH-IF and DVB.
dasher | the DASH segmenter object |
dash_profile_extension | specifies a string of profile extensions, as used by DASH-IF and DVB. |
Enable/Disable cached inputs .
dasher | the DASH segmenter object |
no_cache | if true, input file will be reopen each time the dasher process function is called . |
Enable/Disable loop inputs .
dasher | the DASH segmenter object |
do_loop | if true, input files will be looped at the end of the file in a live simulation. Otherwise a new period will be created. |
GF_Err gf_dasher_set_split_mode | ( | GF_DASHSegmenter * | dasher, |
GF_DASH_SplitMode | split_mode | ||
) |
Enable/Disable split on bound mode.
dasher | the DASH segmenter object |
split_mode | the desired segmentation mode |
Enable/Disable last segment merging (disabled by default).
dasher | the DASH segmenter object |
merge_last_seg | if true, last segment is merged into previous if duration less than half target dur |
Sets m3u8 file name - if not set, no m3u8 output
dasher | the DASH segmenter object |
insert_clock | if true UTC clock is inserted in variant playlists in live |
Sets cue file for the session.
dasher | the DASH segmenter object |
cues_file | name of the cue file. This is an XML document with root 'DASHCues' element, one or multiple 'Stream' elements with attribute ID (trackID) and timescale (trackTimescale), and a set of 'cues' elements per Stream with attributes sampleNumber, dts or cts. |
strict_cues | if true will fail if one cue doesn't match a timestamp in the stream or if the split sample is not RAP |
GF_Err gf_dasher_add_input | ( | GF_DASHSegmenter * | dasher, |
const GF_DashSegmenterInput * | input | ||
) |
Adds a media input to the DASHer
dasher | the DASH segmenter object |
input | media source to add |
GF_Err gf_dasher_process | ( | GF_DASHSegmenter * | dasher | ) |
Process the media source and generate segments
dasher | the DASH segmenter object |
Returns time to wait until end of currently generated segments
dasher | the DASH segmenter object |
ms_ins_session | if set, retrives the number of ms since the start of the dash session |
void gf_dasher_set_start_date | ( | GF_DASHSegmenter * | dasher, |
const char * | dash_utc_start_date | ||
) |
Sets dasher start date, rather than use current time. Used for debugging purposes, such as simulating long lasting sessions.
dasher | the DASH segmenter object |
dash_utc_start_date | start date as as xs:date, eg YYYY-MM-DDTHH:MM:SSZ. If 0, current time is used |
Sets print flags for filter session
dasher | the DASH segmenter object |
fs_print_flags | flags for statistics (1) and graph (2) printing |
Keeps UTC creation and modification dates from sources, if any (default is no)
dasher | the DASH segmenter object |
keep_utc | if GF_TRUE, keeps UTC times |
GF_Err gf_media_fragment_file | ( | GF_ISOFile * | isom_file, |
const char * | output_file, | ||
Double | max_duration_sec, | ||
Bool | use_mfra | ||
) |
save file as fragmented movie
isom_file | the target file to be fragmented |
output_file | name of the output file |
max_duration_sec | max fragment duration in seconds |
use_mfra | insert track fragment movie fragments |