Search code examples
iosavfoundationswift4video-capturetrim

ThumbNail Generator could not get frame width in PryntTrimmerView CocoaPod


I am using PryntTrimmerView CocoaPod for my Video Trimmer app. Everything is working fine but my PryntTrimmerView does not show any Frames from video rather the View stays blank. I checked the Log and it seems, the Thumbnail Generator is getting Thumbnail Width as 0. I am using Video URl to load video in AVPlayer. I am not saving the Video until the Trimming is complete. here is my ViewDidLoad function where I set AVAsset from my Video URL and set TrimmerView asset to the Video Asset.

override func viewDidLoad()
{
    super.viewDidLoad()
    addVideoPlayer()
    
    playerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
    
    trimmerView.frame = CGRect(x: 0, y: CGFloat(playerView.frame.height)-75, width: view.frame.width, height: 50)
    
    trimButton.frame = CGRect(x: Double(CGFloat(view.frame.width)/2)-35, y: Double(CGFloat(view.frame.height) - 150), width: 70, height: 70)
    //playerView.contentMode = .scaleAspectFill
    
    playerView.addSubview(trimmerView)
    
    trimmingFunc()
    currentAsset = AVAsset(url: selectedVideoURL!)
    trimmerView.positionBarColor = .clear
    trimmerView.asset = currentAsset
    trimmerView.delegate = self
    
    view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tap)))
}

I need to show the VideoFrames in the TrimmerView for Better UI, that's all.


Solution

  • Assign asset to trimmerView: trimmerView.asset = currentAsset in viewDidAppear(_ animated: Bool) instead of viewDidLoad()