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

Function webm_chunk_init

libavformat/webm_chunk.c:52–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50} WebMChunkContext;
51
52static int webm_chunk_init(AVFormatContext *s)
53{
54 WebMChunkContext *wc = s->priv_data;
55 AVFormatContext *oc;
56 AVStream *st, *ost = s->streams[0];
57 AVDictionary *dict = NULL;
58 int ret;
59
60 // DASH Streams can only have one track per file.
61 if (s->nb_streams != 1)
62 return AVERROR(EINVAL);
63
64 if (!wc->header_filename) {
65 av_log(s, AV_LOG_ERROR, "No header filename provided\n");
66 return AVERROR(EINVAL);
67 }
68
69 wc->prev_pts = AV_NOPTS_VALUE;
70
71 EXTERN const FFOutputFormat ff_webm_muxer;
72
73 ret = avformat_alloc_output_context2(&wc->avf, &ff_webm_muxer.p, NULL, NULL);
74 if (ret < 0)
75 return ret;
76 oc = wc->avf;
77
78 ff_format_set_url(oc, wc->header_filename);
79 wc->header_filename = NULL;
80
81 oc->interrupt_callback = s->interrupt_callback;
82 oc->max_delay = s->max_delay;
83 oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS;
84 oc->strict_std_compliance = s->strict_std_compliance;
85 oc->avoid_negative_ts = s->avoid_negative_ts;
86
87 oc->flush_packets = 0;
88
89 if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0)
90 return ret;
91
92 st = ff_stream_clone(oc, ost);
93 if (!st)
94 return AVERROR(ENOMEM);
95
96 if (wc->http_method)
97 if ((ret = av_dict_set(&dict, "method", wc->http_method, 0)) < 0)
98 return ret;
99 ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &dict);
100 av_dict_free(&dict);
101 if (ret < 0)
102 return ret;
103 oc->pb->seekable = 0;
104
105 if ((ret = av_dict_set_int(&dict, "dash", 1, 0)) < 0 ||
106 (ret = av_dict_set_int(&dict, "cluster_time_limit",
107 wc->chunk_duration, 0)) < 0 ||
108 (ret = av_dict_set_int(&dict, "live", 1, 0)) < 0)
109 goto fail;

Callers

nothing calls this directly

Calls 10

av_logFunction · 0.85
ff_format_set_urlFunction · 0.85
av_dict_copyFunction · 0.85
ff_stream_cloneFunction · 0.85
av_dict_setFunction · 0.85
av_dict_freeFunction · 0.85
av_dict_set_intFunction · 0.85
avformat_init_outputFunction · 0.85
avpriv_set_pts_infoFunction · 0.85

Tested by

no test coverage detected