MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / hls_write_header

Function hls_write_header

libavformat/hlsenc.c:2286–2345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2284}
2285
2286static int hls_write_header(AVFormatContext *s)
2287{
2288 HLSContext *hls = s->priv_data;
2289 int ret, i, j;
2290 VariantStream *vs = NULL;
2291
2292 for (i = 0; i < hls->nb_varstreams; i++) {
2293 int subtitle_streams = 0;
2294 vs = &hls->var_streams[i];
2295
2296 ret = avformat_write_header(vs->avf, NULL);
2297 if (ret < 0)
2298 return ret;
2299 //av_assert0(s->nb_streams == hls->avf->nb_streams);
2300 for (j = 0; j < vs->nb_streams; j++) {
2301 AVStream *inner_st;
2302 AVStream *outer_st = vs->streams[j];
2303
2304 if (hls->max_seg_size > 0) {
2305 if ((outer_st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
2306 (outer_st->codecpar->bit_rate > hls->max_seg_size)) {
2307 av_log(s, AV_LOG_WARNING, "Your video bitrate is bigger than hls_segment_size, "
2308 "(%"PRId64 " > %"PRId64 "), the result maybe not be what you want.",
2309 outer_st->codecpar->bit_rate, hls->max_seg_size);
2310 }
2311 }
2312
2313 if (outer_st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
2314 inner_st = vs->avf->streams[j - subtitle_streams];
2315 else if (vs->vtt_avf) {
2316 inner_st = vs->vtt_avf->streams[0];
2317 subtitle_streams++;
2318 } else {
2319 /* We have a subtitle stream, when the user does not want one */
2320 inner_st = NULL;
2321 continue;
2322 }
2323 avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, inner_st->time_base.num, inner_st->time_base.den);
2324 if (outer_st->codecpar->codec_id == AV_CODEC_ID_HEVC &&
2325 outer_st->codecpar->codec_tag != MKTAG('h','v','c','1')) {
2326 av_log(s, AV_LOG_WARNING, "Stream HEVC is not hvc1, you should use tag:v hvc1 to set it.\n");
2327 }
2328 write_codec_attr(outer_st, vs);
2329
2330 }
2331 /* Update the Codec Attr string for the mapped audio groups */
2332 if (vs->has_video && vs->agroup) {
2333 for (j = 0; j < hls->nb_varstreams; j++) {
2334 VariantStream *vs_agroup = &(hls->var_streams[j]);
2335 if (!vs_agroup->has_video && !vs_agroup->has_subtitle &&
2336 vs_agroup->agroup &&
2337 !av_strcasecmp(vs_agroup->agroup, vs->agroup)) {
2338 write_codec_attr(vs_agroup->streams[0], vs);
2339 }
2340 }
2341 }
2342 }
2343

Callers

nothing calls this directly

Calls 5

avformat_write_headerFunction · 0.85
av_logFunction · 0.85
avpriv_set_pts_infoFunction · 0.85
write_codec_attrFunction · 0.85
av_strcasecmpFunction · 0.85

Tested by

no test coverage detected