<p><br>
On Aug 15, 2013 4:59 PM, "Andrey Mochenov" <<a href="mailto:andrey2067@gmail.com">andrey2067@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> We are using FFmpeg libraries git-ee94362 libavformat v55.2.100.<br>
> Our purpose is to mux two streams (video and audio) into M3U8 playlist using HLS.<br>
> In addition, we want the duration of every TS segment file be exactly 3.0 sec (frame rate is 25 fps).<br>
> To reach it, we are trying to set several options and properties, namely: <br>
> - segment_time  <br>
> - keyint_min<br>
> - scenechange_threshold<br>
> - gop_size<br>
> - force_key_frames.<br>
><br>
> And our code looks as below:<br>
><br>
> AVCodecContext *codec_ctx = NULL;<br>
> AVFormatContext *ofmt_ctx = NULL;<br>
> int ret = 0, gopSize = (int)(3.0 * 25);   // 3 sec * 25 fps<br>
><br>
> // ofmt_ctx and codec_ctx initialization and filling are OK, but:<br>
><br>
> codec_ctx->time_base.num = 1;<br>
> codec_ctx->time_base.den = 25 // fps<br>
><br>
> // It seems, that the following three lines have no effect without explisit setting of the "hls_time" property<br>
> codec_ctx->keyint_min = gopSize;       // in FFMpeg application, the corresponding option is "-keyint_min 3"<br>
> codec_ctx->scenechange_threshold = 0;  // in FFMpeg application, the corresponding option is "-sc_threshold 0"<br>
> codec_ctx->gop_size = gopSize;         // in FFMpeg application, the corresponding option is "-g 3"<br>
><br>
> ret = av_opt_set_double(ofmt_ctx, "hls_time", 3.0, AV_OPT_SEARCH_CHILDREN);<br>
><br>
> // Any of the following lines causes "Option not found" error.<br>
> ret = av_opt_set(codec_ctx->priv_data, "profile", "main", AV_OPT_SEARCH_CHILDREN);<br>
> ret = av_opt_set(codec_ctx->priv_data, "preset", "ultrafast", AV_OPT_SEARCH_CHILDREN);<br>
> ret = av_opt_get(ofmt_ctx, "segment_time",  AV_OPT_SEARCH_CHILDREN, &str);<br>
> ret = av_opt_set((ofmt_ctx, "segment_time", "3.0", AV_OPT_SEARCH_CHILDREN);<br>
><br>
> Anyway, the TS files durations are different, (~2-3 sec), and not EXACTLY 3.0 sec. <br>
> Our question: What is the best way to solve the problem?<br>
><br>
> Andrey Mochenov.<br>
><br>
><br>
> _______________________________________________<br>
> Libav-user mailing list<br>
> <a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
> <a href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
></p>
<p>Please dont top post over here </p>
<p>Try to set encoder with all idr,  that may give you const duration</p>