![]() ![]() Using FFMPEG you can encode a video to use key-frames only using the “-g 1” option. This is possible, but increases the file size dramatically. Compressing using P And B frames is known as temporal compression and isn’t ideal for accurate random seeking or playback rate changes.įor the best results you would encode your video with only key-frames, as then you can seek accurately and quickly anywhere in the video. The other type of frame is called a key-frame or I-frame and these frames can be decoded immediately because they don’t depend on any other frames. These are called P and B frames and seeking to one of these is computationally expensive, as in order to display them the decoder must first decode the other frames that they depend on. There are also some platform differences to consider.Ĭodecs such as H.264 and H.265 generally compress video frames so that they depend on data included with previously decoded frames. There are several reasons for this, but it mostly is related to how the video is encoded and specifically the key-frame distribution. If you want to start changing the playback rate, play in reverse, allow fast scrubbing, or have fast frame accurate seeking then you may run into issues where the playback becomes extremely slow or the seeking is not accurate. Most videos are optimally encoded for the typical use case: normal forward playback with approximate seeking. ![]() This option must be configured prior to creating the player and cannot be changed after the media has been opened. Should your playback rate exceed this new maximum rate then the player will drop back to showing just key-frames. If you need to play back a video at rates above 2.0 then you can adjust the "Max Playback Rate" slider in the platform specific options to set a higher threshold. There are some platform differences for playback-rate behaviour:īy default playback rates higher than 2.0 causes the player to only show key-frames. ![]() Scripting playback rate: // After the video is loaded and metadata event fires you can use these: Alternatively a fast key-frame-only codec could be used, such as Hap. Videos with more key-frames (or ideally all key-frames) and with less complex encoding (eg no B frames, CABAC disabled etc) will work better. Video encoding can also help the performance of a change in playback rate. This approach would work on all platforms. One safe alternative to adjusting rate is to pause the video and fast seek to simulate a change in playback rate. Using negative values isn’t generally recommended as it isn’t as well supported, but if you do have to use a negative rate then also try keeping the numbers small such as: -0.25, -0.5, -1.0Īudio also may or may not play when changing the playback rate - this depends on the platform (see table below). Increasing playback rate usually places more demand on the video decoder and also on the disk/network source, so these limit how high you can set the playback rate. Going up to 4.0 might be possible depending on your platform, machine specs and the codec used. There are some platform differences for seeking behaviour: If the frame rate can not be determined (eg in some HLS media the frame rate returns zero) then you can still use the frame-based time methods by manually supplying the frame rate as an optional final parameter to the above methods: // After the video is loaded and metadata event fires you can use these: Get the highest frame number you can seek to (the same as durationFrames-1) Media that has a known constant frame rate can be seeked using frames: // After the video is loaded and metadata event fires you can use these: TimeRange seekableRange = Helper.GetTimelineRange((), ()) Seek to the current 'live' time for a live stream This is only currently available on macOS, iOS, iPadOS and tvOS Seek to closest keyframe allowing keyframe to be either ahead, behind or on both sides of the desired time ![]() Seek to nearest keyframe at 24 seconds Get the ranges of time that can be seeked between All time operations are done in seconds using doubles: // After the video is loaded and metadata event fires you can use these:ĭouble duration = () ĭouble time = () ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |