1

I am working on a project that involves generating a thumbnail image for the last scene of a live broadcast in real-time. I have implemented a method that uses the ACThumbnailGenerator class to generate the thumbnail, but I am encountering a problem where the generated thumbnail is consistently 15 seconds behind the live broadcast.

Here is the code for my generateThumbnail() method:

private func generateThumbnail() {
    let streamUrl = URL(string: self.viewModel?.playbackURL ?? "")!
    let startedAt = viewModel.startedAt.stringToDate(dateFormatter: "HH:mm:ss.SSS")
    let elapsedTime = Date().timeIntervalSince(startedAt)
    generator = ACThumbnailGenerator(streamUrl: streamUrl)
    generator.delegate = self
    generator.captureImage(at: Double(elapsedTime))
}

I have tried the solution of subtracting 15 seconds from the elapsedTime variable, as suggested in a similar StackOverflow post, but this did not solve my issue. I still get a thumbnail that is 15 seconds behind the live broadcast.

Is there a way to generate a thumbnail in real-time that is synchronized with the live broadcast? Any help or guidance would be greatly appreciated. Thank you!

Cem Nisan
  • 97
  • 6

0 Answers0