2

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 is generated by somebody else and
  • video2 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
2

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.

  • 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? – Xi Xiao Jul 11 '17 at 17:58
  • Reduce video bitrate? yes. Audio sample rate won't matter much. – Gyan Jul 11 '17 at 19:35
  • got it. good day! – Xi Xiao Jul 11 '17 at 19:41
  • my hls audio have same keyframe freq. But the problem is still here. Is there any another issue can effect this? – jiamo Jul 2 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.