[Libav-user] HLS: Exactly constant segment duration
Andrey Mochenov
andrey2067 at gmail.com
Mon Aug 19 09:11:51 CEST 2013
Hi gentlemen,
Please, help us with the following question:
What is the best way to force an EXACTLY constant video segment duration?
We need the solution urgently.
Best regards,
Andrey.
On Thu, Aug 15, 2013 at 2:29 PM, Andrey Mochenov <andrey2067 at gmail.com>wrote:
> Hi,
>
> We are using FFmpeg libraries git-ee94362 libavformat v55.2.100.
> Our purpose is to mux two streams (video and audio) into M3U8 playlist
> using HLS.
> In addition, we want the duration of every TS segment file be exactly 3.0
> sec (frame rate is 25 fps).
> To reach it, we are trying to set several options and properties, namely:
> - segment_time
> - keyint_min
> - scenechange_threshold
> - gop_size
> - force_key_frames.
>
> And our code looks as below:
>
> AVCodecContext *codec_ctx = NULL;
> AVFormatContext *ofmt_ctx = NULL;
> int ret = 0, gopSize = (int)(3.0 * 25); // 3 sec * 25 fps
>
> // ofmt_ctx and codec_ctx initialization and filling are OK, but:
>
> codec_ctx->time_base.num = 1;
> codec_ctx->time_base.den = 25 // fps
>
> // It seems, that the following three lines have no effect without
> explisit setting of the "hls_time" property
> codec_ctx->keyint_min = gopSize; // in FFMpeg application, the
> corresponding option is "-keyint_min 3"
> codec_ctx->scenechange_threshold = 0; // in FFMpeg application, the
> corresponding option is "-sc_threshold 0"
> codec_ctx->gop_size = gopSize; // in FFMpeg application, the
> corresponding option is "-g 3"
>
> ret = av_opt_set_double(ofmt_ctx, "hls_time", 3.0, AV_OPT_SEARCH_CHILDREN);
>
> // Any of the following lines causes "Option not found" error.
> ret = av_opt_set(codec_ctx->priv_data, "profile", "main",
> AV_OPT_SEARCH_CHILDREN);
> ret = av_opt_set(codec_ctx->priv_data, "preset", "ultrafast",
> AV_OPT_SEARCH_CHILDREN);
> ret = av_opt_get(ofmt_ctx, "segment_time", AV_OPT_SEARCH_CHILDREN, &str);
> ret = av_opt_set((ofmt_ctx, "segment_time", "3.0", AV_OPT_SEARCH_CHILDREN);
>
> Anyway, the TS files durations are different, (~2-3 sec), and not EXACTLY
> 3.0 sec.
> Our question: What is the best way to solve the problem?
>
> Andrey Mochenov.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130819/0db9cca8/attachment.html>
More information about the Libav-user
mailing list