相关疑难解决方法(0)

AVPlayer - 向CMTime添加秒数

如何为当前的播放时间添加5秒?
其实这是我的代码:

CMTime currentTime = music.currentTime;
Run Code Online (Sandbox Code Playgroud)

我不能使用CMTimeGetSeconds(),因为我需要CMTime格式.

谢谢您的回答...

编辑:如何为CMTime设置变量?

iphone xcode ios avplayer cmtime

16
推荐指数
3
解决办法
2万
查看次数

在 Swift 4 中合并两个视频?

因此,我已经录制了两个 .mp4 并存储在应用程序中,我想将一个附加到另一个,然后导出为新视频。它有点有效,但不完全有效!

    let composition = AVMutableComposition()
    var track = composition.addMutableTrack(withMediaType: AVMediaType.video, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))

    let videoAsset = AVAsset(url: AAA as URL) as AVAsset
    let videoAsset2 = AVAsset(url: BBB as URL) as AVAsset
    do {
        try track?.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoAsset.duration), of: videoAsset.tracks(withMediaType: AVMediaType.video)[0] as AVAssetTrack, at: kCMTimeZero)
        try track?.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoAsset.duration), of: videoAsset2.tracks(withMediaType: AVMediaType.video)[0] as AVAssetTrack, at: kCMTimeZero)

    } catch {
        print("darn")
    }

    let exporter = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetHighestQuality)
    exporter?.outputURL = CCC
    exporter?.outputFileType = AVFileType.mp4
    exporter?.shouldOptimizeForNetworkUse = true


    exporter?.exportAsynchronously {
        print("done?")
    }
Run Code Online (Sandbox Code Playgroud)

这种方式组合了视频,但它在两个剪辑之间添加了大量黑屏,并删除了音频。我找不到这个问题的任何最新答案。感谢您的帮助!

video avfoundation avassetexportsession swift

5
推荐指数
1
解决办法
2357
查看次数