Giter VIP home page Giter VIP logo

Comments (4)

AbySwifter avatar AbySwifter commented on May 22, 2024

我在buildPlayerItem中断点调试,发现

CompositionGenerator.swift 85行

timeline.videoChannel.enumerated().forEach({ (offset, provider) in
            for index in 0..<provider.numberOfVideoTracks() {
                let trackID: Int32 = getVideoTrackID(for: index) + Int32((offset % 2 + 1) * 1000)
                if let compositionTrack = provider.videoCompositionTrack(for: composition, at: index, preferredTrackID: trackID) {
                    let info = mainVideoTrackInfo.first(where: { $0.track == compositionTrack })
                    if let info = info {
                        info.info.append(provider)
                    } else {
                        let info = TrackInfo.init(track: compositionTrack, info: [provider])
                        mainVideoTrackInfo.append(info)
                    }
                }
            }

这段代码中,provider.numberOfVideoTracks(),的值始终为0.PHAssetImageResource生成的TrackItem。

from cabbage.

AbySwifter avatar AbySwifter commented on May 22, 2024

我解决了这个问题。在下面的方法里,添加了对Bundle的定义:

 private static let emptyAsset: AVAsset? = {
        let bundle = Bundle(for: ImageResource.self)
        /// 这里添加的3行代码解决了上述问题
        if let videoURL = bundle.url(forResource: "black_empty", withExtension: "mp4") {
            return AVAsset(url: videoURL)
        }
        if let bundleURL = bundle.resourceURL?.appendingPathComponent("Cabbage.bundle") {
            let resourceBundle = Bundle.init(url: bundleURL)
            if let videoURL = resourceBundle?.url(forResource: "black_empty", withExtension: "mp4") {
                return AVAsset(url: videoURL)
            }
        }
        
        if let url = Bundle.main.url(forResource: "black_empty", withExtension: "mp4") {
            let asset = AVAsset(url: url)
            return asset
        }
        
        return nil
    }()

from cabbage.

vitoziv avatar vitoziv commented on May 22, 2024

这个修改欢迎提交 pr

from cabbage.

AbySwifter avatar AbySwifter commented on May 22, 2024

好的,我会在最近提交PR

from cabbage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.