c++ - FFmpeg: HLS options cannot be set/get/find -
we using ffmpeg
libraries git-ee94362 libavformat v55.2.100
. trying write simple hls
code example based on muxing.c
standard one. let 2 input streams, video , audio (they can synthetic, doesn't matter). our purpose mux
them m3u8
playlist using hls
. suppose, duration of every ts segment file 3 sec, , desirable maximum number of entries in m3u8
output file 100.
from ffmpeg
application sources, 1 can see apple http live streaming segmenter implemented in hlsenc.c
file. , relevant options there are, well: "hls_list_size"
, "hls_time"
, etc. problem have not succeeded set/get/find these options in conventional way, shown in following code:
// here 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; // relevant options ("hls_list_size", "hls_time") located under ofmt->priv_class->option. // avclass *priv_class not first member of avoutputformat. // so, due documentation, av_opt_find...(), av_opt_get...() , av_opt_set...() // cannot used options within avoutputformat. // in practice, of following 3 lines causes exception. const avoption *o = av_opt_find2(ofmt, "hls_list_size", null, 0, av_opt_search_children, &target_obj); av_opt_get_int(ofmt, "hls_list_size", av_opt_search_children, &i1); av_opt_set_int(ofmt, "hls_list_size", 10, av_opt_search_children);
our question: if there way overcome problem, i.e. set/get/find options avoutputformat
, avcodeccontext
(for example)?
thank you,
andrey mochenov.
try passing in priv_data field of avformatcontext (ofmt->priv_data) instead of struct itself. null @ point in code gets filled in after call avformat_write_header.
av_opt_set_int(ofmt->priv_data, "hls_list_size", 10, av_opt_search_children) should work @ point.
if options need set before calling avformat_write_header() options live streaming, should pass them avdictionary** options argument function.
Comments
Post a Comment