139 int64_t target_duration = 0;
142 char temp_filename[1024];
145 snprintf(temp_filename,
sizeof(temp_filename),
"%s.tmp", s->
filename);
149 for (en = hls->
list; en; en = en->
next) {
159 avio_printf(out,
"#EXT-X-TARGETDURATION:%"PRId64
"\n",
162 avio_printf(out,
"#EXT-X-MEDIA-SEQUENCE:%"PRId64
"\n", sequence);
167 for (en = hls->
list; en; en = en->
next) {
214 const char *pattern =
"%d.ts";
215 int basename_size = strlen(s->
filename) + strlen(pattern) + 1;
227 "More than a single video stream present, " 228 "expect issues decoding it.\n");
279 int ret, can_split = 1;
295 if (can_split && pts - hls->
start_pts >= end_pts) {
338 #define OFFSET(x) offsetof(HLSContext, x) 339 #define E AV_OPT_FLAG_ENCODING_PARAM 345 {
"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},
362 .extensions =
"m3u8",
370 .priv_class = &hls_class,
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static int hls_write_trailer(struct AVFormatContext *s)
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define AVIO_FLAG_WRITE
write-only
static int hls_window(AVFormatContext *s, int last)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
const char * av_basename(const char *path)
Thread safe basename.
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.
#define AV_LOG_VERBOSE
Detailed information.
static int append_entry(HLSContext *hls, int64_t duration)
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static const AVOption options[]
static int hls_write_header(AVFormatContext *s)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVMediaType codec_type
General type of the encoded data.
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.
int flags
A combination of AV_PKT_FLAG values.
void * opaque
Arbitrary user data set by the caller.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static void free_entries(HLSContext *hls)
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
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...
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
if(ac->has_optimized_func)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
AVIOContext * pb
I/O context.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
Describe the class of an AVClass context structure.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
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 int64_t pts
Global timestamp for the audio frames.
static int hls_mux_init(AVFormatContext *s)
static int hls_start(AVFormatContext *s)
void * priv_data
Format private data.
static const uint8_t start_sequence[]
static void write_header(FFV1Context *f)
AVOutputFormat ff_hls_muxer
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
#define AVERROR_MUXER_NOT_FOUND
Muxer not found.
AVCodecParameters * codecpar
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static const AVClass hls_class
This structure stores compressed data.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2