char *header_filename;
int chunk_duration;
int chunk_index;
+ char *http_method;
uint64_t duration_written;
int prev_pts;
AVOutputFormat *oformat;
}
if (is_header) {
if (!wc->header_filename) {
+ av_log(oc, AV_LOG_ERROR, "No header filename provided\n");
return AVERROR(EINVAL);
}
av_strlcpy(filename, wc->header_filename, strlen(wc->header_filename) + 1);
WebMChunkContext *wc = s->priv_data;
AVFormatContext *oc = NULL;
int ret;
+ int i;
+ AVDictionary *options = NULL;
// DASH Streams can only have either one track per file.
if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; }
ret = get_chunk_filename(s, 1, oc->filename);
if (ret < 0)
return ret;
- ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL);
+ if (wc->http_method)
+ av_dict_set(&options, "method", wc->http_method, 0);
+ ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, &options);
+ av_dict_free(&options);
if (ret < 0)
return ret;
if (ret < 0)
return ret;
ff_format_io_close(s, &oc->pb);
+ for (i = 0; i < s->nb_streams; i++) {
+ // ms precision is the de-facto standard timescale for mkv files.
+ avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
+ }
return 0;
}
uint8_t *buffer;
AVIOContext *pb;
char filename[MAX_FILENAME_SIZE];
+ AVDictionary *options = NULL;
if (wc->chunk_start_index == wc->chunk_index)
return 0;
ret = get_chunk_filename(s, 0, filename);
if (ret < 0)
goto fail;
- ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, NULL);
+ if (wc->http_method)
+ av_dict_set(&options, "method", wc->http_method, 0);
+ ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options);
if (ret < 0)
goto fail;
avio_write(pb, buffer, buffer_size);
ff_format_io_close(s, &pb);
oc->pb = NULL;
fail:
+ av_dict_free(&options);
av_free(buffer);
return (ret < 0) ? ret : 0;
}
{ "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
{ "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
{ "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+ { "method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
{ NULL },
};