Languages

Menu
Sites
Language
AVPlayer seeking issue for Multi Period DASH Live

Hi,

 

Recently I'm experiencing a seeking issue with Multi Period DASH Live Streaming. The issue is `webapis.avplay.seekTo` only works in the last period. When I try to seek to a time point that is out of the last period of the manifest, the playback always get freezing. I'm pretty sue that seeking time is in the DVR window and the playback works well on other players, e.g. dash-if-reference-player.

I just want to check if seeking works well or not for Multi Period of DASH Live streaming in AVPlayer? Is it a known issue? My TV is Samsung 2018,

 

There is a similar issue, https://developer.tizen.org/ko/forums/web-application-development/multi-period-dash-live-streams, but no any responses yet.

 

Best regards,

Responses

1 Replies
Rachel Gomez
Hey! I just solved this problem and am very happy to share my working solution. The trick here is that two videos can have different fps. And we need to update the frameDuration AVMutableVideoComposition parameter of our AVPlayerItem
 
in general, the code looks like this
 
enum Const {
static let perciseValue = 1000000
}
 
struct SemgentModel {
let framerate: Float
let timeRange: CMTimeRange
}
 
var mySegments: [SemgentModel] = ..add segments
var player: AVPlayer?
 
func updateFramerateOfComposition(newRate: Float) {
let mutableComposition = player?.playerItem?.videoComposition?.mutableCopy() as? AVMutableVideoComposition
    mutableComposition?.frameDuration = CMTime(value: CMTimeValue(1 * Const.perciseValue), timescale: CMTimeScale(newRate * Float(Const.perciseValue)))
    player?.playerItem?.videoComposition = mutableComposition
}
 
func setTime(time: CMTime) {
if let segment = mySegments.first(where: { $0.timeRange.contains(time) }) {
updateFramerateOfComposition(newRate: segment.framerate)
}
player?.seek( to: seekTargetTime, toleranceBefore: .zero, toleranceAfter: .zero) { ... }
}
 
Regards,
Rachel Gomez