43 #if CONFIG_HTTP_PROTOCOL 84 int64_t init_start_pos,
pos;
101 char full_path[1024];
102 char temp_path[1024];
115 #if FF_API_DASH_MIN_SEG_DURATION 116 int min_seg_duration;
127 char availability_start_time[100];
183 #if CONFIG_HTTP_PROTOCOL 204 #if CONFIG_HTTP_PROTOCOL 217 if (
formats[i].segment_type == segment_type)
228 default:
return NULL;
237 "Unable to open %s for writing: %s\n", url, errbuf);
258 int has_mp4_streams = 0;
288 if (!filename || !extension)
290 dot = strrchr(filename,
'.');
291 if (dot && !strcmp(dot + 1, extension))
347 if (!strcmp(str,
"mp4a") || !strcmp(str,
"mp4v")) {
356 if (tag ==
MKTAG(
'm',
'p',
'4',
'a')) {
363 }
else if (tag ==
MKTAG(
'm',
'p',
'4',
'v')) {
367 }
else if (!strcmp(str,
"avc1")) {
373 if (extradata[0] != 1) {
385 if (extradata_size >= 4)
387 extradata[1], extradata[2], extradata[3]);
389 }
else if (!strcmp(str,
"av01")) {
399 av_strlcatf(str, size,
".%01u.%01u%01u%01u.%02u.%02u.%02u.%01u",
449 const char *base_url,
int id) {
451 snprintf(playlist_name, string_size,
"%smedia_%d.m3u8", base_url,
id);
453 snprintf(playlist_name, string_size,
"media_%d.m3u8",
id);
457 int *start_index,
int *start_number) {
467 int representation_id,
int final,
468 char *prefetch_url) {
471 char temp_filename_hls[1024];
472 char filename_hls[1024];
474 int target_duration = 0;
477 int use_rename = proto && !strcmp(proto,
"file");
478 int i, start_index, start_number;
488 c->
dirname, representation_id);
490 snprintf(temp_filename_hls,
sizeof(temp_filename_hls), use_rename ?
"%s.tmp" :
"%s", filename_hls);
502 if (target_duration <= duration)
503 target_duration =
lrint(duration);
515 if (prog_date_time == 0) {
524 (
double) seg->
duration / timescale, 0,
527 &prog_date_time, 0, 0, 0);
571 for (i = 0; i < c->
nb_as; i++)
604 int representation_id,
int final)
607 int i, start_index, start_number;
612 avio_printf(out,
"\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale);
616 avio_printf(out,
"availabilityTimeOffset=\"%.3f\" ",
621 int64_t cur_time = 0;
627 if (i == start_index || seg->
time != cur_time) {
628 cur_time = seg->
time;
640 cur_time += (1 + repeat) * seg->
duration;
642 avio_printf(out,
"\t\t\t\t\t</SegmentTimeline>\n");
662 avio_printf(out,
"\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->
file);
666 if (!c->
lhls ||
final) {
673 int outlen = strlen(str)*3/2 + 6;
678 for (; *str; str++) {
679 if (pos + 6 > outlen) {
681 outlen = 2 * outlen + 6;
690 memcpy(&out[pos],
"&", 5);
692 }
else if (*str ==
'<') {
693 memcpy(&out[pos],
"<", 4);
695 }
else if (*str ==
'>') {
696 memcpy(&out[pos],
">", 4);
698 }
else if (*str ==
'\'') {
699 memcpy(&out[pos],
"'", 6);
701 }
else if (*str ==
'\"') {
702 memcpy(&out[pos],
""", 6);
716 int minutes = seconds / 60;
717 int hours = minutes / 60;
723 if (hours || minutes)
730 struct tm *ptm, tmbuf;
732 int64_t time_ms = time_us / 1000;
733 const time_t time_s = time_ms / 1000;
734 int millisec = time_ms - (time_s * 1000);
738 if (!strftime(buf, size,
"%Y-%m-%dT%H:%M:%S", ptm)) {
743 snprintf(buf + len, size - len,
".%03dZ", millisec);
755 avio_printf(out,
"\t\t<AdaptationSet id=\"%s\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
766 avio_printf(out,
"\t\t\t<Role schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->
value);
770 char bandwidth_str[64] = {
'\0'};
772 if (os->
as_idx - 1 != as_index)
776 snprintf(bandwidth_str,
sizeof(bandwidth_str),
" bandwidth=\"%d\"",
781 avio_printf(out,
"\t\t\t<Representation id=\"%d\" mimeType=\"video/%s\" codecs=\"%s\"%s width=\"%d\" height=\"%d\"",
787 avio_printf(out,
"\t\t\t<Representation id=\"%d\" mimeType=\"audio/%s\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n",
789 avio_printf(out,
"\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n",
811 memset(*as, 0,
sizeof(**as));
812 (*as)->media_type =
type;
824 av_log(s,
AV_LOG_ERROR,
"Codec type of stream %d doesn't match AdaptationSet's media type\n", i);
839 enum { new_set, parse_id, parsing_streams }
state;
861 }
else if (state == new_set &&
av_strstart(p,
"id=", &p)) {
873 }
else if (state == parse_id &&
av_strstart(p,
"streams=", &p)) {
874 state = parsing_streams;
875 }
else if (state == parsing_streams) {
877 char idx_str[8], *end_str;
879 n = strcspn(p,
" ,");
880 snprintf(idx_str,
sizeof(idx_str),
"%.*s", n, p);
898 i = strtol(idx_str, &end_str, 10);
899 if (idx_str == end_str || i < 0 || i >= s->
nb_streams) {
938 char temp_filename[1024];
941 int use_rename = proto && !strcmp(proto,
"file");
942 static unsigned int warned_non_file = 0;
946 if (!use_rename && !warned_non_file++)
947 av_log(s,
AV_LOG_ERROR,
"Cannot use rename on non file protocol, this may lead to races and temporary partial files\n");
949 snprintf(temp_filename,
sizeof(temp_filename), use_rename ?
"%s.tmp" :
"%s", s->
url);
957 avio_printf(out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
958 avio_printf(out,
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" 959 "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n" 960 "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" 961 "\txsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd\"\n" 962 "\tprofiles=\"urn:mpeg:dash:profile:isoff-live:2011\"\n" 963 "\ttype=\"%s\"\n",
final ?
"static" :
"dynamic");
965 avio_printf(out,
"\tmediaPresentationDuration=\"");
973 avio_printf(out,
"\tminimumUpdatePeriod=\"PT%"PRId64
"S\"\n", update_period);
979 avio_printf(out,
"\tpublishTime=\"%s\"\n", now_str);
992 avio_printf(out,
"\t\t<Title>%s</Title>\n", escaped);
1005 avio_printf(out,
"\t<Period id=\"0\" start=\"PT0.0S\">\n");
1008 for (i = 0; i < c->
nb_as; i++) {
1015 avio_printf(out,
"\t<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:http-xsdate:2014\" value=\"%s\"/>\n", c->
utc_timing_url);
1027 char filename_hls[1024];
1028 const char *audio_group =
"A1";
1029 char audio_codec_str[128] =
"\0";
1031 int max_audio_bitrate = 0;
1039 snprintf(filename_hls,
sizeof(filename_hls),
"%smaster.m3u8", c->
dirname);
1041 snprintf(filename_hls,
sizeof(filename_hls),
"master.m3u8");
1043 snprintf(temp_filename,
sizeof(temp_filename), use_rename ?
"%s.tmp" :
"%s", filename_hls);
1055 char playlist_file[64];
1064 playlist_file,
NULL, i, is_default);
1068 if (strlen(audio_codec_str))
1069 av_strlcat(audio_codec_str,
",",
sizeof(audio_codec_str));
1076 char playlist_file[64];
1077 char codec_str[128];
1080 char *agroup =
NULL;
1081 char *codec_str_ptr =
NULL;
1088 if (max_audio_bitrate) {
1089 agroup = (
char *)audio_group;
1090 stream_bitrate += max_audio_bitrate;
1091 av_strlcat(codec_str,
",",
sizeof(codec_str));
1092 av_strlcat(codec_str, audio_codec_str,
sizeof(codec_str));
1095 codec_str_ptr = codec_str;
1099 playlist_file, agroup,
1100 codec_str_ptr,
NULL);
1125 char basename[1024];
1133 #if FF_API_DASH_MIN_SEG_DURATION 1134 if (c->min_seg_duration != 5000000) {
1135 av_log(s,
AV_LOG_WARNING,
"The min_seg_duration option is deprecated and will be removed. Please use the -seg_duration\n");
1141 "LHLS is experimental, Please set -strict experimental in order to enable it.\n");
1156 av_log(s,
AV_LOG_WARNING,
"Global SIDX option will be ignored as single_file is not enabled\n");
1166 ptr = strrchr(c->
dirname,
'/');
1168 av_strlcpy(basename, &ptr[1],
sizeof(basename));
1175 ptr = strrchr(basename,
'.');
1195 char filename[1024];
1201 av_log(s, level,
"No bit rate set for stream %d\n",
i);
1231 "One or many segment file names doesn't end with .webm. " 1232 "Override -init_seg_name and/or -media_seg_name and/or " 1233 "-single_file_name to end with the extension .webm\n");
1237 av_log(s,
AV_LOG_WARNING,
"One or more streams in WebM output format. Streaming option will be ignored\n");
1298 av_dict_set(&opts,
"movflags",
"frag_every_frame+dash+delay_moov+skip_sidx+skip_trailer", 0);
1301 av_dict_set(&opts,
"movflags",
"frag_custom+dash+delay_moov+global_sidx+skip_trailer", 0);
1303 av_dict_set(&opts,
"movflags",
"frag_custom+dash+delay_moov+skip_trailer", 0);
1328 if (avg_frame_rate.
num > 0) {
1401 if (seg->
time < 0) {
1439 if (
avio_seek(pb, pos, SEEK_SET) != pos) {
1449 *index_length =
AV_RB32(&buf[0]);
1457 int ret, extradata_size;
1463 if (!extradata_size)
1470 memcpy(par->
extradata, extradata, extradata_size);
1481 if (http_base_proto) {
1507 size_t dirname_len, file_len;
1508 char filename[1024];
1510 dirname_len = strlen(c->
dirname);
1511 if (dirname_len >=
sizeof(filename)) {
1512 av_log(s,
AV_LOG_WARNING,
"Cannot delete segments as the directory path is too long: %"PRIu64
" characters: %s\n",
1513 (uint64_t)dirname_len, c->
dirname);
1517 memcpy(filename, c->
dirname, dirname_len);
1519 file_len = strlen(file);
1520 if ((dirname_len + file_len) >=
sizeof(filename)) {
1521 av_log(s,
AV_LOG_WARNING,
"Cannot delete segments as the path is too long: %"PRIu64
" characters: %s%s\n",
1522 (uint64_t)(dirname_len + file_len), c->
dirname, file);
1526 memcpy(filename + dirname_len, file, file_len + 1);
1534 for (
int i = 0;
i < remove_count; ++
i) {
1551 int use_rename = proto && !strcmp(proto,
"file");
1553 int cur_flush_segment_index = 0, next_exp_index = -1;
1580 if (stream >= 0 && i != stream) {
1638 if (remove_count > 0)
1650 int j, start_index, start_number;
1684 int64_t seg_end_duration, elapsed_duration;
1752 "Segment durations differ too much, enable use_timeline " 1753 "and use_template, or keep a stricter keyframe interval\n");
1786 int use_rename = proto && !strcmp(proto,
"file");
1794 use_rename ?
"%s.tmp" :
"%s", os->
full_path);
1850 char filename[1024];
1858 char filename[1024];
1890 #define OFFSET(x) offsetof(DASHContext, x) 1891 #define E AV_OPT_FLAG_ENCODING_PARAM 1893 {
"adaptation_sets",
"Adaptation sets. Syntax: id=0,streams=0,1,2 id=1,streams=3,4 and so on",
OFFSET(adaptation_sets),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
AV_OPT_FLAG_ENCODING_PARAM },
1894 {
"window_size",
"number of segments kept in the manifest",
OFFSET(window_size),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
E },
1895 {
"extra_window_size",
"number of segments kept outside of the manifest before removing from disk",
OFFSET(extra_window_size),
AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX, E },
1896 #if FF_API_DASH_MIN_SEG_DURATION 1897 {
"min_seg_duration",
"minimum segment duration (in microseconds) (will be deprecated)",
OFFSET(min_seg_duration),
AV_OPT_TYPE_INT, { .i64 = 5000000 }, 0, INT_MAX, E },
1899 {
"seg_duration",
"segment duration (in seconds, fractional value can be set)",
OFFSET(seg_duration),
AV_OPT_TYPE_DURATION, { .i64 = 5000000 }, 0, INT_MAX, E },
1900 {
"remove_at_exit",
"remove all segments when finished",
OFFSET(remove_at_exit),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1901 {
"use_template",
"Use SegmentTemplate instead of SegmentList",
OFFSET(use_template),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
1902 {
"use_timeline",
"Use SegmentTimeline in SegmentTemplate",
OFFSET(use_timeline),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, E },
1903 {
"single_file",
"Store all segments in one file, accessed using byte ranges",
OFFSET(single_file),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1904 {
"single_file_name",
"DASH-templated name to be used for baseURL. Implies storing all segments in one file, accessed using byte ranges",
OFFSET(single_file_name),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, 0, E },
1905 {
"init_seg_name",
"DASH-templated name to used for the initialization segment",
OFFSET(init_seg_name),
AV_OPT_TYPE_STRING, {.str =
"init-stream$RepresentationID$.$ext$"}, 0, 0, E },
1906 {
"media_seg_name",
"DASH-templated name to used for the media segments",
OFFSET(media_seg_name),
AV_OPT_TYPE_STRING, {.str =
"chunk-stream$RepresentationID$-$Number%05d$.$ext$"}, 0, 0, E },
1907 {
"utc_timing_url",
"URL of the page that will return the UTC timestamp in ISO format",
OFFSET(utc_timing_url),
AV_OPT_TYPE_STRING, { 0 }, 0, 0, E },
1910 {
"http_persistent",
"Use persistent HTTP connections",
OFFSET(http_persistent),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
1911 {
"hls_playlist",
"Generate HLS playlist files(master.m3u8, media_%d.m3u8)",
OFFSET(hls_playlist),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1912 {
"streaming",
"Enable/Disable streaming mode of output. Each frame will be moof fragment",
OFFSET(streaming),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1913 {
"timeout",
"set timeout for socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E },
1914 {
"index_correction",
"Enable/Disable segment index correction logic",
OFFSET(index_correction),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1915 {
"format_options",
"set list of options for the container format (mp4/webm) used for dash",
OFFSET(format_options_str),
AV_OPT_TYPE_STRING, {.str =
NULL}, 0, 0, E},
1916 {
"global_sidx",
"Write global SIDX atom. Applicable only for single file, mp4 output, non-streaming mode",
OFFSET(global_sidx),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1921 {
"ignore_io_errors",
"Ignore IO errors during open and write. Useful for long-duration runs with network output",
OFFSET(ignore_io_errors),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1922 {
"lhls",
"Enable Low-latency HLS(Experimental). Adds #EXT-X-PREFETCH tag with current segment's URI",
OFFSET(lhls),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
1923 {
"master_m3u8_publish_rate",
"Publish master playlist every after this many segment intervals",
OFFSET(master_publish_rate),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E},
1937 .extensions =
"mpd",
1948 .priv_class = &dash_class,
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
char * format_options_str
static int dict_copy_entry(AVDictionary **dst, const AVDictionary *src, const char *key)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
static int init_segment_types(AVFormatContext *s)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static void set_http_options(AVDictionary **options, DASHContext *c)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int parse_adaptation_sets(AVFormatContext *s)
static const AVOption options[]
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
const char * media_seg_name
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
const char * single_file_name
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
static av_cold int init(AVCodecContext *avctx)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
uint8_t transfer_characteristics
Convenience header that includes libavutil's core.
static int update_stream_extradata(AVFormatContext *s, OutputStream *os, AVPacket *pkt, AVRational *frame_rate)
int nr_of_streams_to_flush
static void set_codec_str(AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, char *str, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int strict_std_compliance
Allow non-standard and experimental extension.
static int dash_init(AVFormatContext *s)
uint8_t chroma_sample_position
This struct describes the properties of an encoded stream.
int ffurl_shutdown(URLContext *h, int flags)
Signal the URLContext that we are done reading or writing the stream.
int avpriv_io_move(const char *url_src, const char *url_dst)
Move or rename a resource.
static struct codec_string codecs[]
uint8_t chroma_subsampling_x
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int add_segment(OutputStream *os, const char *file, int64_t time, int64_t duration, int64_t start_pos, int64_t range_length, int64_t index_length, int next_exp_index)
static int64_t start_time
AVRational min_frame_rate
miscellaneous OS support macros and functions.
const AVCodecTag ff_codec_movvideo_tags[]
static int add_adaptation_set(AVFormatContext *s, AdaptationSet **as, enum AVMediaType type)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void get_start_index_number(OutputStream *os, DASHContext *c, int *start_index, int *start_number)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
static void dashenc_delete_media_segments(AVFormatContext *s, OutputStream *os, int remove_count)
#define AV_LOG_VERBOSE
Detailed information.
static int dashenc_delete_segment_file(AVFormatContext *s, const char *file)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
uint64_t availability_start_time
static void format_date_now(char *buf, int size)
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup, char *filename, char *language, int name_id, int is_default)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static void get_hls_playlist_name(char *playlist_name, int string_size, const char *base_url, int id)
static void write_time(AVIOContext *out, int64_t time)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int write_manifest(AVFormatContext *s, int final)
#define i(width, name, range_min, range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
const char * init_seg_name
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
char * url
input or output URL.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
enum AVMediaType codec_type
General type of the encoded data.
simple assert() macros that are a bit more flexible than ISO C assert().
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
static int dash_check_bitstream(struct AVFormatContext *s, const AVPacket *avpkt)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int flush_init_segment(AVFormatContext *s, OutputStream *os)
static SegmentType select_segment_type(SegmentType segment_type, enum AVCodecID codec_id)
double availability_time_offset
AVRational avg_frame_rate
Average framerate.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
const AVCodecTag ff_mp4_obj_type[]
static void dashenc_delete_file(AVFormatContext *s, char *filename)
int flags
A combination of AV_PKT_FLAG values.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
int extradata_size
Size of the extradata content in bytes.
AVOutputFormat ff_dash_muxer
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVBSFContext ** bsfcs
bitstream filters to run on stream
const char * media_seg_name
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
#define AV_TIME_BASE
Internal time base represented as integer.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
static int write_trailer(AVFormatContext *s1)
void ff_hls_write_playlist_header(AVIOContext *out, int version, int allowcache, int target_duration, int64_t sequence, uint32_t playlist_type, int iframe_mode)
int master_playlist_created
enum AVMediaType media_type
int avoid_negative_ts
Avoid negative timestamps during muxing.
uint8_t color_description_present_flag
static void set_vp9_codec_str(AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, char *str, int size)
Usually treated as AVMEDIA_TYPE_DATA.
av_warn_unused_result int avformat_init_output(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and initialize the codec, but do not write the header.
#define AV_ERROR_MAX_STRING_SIZE
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it...
ff_const59 struct AVOutputFormat * oformat
The output container format.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int64_t av_gettime(void)
Get the current time in microseconds.
static int flush_dynbuf(DASHContext *c, OutputStream *os, int *range_length)
void ff_dash_fill_tmpl_params(char *dst, size_t buffer_size, const char *template, int rep_id, int number, int bit_rate, int64_t time)
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
void ff_hls_write_playlist_version(AVIOContext *out, int version)
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
char * av_strdup(const char *s)
Duplicate a string.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
const AVCodecTag ff_codec_movaudio_tags[]
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int ff_hls_write_file_entry(AVIOContext *out, int insert_discont, int byterange_mode, double duration, int round_duration, int64_t size, int64_t pos, char *baseurl, char *filename, double *prog_date_time, int64_t video_keyframe_size, int64_t video_keyframe_pos, int iframe_mode)
AVIOContext * pb
I/O context.
AVRational max_frame_rate
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
const char * init_seg_name
ff_const59 AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
Rational number (pair of numerator and denominator).
static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_index, int final)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static const char * get_format_str(SegmentType segment_type)
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
static int adaptation_set_add_stream(AVFormatContext *s, int as_idx, int i)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static void find_index_range(AVFormatContext *s, const char *full_path, int64_t pos, int *index_length)
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
static const char * get_extension_str(SegmentType type, int single_file)
static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, AVDictionary **options)
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
#define flags(name, subs,...)
void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, char *filename, char *agroup, char *codecs, char *ccgroup)
int ff_http_do_new_request(URLContext *h, const char *uri)
Send a new HTTP request, reusing the old connection.
SegmentType segment_type_option
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
int sample_rate
Audio only.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
char * av_strnstr(const char *haystack, const char *needle, size_t hay_length)
Locate the first occurrence of the string needle in the string haystack where not more than hay_lengt...
int ff_isom_get_vpcc_features(AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, VPCC *vpcc)
Utilties for rational number calculation.
const char * single_file_name
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
void ff_hls_write_init_file(AVIOContext *out, char *filename, int byterange_mode, int64_t size, int64_t pos)
uint8_t chroma_subsampling_y
int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int size)
Parses a Sequence Header from the the provided buffer.
static int handle_io_open_error(AVFormatContext *s, int err, char *url)
static void write_styp(AVIOContext *pb)
static int dash_write_header(AVFormatContext *s)
int nr_of_streams_flushed
static int check_file_extension(const char *filename, const char *extension)
void * priv_data
Format private data.
const char * utc_timing_url
static int dash_write_trailer(AVFormatContext *s)
static void write_header(FFV1Context *f)
static void dash_free(AVFormatContext *s)
static void write_hls_media_playlist(OutputStream *os, AVFormatContext *s, int representation_id, int final, char *prefetch_url)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int avpriv_io_delete(const char *url)
Delete a resource.
void ff_hls_write_end_list(AVIOContext *out)
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
void avio_wb32(AVIOContext *s, unsigned int val)
static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatContext *s, int representation_id, int final)
const char * extension_name
internal header for VPx codec configuration utilities.
uint8_t matrix_coefficients
unbuffered private I/O API
#define AVERROR_MUXER_NOT_FOUND
Muxer not found.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static char * xmlescape(const char *str)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static int dash_flush(AVFormatContext *s, int final, int stream)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
static const AVClass dash_class
#define AV_NOPTS_VALUE
Undefined timestamp value.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.