<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 8/19/2013 3:03 AM, Anshul wrote:<br>
    </div>
    <blockquote cite="mid:5211ED79.4070503@gmail.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 08/19/2013 03:18 PM, Andrey
        Mochenov wrote:<br>
      </div>
      <blockquote
cite="mid:CACg7hcuigi-qQS9p+H+zeAa17VO7vkpQpBc30MTi+wm0AtAJOQ@mail.gmail.com"
        type="cite">
        <div dir="ltr">
          <div>Hi,</div>
          <div> </div>
          <div>Thank you for your answer.</div>
          <div>I suppose, IDR stands for <span lang="HE">Instantaneous
              Decoding Refresh.</span></div>
          <div><span lang="HE">
              <div>Please, explain: what do you mean under "set encoder
                with all idr"? </div>
            </span><br>
            What settings I need to use?</div>
          <div> </div>
          <div>Andrey.</div>
          <div> </div>
        </div>
        <div class="gmail_quote">On Mon, Aug 19, 2013 at 10:48 AM,
          Anshul maheshwari <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:er.anshul.maheshwari@gmail.com"
              target="_blank">er.anshul.maheshwari@gmail.com</a>></span>
          wrote:<br>
          <blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px
            0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
            <p> </p>
            <div>
              <div class="h5">
                <p>Please dont top post over here </p>
                <p>Try to set encoder with all idr,  that may give you
                  const duration</p>
              </div>
            </div>
          </blockquote>
          <blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px
            0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
            <div>
              <div class="h5">
                <p>On Aug 15, 2013 4:59 PM, "Andrey Mochenov" <<a
                    moz-do-not-send="true"
                    href="mailto:andrey2067@gmail.com" target="_blank">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>
                </p>
              </div>
            </div>
            > _______________________________________________<br>
            > Libav-user mailing list<br>
            > <a moz-do-not-send="true"
              href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
            > <a moz-do-not-send="true"
              href="http://ffmpeg.org/mailman/listinfo/libav-user"
              target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
            >
            <p>Please dont top post over here </p>
            <p>Try to set encoder with all idr,  that may give you const
              duration</p>
            <br>
            _______________________________________________<br>
            Libav-user mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
            <a moz-do-not-send="true"
              href="http://ffmpeg.org/mailman/listinfo/libav-user"
              target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
Libav-user mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a>
</pre>
      </blockquote>
      <br>
      <br>
      <b>I am reminding you again, please don't top post on this mailing
        list.<br>
        <br>
      </b>While cutting the video , segmenter over ride the
      segement-time if at that time  IDR is not the frame.<br>
      so if you have less interval between idr, than there are
      probability that segmenter does not over-ride the segment-time.
      just to verify that you are facing the same problem set your
      encoder IDR interval as 0 or 1,<br>
      <br>
      -Anshul<br>
      <br>
      <br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Libav-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a class="moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a>
</pre>
    </blockquote>
    <br>
    It also can help to use a higher version in the m3u8 file list so
    that you can specify decimals for duration.If your segment is 200
    mills short or longer, the client is able to anticipate gaps, and
    initiate the next stream-pull earlier or later. Seemed to me while
    segmenting live streams, that as long as I did the chop at interval
    of 4 or 8 seconds, that my segments could be shorter or longer and
    play-out is smooth as long as I was honest in the playlist about the
    actual duration of each entry.<br>
    <br>
    <br>
    Andy<br>
    <br>
     <br>
  </body>
</html>