Search code examples
videoflowplayer

Flowplayer pauses at different times with cuepoint


Good morning. I have a Flowplayer video with cuepoints ex [5, 10]. Here, my video starts from 5th second and pauses at 10th second. So it works. However, video sometimes pauses at 9th second and sometimes on 10th second. So it looks like a flowplayer bug.

I'd appreciate a hint or solution, how I can make the video always pause at exact time everytime.

here is the code snippet

flowplayer(flowplayerObject, {
        hlsjs: {
          xhrSetup: function (xhr) {
            xhr.withCredentials = true;
          }
        },
        swf: ------,
        swfHls: -------,
        clip: {
          cuepoints:[videoStartTime,videoEndTime],
          sources: [
            {type: "application/x-mpegURL", src: -------l},
            {type: "video/mp4", src: -------}
          ]
        }
      }).one("ready", function (e, api, video){
        api.seek(parseInt(videoStartTime));
      }).on("cuepoint", function (e, api, cuepoint) {
         if (cuepoint.index === 1) {
          api.pause();
        };
      }) ;

Thank you


Solution

  • I have not used the cuepoints feature of Flowplayer before, but I am familiar with the seek() API function where you specify the time (in seconds) in the video that you would like to seek to.

    For the seek function to work properly, your video needs to have a keyframe at every second of the video. I have a feeling cuepoints would have the same requirement.

    If you are familiar with ffmpeg, you can use the "force_key_frames" parameter like this way to add a keyframe to every second of the video -

    ffmpeg -i input_file_location -force_key_frames "expr:gte(t,n_forced*1)" other_ffmpeg_parameters -y output_file_location

    The downside to adding additional keyframes is that your video will occupy more space on the disk, but if you need the video to pause (or) start consistently at the times specified, I can't think of any other way using the HTML5 version of Flowplayer.