[FFmpeg-cvslog] avformat/webm_chunk: Add init function
Andreas Rheinhardt
git at videolan.org
Thu Mar 26 03:27:11 EET 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Mar 1 00:33:18 2020 +0100| [42b000427dfa8d49807e8a756091d7662ba3bf65] | committer: Andreas Rheinhardt
avformat/webm_chunk: Add init function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42b000427dfa8d49807e8a756091d7662ba3bf65
---
libavformat/webm_chunk.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index af0d6b9d76..4188c5c0a5 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -55,7 +55,7 @@ typedef struct WebMChunkContext {
AVFormatContext *avf;
} WebMChunkContext;
-static int chunk_mux_init(AVFormatContext *s)
+static int webm_chunk_init(AVFormatContext *s)
{
WebMChunkContext *wc = s->priv_data;
ff_const59 AVOutputFormat *oformat;
@@ -64,11 +64,17 @@ static int chunk_mux_init(AVFormatContext *s)
AVDictionary *dict = NULL;
int ret;
+ // DASH Streams can only have one track per file.
+ if (s->nb_streams != 1)
+ return AVERROR(EINVAL);
+
if (!wc->header_filename) {
av_log(s, AV_LOG_ERROR, "No header filename provided\n");
return AVERROR(EINVAL);
}
+ wc->prev_pts = AV_NOPTS_VALUE;
+
oformat = av_guess_format("webm", s->url, "video/webm");
if (!oformat)
return AVERROR_MUXER_NOT_FOUND;
@@ -144,19 +150,10 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ
static int webm_chunk_write_header(AVFormatContext *s)
{
WebMChunkContext *wc = s->priv_data;
- AVFormatContext *oc = NULL;
+ AVFormatContext *oc = wc->avf;
int ret;
AVDictionary *options = NULL;
- // DASH Streams can only have either one track per file.
- if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; }
-
- wc->prev_pts = AV_NOPTS_VALUE;
-
- ret = chunk_mux_init(s);
- if (ret < 0)
- return ret;
- oc = wc->avf;
if (wc->http_method)
av_dict_set(&options, "method", wc->http_method, 0);
ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options);
@@ -295,6 +292,7 @@ AVOutputFormat ff_webm_chunk_muxer = {
.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NEEDNUMBER |
AVFMT_TS_NONSTRICT,
.priv_data_size = sizeof(WebMChunkContext),
+ .init = webm_chunk_init,
.write_header = webm_chunk_write_header,
.write_packet = webm_chunk_write_packet,
.write_trailer = webm_chunk_write_trailer,
More information about the ffmpeg-cvslog
mailing list