FFmpeg: HLS options cannot be set/get/find
We are using FFmpeg libraries git-ee94362 libavformat v55.2.100. We are
trying to write a simple HLS code example based on muxing.c standard one.
Let be two input streams, video and audio (they can be synthetic, doesn't
matter). Our purpose is to mux them into M3U8 playlist using HLS. Suppose,
duration of every TS segment file be 3 sec, and the desirable maximum
number of entries in M3U8 output file be 100.
From the FFmpeg application sources, one can see that the Apple HTTP Live
Streaming segmenter implemented in hlsenc.c file. And the relevant options
there are, as well: "hls_list_size", "hls_time", etc. The problem is that
we have not succeeded to set/get/find these options in a conventional way,
as shown in the following code:
// Here is a part of main() program
int64_t i1 = 0; void *target_obj;
AVFormatContext *ofmt_ctx = NULL; AVOutputFormat *ofmt = NULL;
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, "Example_Out.m3u8");
ofmt = ofmt_ctx->oformat;
// The relevant options ("hls_list_size", "hls_time") are located under
ofmt->priv_class->option. // But AVClass *priv_class is not the first
member of the AVOutputFormat. // So, due to the documentation,
av_opt_find...(), av_opt_get...() and av_opt_set...() // cannot be used
for options within AVOutputFormat. // In practice, any of the following
three lines causes exception. const AVOption *o = av_opt_find2(ofmt,
"segment_list_size", NULL, 0, AV_OPT_SEARCH_CHILDREN, &target_obj);
av_opt_get_int(ofmt, "segment_list_size", AV_OPT_SEARCH_CHILDREN, &i1);
av_opt_set_int(ofmt, "segment_list_size", 10, AV_OPT_SEARCH_CHILDREN);
Our question: If there is a way to overcome the problem, i.e. to
set/get/find options for AVOutputFormat, like for AVCodecContext (for
example)?
Thank you,
Andrey Mochenov.
No comments:
Post a Comment