Answers.Body: <p><code>video1</code> has a very short keyframe interval - it has a keyframe every few frames. <code>video2</code> doesn't. Some players have the ability to decode upto non-KF silently and start playing from seek point. If yours doesn't, then it will start from the nearest keyframe preceding the seek point.</p>
  
  <pre><code>ffprobe origin.mp4 -show_entries frame=key_frame,pkt_pts_time -select_streams v -of compact=p=0 | grep ame=1
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>key_frame=1|pkt_pts_time=0.000000
  key_frame=1|pkt_pts_time=0.333667
  key_frame=1|pkt_pts_time=0.667334
  key_frame=1|pkt_pts_time=1.001001
  key_frame=1|pkt_pts_time=1.334668
  key_frame=1|pkt_pts_time=1.668335
  key_frame=1|pkt_pts_time=2.002002
  ...
  key_frame=1|pkt_pts_time=32.699366
  key_frame=1|pkt_pts_time=33.033033
  key_frame=1|pkt_pts_time=33.366700
  key_frame=1|pkt_pts_time=33.700367
  </code></pre>
  
  <p>Video2:</p>
  
  <pre><code>ffprobe my.mp4 -show_entries frame=key_frame,pkt_pts_time -select_streams v -of compact=p=0 | grep ame=1
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>key_frame=1|pkt_pts_time=0.000000
  key_frame=1|pkt_pts_time=2.293958
  key_frame=1|pkt_pts_time=5.171833
  key_frame=1|pkt_pts_time=7.257250
  key_frame=1|pkt_pts_time=9.718042
  key_frame=1|pkt_pts_time=13.221542
  key_frame=1|pkt_pts_time=15.473792
  key_frame=1|pkt_pts_time=21.271250
  key_frame=1|pkt_pts_time=24.357667
  key_frame=1|pkt_pts_time=29.195833
  key_frame=1|pkt_pts_time=32.407375
  </code></pre>
  
  <hr>
  
  <p>Add <code>-g 8</code> to ffmpeg transcode command to place a keyframe every 8 frames.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-11T17:58:06.967Z
Answers.Text: you are such a life saver like always! You really saved me from days of depression!!  One more question, if I want both good keyframe interval and about 3m file size. I should in the meanwhile reduce video bitrate and audio Hz, which of course will result in reduced quality. Am I right?
Answers.UserDisplayName: Xi Xiao
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-11T19:35:55.553Z
Answers.Text: Reduce video bitrate? yes. Audio sample rate won't matter much.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-11T19:41:51.777Z
Answers.Text: got it. good day!
Answers.UserDisplayName: Xi Xiao
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-02T05:06:07.147Z
Answers.Text: my hls audio have same keyframe freq. But the problem is still here. Is there any another issue can effect this?
Answers.UserDisplayName: jiamo
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-11T10:00:16.520Z
Answers.LastActivityDate: 2017-07-11T10:22:16.000Z
Answers.LastEditDate: 2017-07-11T10:22:16.000Z
Answers.UserDisplayName: Gyan
Body: <p>I am stuck and really do not know how to explain it in correct manner. Thus I put it in the layman details.</p>
  
  <p>I have two 30~ second length mp4 videos saved in cloud storage. </p>
  
  <ul>
  <li><a href="https://s3-eu-west-1.amazonaws.com/test-origin-my/origin.mp4" rel="nofollow noreferrer">video1</a> is generated by somebody else and </li>
  <li><a href="https://s3-eu-west-1.amazonaws.com/test-origin-my/my.mp4" rel="nofollow noreferrer">video2</a> is generated by me on ffmpeg. </li>
  </ul>
  
  <p>They both have the same video content.</p>
  
  <p><strong>My issue is</strong></p>
  
  <p>If I open <code>video2</code> in Safari browser, I cannot locate the accurate time (by sec) in the video player progress bar.</p>
  
  <p>What I mean is, for example I take steps:</p>
  
  <ol>
  <li>I pause the video,  </li>
  <li>drag the progress bar to the first second,  </li>
  <li>I play the video.</li>
  </ol>
  
  <p>the video player will jump to 0 and play, instead of playing from 1 second.</p>
  
  <p>There are multiple time-slots in <code>video2</code> that have this issue.</p>
  
  <p><strong>However, <code>video1</code> does not have this issue.</strong></p>
  
  <p>video1 info from ffmpeg</p>
  
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'origin.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.4.101
    Duration: 00:00:33.78, start: 0.000000, bitrate: 584 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 545 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 32 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  </code></pre>
  
  <p>video2 info from ffmpeg</p>
  
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf57.71.100
    Duration: 00:00:35.04, start: 0.000000, bitrate: 734 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 90:67 DAR 160:67], 599 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  </code></pre>
  
Tags: <video><ffmpeg><codec><mp4><webvideos>
Title: Why can't my video play from where I drag the playback bar?
UserDisplayName: Xi Xiao
ThreadText: # Why can't my video play from where I drag the playback bar?
  
  (Asked by: username_0 on 2017-07-11)
  
  I am stuck and really do not know how to explain it in correct manner. Thus I put it in the layman details.
  
  I have two 30~ second length mp4 videos saved in cloud storage.
  
  * [video1](https://s3-eu-west-1.amazonaws.com/test-origin-my/origin.mp4) is generated by somebody else and
  * [video2](https://s3-eu-west-1.amazonaws.com/test-origin-my/my.mp4) is generated by me on ffmpeg.
  
  They both have the same video content.
  
  **My issue is**
  
  If I open `video2` in Safari browser, I cannot locate the accurate time (by sec) in the video player progress bar.
  
  What I mean is, for example I take steps:
  
  1. I pause the video,
  2. drag the progress bar to the first second,
  3. I play the video.
  
  the video player will jump to 0 and play, instead of playing from 1 second.
  
  There are multiple time-slots in `video2` that have this issue.
  
  **However, `video1` does not have this issue.**
  
  video1 info from ffmpeg
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'origin.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf56.4.101
    Duration: 00:00:33.78, start: 0.000000, bitrate: 584 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 545 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 32 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  
  ```
  
  video2 info from ffmpeg
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf57.71.100
    Duration: 00:00:35.04, start: 0.000000, bitrate: 734 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 90:67 DAR 160:67], 599 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
  
  ```
  
  **Tags:** video, ffmpeg, codec, mp4, webvideos
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-07-11. Score: 3 | Accepted answer
  
  `video1` has a very short keyframe interval - it has a keyframe every few frames. `video2` doesn't. Some players have the ability to decode upto non-KF silently and start playing from seek point. If yours doesn't, then it will start from the nearest keyframe preceding the seek point.
  
  ```
  ffprobe origin.mp4 -show_entries frame=key_frame,pkt_pts_time -select_streams v -of compact=p=0 | grep ame=1
  
  ```
  
  Result:
  
  ```
  key_frame=1|pkt_pts_time=0.000000
  key_frame=1|pkt_pts_time=0.333667
  key_frame=1|pkt_pts_time=0.667334
  key_frame=1|pkt_pts_time=1.001001
  key_frame=1|pkt_pts_time=1.334668
  key_frame=1|pkt_pts_time=1.668335
  key_frame=1|pkt_pts_time=2.002002
  ...
  key_frame=1|pkt_pts_time=32.699366
  key_frame=1|pkt_pts_time=33.033033
  key_frame=1|pkt_pts_time=33.366700
  key_frame=1|pkt_pts_time=33.700367
  
  ```
  
  Video2:
  
  ```
  ffprobe my.mp4 -show_entries frame=key_frame,pkt_pts_time -select_streams v -of compact=p=0 | grep ame=1
  
  ```
  
  Result:
  
  ```
  key_frame=1|pkt_pts_time=0.000000
  key_frame=1|pkt_pts_time=2.293958
  key_frame=1|pkt_pts_time=5.171833
  key_frame=1|pkt_pts_time=7.257250
  key_frame=1|pkt_pts_time=9.718042
  key_frame=1|pkt_pts_time=13.221542
  key_frame=1|pkt_pts_time=15.473792
  key_frame=1|pkt_pts_time=21.271250
  key_frame=1|pkt_pts_time=24.357667
  key_frame=1|pkt_pts_time=29.195833
  key_frame=1|pkt_pts_time=32.407375
  
  ```
  
  ---
  
  Add `-g 8` to ffmpeg transcode command to place a keyframe every 8 frames.
  
  > **Comments:**
  > **username_0**: you are such a life saver like always! You really saved me from days of depression!!  One more question, if I want both good keyframe interval and about 3m file size. I should in the meanwhile reduce video bitrate and audio Hz, which of course will result in reduced quality. Am I right?  
  > **username_1**: Reduce video bitrate? yes. Audio sample rate won't matter much.  
  > **username_0**: got it. good day!  
  > **username_2**: my hls audio have same keyframe freq. But the problem is still here. Is there any another issue can effect this?  
  
  ---
  
  