Go to the documentation of this file.
24 #include "config_components.h"
47 #if CONFIG_HTTP_PROTOCOL
70 #define LINE_BUFFER_SIZE MAX_URL_SIZE
71 #define HLS_MICROSECOND_UNIT 1000000
72 #define BUFSIZE (16 * 1024)
73 #define POSTFIX_PATTERN "_%d"
270 struct tm *tm, tmpbuf;
297 #if CONFIG_HTTP_PROTOCOL
319 #if CONFIG_HTTP_PROTOCOL
336 }
else if (http_base_proto) {
341 if (
c->http_persistent)
369 "%s%s", codec_strlen ?
"," :
"", attr);
395 if (
c ==
'%' && *(
p+1) ==
'%')
397 else if (
c ==
'%' && *(
p+1) == placeholder) {
405 if (addchar_count > 0) {
423 int nd, addchar_count;
435 if (
c ==
'%' && *(
p+1) ==
'%')
437 else if (
c ==
'%' && (
av_isdigit(*(
p+1)) || *(
p+1) == placeholder)) {
441 nd = nd * 10 + *(
p + addchar_count) -
'0';
445 if (*(
p + addchar_count) == placeholder) {
446 av_bprintf(&buf,
"%0*"PRId64, (number < 0) ? nd : nd++, number);
447 p += (addchar_count + 1);
505 char *path,
const char *proto)
521 }
else if (unlink(path) < 0) {
523 path, strerror(errno));
533 float playlist_duration = 0.0f;
537 const char *dirname =
NULL;
538 char *dirname_r =
NULL;
539 char *dirname_repl =
NULL;
540 const char *vtt_dirname =
NULL;
541 char *vtt_dirname_r =
NULL;
542 const char *proto =
NULL;
559 if (playlist_duration <= -previous_segment->
duration) {
589 dirname = dirname_repl;
608 if ((
segment->sub_filename[0] !=
'\0')) {
647 len = strlen(key_basename_source) + 4 + 1;
664 uint8_t iv[16] = { 0 };
670 memcpy(iv, hls->
iv,
sizeof(iv));
777 int remaining_options;
838 av_log(
s,
AV_LOG_WARNING,
"http persistent mode is currently unsupported for fragment mp4 in the HLS muxer.\n");
851 if (byterange_mode) {
879 if (remaining_options) {
909 char *filename =
NULL;
912 "Invalid second level segment filename template '%s', "
913 "you can try to remove second_level_segment_size flag\n",
921 char *filename =
NULL;
925 "Invalid second level segment filename template '%s', "
926 "you can try to remove second_level_segment_duration flag\n",
943 "second_level_segment_duration hls_flag requires strftime to be true\n");
948 "second_level_segment_size hls_flag requires strfime to be true\n");
953 "second_level_segment_index hls_flag requires strftime to be true\n");
963 int segment_renaming_ok = proto && !strcmp(proto,
"file");
968 "second_level_segment_duration hls_flag works only with file protocol segment names\n");
973 "second_level_segment_size hls_flag works only with file protocol segment names\n");
990 char *filename =
NULL;
994 "you can try to remove second_level_segment_index flag\n",
1005 char *filename =
NULL;
1008 "you can try to remove second_level_segment_size flag\n",
1016 char *filename =
NULL;
1019 "you can try to remove second_level_segment_duration flag\n",
1036 const char *filename;
1068 && !byterange_mode) {
1133 const char *dot = strrchr(filename,
'.');
1134 const char *num_start = dot - 1;
1136 while (num_start > filename && *num_start >=
'0' && *num_start <=
'9') {
1142 if (num_start == dot)
1145 return atoi(num_start);
1152 int ret = 0, is_segment = 0;
1157 double discont_program_date_time = 0;
1160 &
s->interrupt_callback,
NULL,
1161 s->protocol_whitelist,
s->protocol_blacklist)) < 0)
1165 if (strcmp(
line,
"#EXTM3U")) {
1175 if (tmp_sequence < vs->sequence)
1177 "Found playlist sequence number was smaller """
1178 "than specified start sequence number: %"PRId64
" < %"PRId64
", "
1181 av_log(hls,
AV_LOG_DEBUG,
"Found playlist sequence number: %"PRId64
"\n", tmp_sequence);
1193 ptr += strlen(
"URI=\"");
1204 ptr += strlen(
"IV=0x");
1213 struct tm program_date_time;
1216 if (sscanf(ptr,
"%d-%d-%dT%d:%d:%d.%lf", &y, &
M, &d, &
h, &m, &
s, &ms) != 7) {
1221 program_date_time.tm_year = y - 1900;
1222 program_date_time.tm_mon =
M - 1;
1223 program_date_time.tm_mday = d;
1224 program_date_time.tm_hour =
h;
1225 program_date_time.tm_min = m;
1226 program_date_time.tm_sec =
s;
1227 program_date_time.tm_isdst = -1;
1229 discont_program_date_time = mktime(&program_date_time);
1230 discont_program_date_time += (
double)(ms / 1000);
1233 }
else if (
line[0]) {
1245 int len = strlen(vtt_basename) + 11;
1259 if (discont_program_date_time) {
1261 discont_program_date_time += vs->
duration;
1288 size_t len = strlen(oc->
url);
1292 if (!final_filename)
1294 final_filename[
len-4] =
'\0';
1303 const char *
p = strrchr(master_url,
'/');
1304 size_t base_len = 0;
1306 if (!
p)
p = strrchr(master_url,
'\\');
1309 base_len =
p - master_url;
1318 return media_url + base_len + 1;
1347 int ret, bandwidth, avg_bandwidth;
1348 const char *m3u8_rel_name =
NULL;
1349 const char *vtt_m3u8_rel_name =
NULL;
1350 const char *ccgroup;
1351 const char *sgroup =
NULL;
1354 int is_file_proto = proto && !strcmp(proto,
"file");
1402 if (!m3u8_rel_name) {
1420 if (!m3u8_rel_name) {
1434 if (!vid_st && !aud_st) {
1467 bandwidth += bandwidth / 10;
1485 if (vid_st && vs->
sgroup) {
1488 if (!vtt_m3u8_rel_name) {
1521 int target_duration = 0;
1527 int is_file_proto = proto && !strcmp(proto,
"file");
1529 static unsigned warned_non_file;
1530 char *key_uri =
NULL;
1531 char *iv_string =
NULL;
1542 if (byterange_mode) {
1560 av_log(
s,
AV_LOG_ERROR,
"Cannot use rename on non file protocol, this may lead to races and temporary partial files\n");
1563 snprintf(temp_filename,
sizeof(temp_filename), use_temp_file ?
"%s.tmp" :
"%s", vs->
m3u8_name);
1571 if (target_duration <= en->
duration)
1620 snprintf(temp_vtt_filename,
sizeof(temp_vtt_filename), use_temp_file ?
"%s.tmp" :
"%s", vs->
vtt_m3u8_name);
1649 if (use_temp_file) {
1667 const char *proto =
NULL;
1668 int use_temp_file = 0;
1669 char iv_string[
KEYSIZE*2 + 1];
1683 }
else if (
c->max_seg_size > 0) {
1684 char *filename =
NULL;
1693 if (
c->use_localtime) {
1695 char *expanded =
NULL;
1709 if (
c->use_localtime_mkdir) {
1715 if (
ff_mkdir_p(dir) == -1 && errno != EEXIST) {
1716 av_log(oc,
AV_LOG_ERROR,
"Could not create directory %s with use_localtime_mkdir\n", dir);
1723 char *filename =
NULL;
1733 char *filename =
NULL;
1745 use_temp_file = proto && !strcmp(proto,
"file") && (
c->flags &
HLS_TEMP_FILE);
1747 if (use_temp_file) {
1754 if (
c->key_info_file ||
c->encrypt) {
1760 if (
c->key_info_file &&
c->encrypt) {
1762 " ignoring -hls_enc\n");
1766 if (
c->key_info_file) {
1770 if (!
c->encrypt_started) {
1773 c->encrypt_started = 1;
1785 memcpy(vs->
iv_string, iv_string,
sizeof(iv_string));
1793 if (
c->key_info_file ||
c->encrypt) {
1810 if (
c->ignore_io_errors)
1816 if (
c->ignore_io_errors)
1826 if (
c->ignore_io_errors)
1849 #if HAVE_LIBC_MSVCRT
1852 int strftime_s_supported = 0;
1855 time_t t = time(
NULL);
1858 int strftime_s_supported = strftime(
b,
sizeof(
b),
"%s",
p) && strcmp(
b,
"%s");
1862 return strftime_s_supported ?
"-%s.m4s" :
"-%Y%m%d%H%M%S.m4s";
1864 return strftime_s_supported ?
"-%s.ts" :
"-%Y%m%d%H%M%S.ts";
1870 char extension[10] = {
'\0'};
1872 p = strrchr(
name,
'.');
1880 if (strlen(extension))
1888 const char *filename, *subdir_name;
1889 char *fn_dup =
NULL;
1903 "either in the filename or in the sub-directory name of file %s\n",
fn);
1910 "in the sub-directory name of file %s, but only in one of them\n",
fn);
1922 const char *proto, *dir;
1923 char *orig_buf_dup =
NULL, *mod_buf_dup =
NULL;
1951 if (
av_stristr(dir,
"%v") && proto && !strcmp(proto,
"file")) {
1954 if (
ff_mkdir_p(dir) == -1 && errno != EEXIST) {
1970 unsigned int stream_index, cnt;
1971 if (stream_id < 0 || stream_id >
s->nb_streams - 1)
1974 for (stream_index = 0; stream_index <
s->nb_streams; stream_index++) {
1975 if (
s->streams[stream_index]->codecpar->codec_type !=
codec_type)
1977 if (cnt == stream_id)
1978 return stream_index;
1988 int stream_index,
i, j;
1991 char *
p, *q, *saveptr1, *saveptr2, *varstr, *keyval;
2014 while (
av_strtok(q,
" \t", &saveptr1)) {
2027 while (varstr =
av_strtok(
p,
" \t", &saveptr1)) {
2030 if (nb_varstreams < hls->nb_varstreams) {
2053 while (keyval =
av_strtok(varstr,
",", &saveptr2)) {
2092 num = strtoll(
val, &end, 10);
2099 if (stream_index >= 0 && nb_streams < vs->
nb_streams) {
2101 if (vs->
streams[
i] ==
s->streams[stream_index]) {
2103 "variant definition #%d\n", nb_varstreams - 1);
2107 for (j = 0; nb_varstreams > 1 && j < nb_varstreams - 1; j++) {
2111 "in two different variant definitions #%d and #%d\n",
2112 j, nb_varstreams - 1);
2133 int nb_ccstreams = 0;
2134 char *
p, *q, *ccstr, *keyval;
2135 char *saveptr1 =
NULL, *saveptr2 =
NULL;
2144 while (
av_strtok(q,
" \t", &saveptr1)) {
2157 while (ccstr =
av_strtok(
p,
" \t", &saveptr1)) {
2160 if (nb_ccstreams < hls->nb_ccstreams)
2165 while (keyval =
av_strtok(ccstr,
",", &saveptr2)) {
2186 if (atoi(
val) < 1 || atoi(
val) > 4) {
2192 if (atoi(
val) < 1 || atoi(
val) > 63) {
2239 for (
i = 0;
i <
s->nb_streams;
i++)
2270 if (dir && strcmp(dir,
"."))
2294 int subtitle_streams = 0;
2309 "(%"PRId64
" > %"PRId64
"), the result maybe not be what you want.",
2315 inner_st = vs->
avf->
streams[j - subtitle_streams];
2370 char *filename =
NULL;
2384 if (read_byte > 0) {
2386 total_size += read_byte;
2389 }
while (read_byte > 0);
2404 int stream_index = 0;
2405 int range_length = 0;
2406 const char *proto =
NULL;
2407 int use_temp_file = 0;
2409 char *old_filename =
NULL;
2412 int subtitle_streams = 0;
2424 stream_index = j - subtitle_streams;
2446 end_pts = init_list_dur + after_init_list_dur ;
2479 av_log(
s,
AV_LOG_WARNING,
"Stream %d packet with pts %" PRId64
" has duration 0. The segment duration may not be precise.\n",
2491 double cur_duration;
2500 if (range_length <= 0)
2509 if (!byterange_mode) {
2514 if (!byterange_mode) {
2526 vs->
size = range_length;
2532 use_temp_file = proto && !strcmp(proto,
"file")
2538 char *filename =
NULL;
2560 "Failed to open file '%s'\n", filename);
2574 vs->
size = range_length;
2578 " will retry with a new http session.\n");
2599 if (!old_filename) {
2718 char *old_filename =
NULL;
2719 const char *proto =
NULL;
2720 int use_temp_file = 0;
2725 int range_length, byterange_mode;
2728 char *filename =
NULL;
2735 if (!old_filename) {
2752 int range_length = 0;
2765 if (!byterange_mode) {
2785 vs->
size = range_length;
2822 if (!old_filename) {
2859 const char *pattern;
2865 double initial_program_date_time =
av_gettime() / 1000000.0;
2884 if (!hls->
method && http_base_proto) {
2922 time_t t = time(
NULL);
2929 struct tm *
p, tmbuf;
2932 if (!strftime(
b,
sizeof(
b),
"%Y%m%d%H%M%S",
p))
2945 "'split_by_time' and 'independent_segments' cannot be "
2946 "enabled together. Disabling 'independent_segments' flag\n");
3011 fmp4_init_filename_len);
3026 char *expanded =
NULL;
3090 " hls_init_time value will have no effect\n");
3104 #define OFFSET(x) offsetof(HLSContext, x)
3105 #define E AV_OPT_FLAG_ENCODING_PARAM
3110 {
"hls_list_size",
"set maximum number of playlist entries",
OFFSET(max_nb_segments),
AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX,
E},
3111 {
"hls_delete_threshold",
"set number of unreferenced segments to keep before deleting",
OFFSET(hls_delete_threshold),
AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX,
E},
3112 {
"hls_vtt_options",
"set hls vtt list of options for the container format used for hls",
OFFSET(vtt_format_options_str),
AV_OPT_TYPE_STRING, {.str =
NULL}, 0, 0,
E},
3113 {
"hls_allow_cache",
"explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments",
OFFSET(allowcache),
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX,
E},
3116 {
"hls_segment_options",
"set segments files format options of hls",
OFFSET(format_options),
AV_OPT_TYPE_DICT, {.str =
NULL}, 0, 0,
E},
3117 {
"hls_segment_size",
"maximum size per segment file, (in bytes)",
OFFSET(max_seg_size),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E},
3127 {
"hls_fmp4_init_filename",
"set fragment mp4 file init filename",
OFFSET(fmp4_init_filename),
AV_OPT_TYPE_STRING, {.str =
"init.mp4"}, 0, 0,
E},
3128 {
"hls_fmp4_init_resend",
"resend fragment mp4 init file after refresh m3u8 every time",
OFFSET(resend_init_file),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3129 {
"hls_flags",
"set flags affecting HLS playlist and media file generation",
OFFSET(
flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX,
E, .unit =
"flags"},
3131 {
"temp_file",
"write segment and playlist to temporary file and rename when complete", 0,
AV_OPT_TYPE_CONST, {.i64 =
HLS_TEMP_FILE }, 0, UINT_MAX,
E, .unit =
"flags"},
3143 {
"independent_segments",
"add EXT-X-INDEPENDENT-SEGMENTS, whenever applicable", 0,
AV_OPT_TYPE_CONST, { .i64 =
HLS_INDEPENDENT_SEGMENTS }, 0, UINT_MAX,
E, .unit =
"flags"},
3144 {
"iframes_only",
"add EXT-X-I-FRAMES-ONLY, whenever applicable", 0,
AV_OPT_TYPE_CONST, { .i64 =
HLS_I_FRAMES_ONLY }, 0, UINT_MAX,
E, .unit =
"flags"},
3145 {
"strftime",
"set filename expansion with strftime at segment creation",
OFFSET(use_localtime),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3146 {
"strftime_mkdir",
"create last directory component in strftime-generated filename",
OFFSET(use_localtime_mkdir),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3160 {
"master_pl_publish_rate",
"Publish master play list every after this many segment intervals",
OFFSET(master_publish_rate),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX,
E},
3161 {
"http_persistent",
"Use persistent HTTP connections",
OFFSET(http_persistent),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3162 {
"timeout",
"set timeout for socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags =
E },
3163 {
"ignore_io_errors",
"Ignore IO errors for stable long-duration runs with network output",
OFFSET(ignore_io_errors),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
E },
3179 .p.extensions =
"m3u8",
int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
Same as ff_get_line but strip the white-space characters in the text tail.
AVFormatContext * vtt_avf
static int hls_write_header(AVFormatContext *s)
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
static const char * get_relative_url(const char *master_url, const char *media_url)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static HLSSegment * find_segment_by_filename(HLSSegment *segment, const char *filename)
static int append_postfix(char *name, int name_buf_len, int i)
static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, VariantStream *vs)
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int strftime_expand(const char *fmt, char **dest)
enum AVMediaType codec_type
General type of the encoded data.
int resend_init_file
resend init file into disk after refresh m3u8
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.
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
char key_file[LINE_BUFFER_SIZE+1]
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void ff_hls_write_end_list(AVIOContext *out)
static int hls_init_file_resend(AVFormatContext *s, VariantStream *vs)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
char filename[MAX_URL_SIZE]
#define AVERROR_EOF
End of file.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
char key_uri[LINE_BUFFER_SIZE+1]
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_asprintf(const char *fmt,...)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static void write_styp(AVIOContext *pb)
AVStream ** streams
A list of all streams in the file.
static void deinit(AVFormatContext *s)
static int create_master_playlist(AVFormatContext *s, VariantStream *const input_vs, int final)
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
@ HLS_SECOND_LEVEL_SEGMENT_INDEX
int strict_std_compliance
Allow non-standard and experimental extension.
#define HLS_MICROSECOND_UNIT
@ HLS_START_SEQUENCE_AS_MICROSECONDS_SINCE_EPOCH
AVRational avg_frame_rate
Average framerate.
@ HLS_INDEPENDENT_SEGMENTS
char iv_string[KEYSIZE *2+1]
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
#define AV_DICT_APPEND
If the entry already exists, append to it.
#define AV_LOG_VERBOSE
Detailed information.
unsigned int nb_ccstreams
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
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.
static int extract_segment_number(const char *filename)
static int hls_write_trailer(struct AVFormatContext *s)
static int get_nth_codec_stream_index(AVFormatContext *s, enum AVMediaType codec_type, int64_t stream_id)
int nb_channels
Number of channels in this layout.
enum AVMediaType codec_type
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int update_variant_stream_info(AVFormatContext *s)
const char * av_basename(const char *path)
Thread safe basename.
static int sls_flag_check_duration_size(HLSContext *hls, VariantStream *vs)
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
char key_file[LINE_BUFFER_SIZE+1]
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static int do_encrypt(AVFormatContext *s, VariantStream *vs)
int use_localtime
flag to expand filename with localtime
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)
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
const FFOutputFormat ff_hls_muxer
static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls, VariantStream *vs, HLSSegment *en, double duration, int64_t pos, int64_t size)
static int hls_start(AVFormatContext *s, VariantStream *vs)
static int hls_delete_file(HLSContext *hls, AVFormatContext *avf, char *path, const char *proto)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static double val(void *priv, double ch)
const AVOutputFormat * oformat
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int ff_rename(const char *url_src, const char *url_dst, void *logctx)
Wrap ffurl_move() and log if error happens.
const char * av_dirname(char *path)
Thread safe dirname.
static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char *old_filename)
int use_localtime_mkdir
flag to mkdir dirname in timebased filename
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
static int64_t get_stream_bit_rate(AVStream *stream)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static int validate_name(int nb_vs, const char *fn)
static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)
@ CODEC_ATTRIBUTE_WRITTEN
const AVOutputFormat * vtt_oformat
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static int flush_dynbuf(VariantStream *vs, int *range_length)
static void hls_deinit(AVFormatContext *s)
@ HLS_SECOND_LEVEL_SEGMENT_SIZE
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AVIO_FLAG_WRITE
write-only
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
char key_string[KEYSIZE *2+1]
int nb_coded_side_data
Amount of entries in coded_side_data.
This structure describes the bitrate properties of an encoded bitstream.
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.
CodecAttributeStatus attr_status
int reference_stream_index
char * base_output_dirname
static void write_codec_attr(AVStream *st, VariantStream *vs)
int ff_http_do_new_request(URLContext *h, const char *uri)
Send a new HTTP request, reusing the old connection.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int64_t video_keyframe_pos
void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, const char *sname, int name_id, int is_default)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int replace_str_data_in_filename(char **s, const char *filename, char placeholder, const char *datastring)
Describe the class of an AVClass context structure.
static void reflush_dynbuf(VariantStream *vs, int *range_length)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int write_trailer(AVFormatContext *s1)
const char * subtitle_varname
char sub_filename[MAX_URL_SIZE]
char iv_string[KEYSIZE *2+1]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without period
char key_uri[LINE_BUFFER_SIZE+1]
char * vtt_format_options_str
AVIOContext * http_delete
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
const char * av_default_item_name(void *ptr)
Return the context name.
int ffurl_shutdown(URLContext *h, int flags)
Signal the URLContext that we are done reading or writing the stream.
AVIOContext * pb
I/O context.
@ HLS_START_SEQUENCE_LAST
static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, const char *filename, AVDictionary **options)
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
AVDictionary * vtt_format_options
AVChannelLayout ch_layout
Audio only.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ HLS_START_SEQUENCE_AS_START_NUMBER
HLSSegment * old_segments
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
double initial_prog_date_time
static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, VariantStream *vs, double duration, int64_t pos, int64_t size)
void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, int avg_bandwidth, const char *filename, const char *agroup, const char *codecs, const char *ccgroup, const char *sgroup)
ClosedCaptionsStream * cc_streams
void ff_hls_write_playlist_version(AVIOContext *out, int version)
int(* init)(AVBSFContext *ctx)
static int hls_rename_temp_file(AVFormatContext *s, AVFormatContext *oc)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
#define FF_OFMT_FLAG_ALLOW_FLUSH
This flag indicates that the muxer stores data internally and supports flushing it.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
uint32_t start_sequence_source_type
char * url
input or output URL.
#define AV_NOPTS_VALUE
Undefined timestamp value.
@ CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN
void ff_hls_write_init_file(AVIOContext *out, const char *filename, int byterange_mode, int64_t size, int64_t pos)
double discont_program_date_time
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int parse_variant_stream_mapstring(AVFormatContext *s)
static int hls_init(AVFormatContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
int flags
A combination of AV_PKT_FLAG values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
AVDictionary * format_options
int64_t video_keyframe_size
@ HLS_START_SEQUENCE_AS_FORMATTED_DATETIME
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs)
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
int ff_make_codec_str(void *logctx, const AVCodecParameters *par, const AVRational *frame_rate, struct AVBPrint *out)
Make a RFC 4281/6381 like string describing a codec.
HLSSegment * last_segment
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, const char *filename, const char *language, int name_id, int is_default, int nb_channels)
char iv_string[KEYSIZE *2+1]
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static av_always_inline av_const double round(double x)
#define AVERROR_MUXER_NOT_FOUND
Muxer not found.
char key_string[KEYSIZE *2+1]
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
AVIOContext * sub_m3u8_out
static int hls_encryption_start(AVFormatContext *s, VariantStream *vs)
static const AVOption options[]
static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename)
int av_random_bytes(uint8_t *buf, size_t len)
Generate cryptographically secure random data, i.e.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
static const uint8_t start_sequence[]
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
char * fmp4_init_filename
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int id
Format-specific stream ID.
AVIOContext * out_single_file
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, const char *baseurl, const char *filename, double *prog_date_time, int64_t video_keyframe_size, int64_t video_keyframe_pos, int iframe_mode)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
char * fmp4_init_filename
const struct AVOutputFormat * oformat
The output container format.
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 int replace_int_data_in_filename(char **s, const char *filename, char placeholder, int64_t number)
static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, VariantStream *vs)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
Writes a formatted string to the context.
char current_segment_final_filename_fmt[MAX_URL_SIZE]
int index
stream index in AVFormatContext
static void can_split(const VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit *split)
static int format_name(const char *buf, char **s, int index, const char *varname)
static const char * get_default_pattern_localtime_fmt(AVFormatContext *s)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
@ AV_OPT_TYPE_INT
Underlying C type is int.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int update_master_pl_info(AVFormatContext *s)
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
static int sls_flag_check_duration_size_index(HLSContext *hls)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t av_gettime(void)
Get the current time in microseconds.
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.
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
const 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...
unsigned int nb_varstreams
VariantStream * var_streams
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets fate list failing List the fate tests that failed the last time they were executed fate clear reports Remove the test reports from previous test libraries and programs examples Build all examples located in doc examples checkheaders Check headers dependencies alltools Build all tools in tools directory config Reconfigure the project with the current configuration tools target_dec_< decoder > _fuzzer Build fuzzer to fuzz the specified decoder tools target_bsf_< filter > _fuzzer Build fuzzer to fuzz the specified bitstream filter Useful standard make this is useful to reduce unneeded rebuilding when changing headers
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static void hls_free_segments(HLSSegment *p)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int(* io_close2)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
static int64_t append_single_file(AVFormatContext *s, VariantStream *vs)
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
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.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static void write_header(FFV1Context *f)
char key_uri[LINE_BUFFER_SIZE+1]
int pts_wrap_bits
Number of bits in timestamps.
@ HLS_SECOND_LEVEL_SEGMENT_DURATION
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
void * priv_data
Format private data.
static int parse_cc_stream_mapstring(AVFormatContext *s)
unsigned int master_publish_rate
@ HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
static const AVClass hls_class
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.