2

これは、iTunes のトリム機能に似ています。次の 2 つのパラメータを渡して、必要なトリム オーディオを取得します。

例えば。開始時間:00:23.12

停止時間:01:33.54

何か助けがあれば大歓迎です!

4

2 に答える 2

1

あなたが2016年にこれを読んでいて、解決策を探しているなら.それは私のために働いています(swift 2.3):

let exporter = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A)
    exporter!.outputURL = soundFile1
    exporter!.outputFileType = AVFileTypeAppleM4A
    let duration = CMTimeGetSeconds(avAsset1.duration)
    print(duration)
    if (duration < 5.0) {
        print("sound is not long enough")
        return
    }
    // e.g. the first 30 seconds
    let startTime = CMTimeMake(0, 1)
    let stopTime = CMTimeMake(30,1)
    let exportTimeRange = CMTimeRangeFromTimeToTime(startTime, stopTime)
    print(exportTimeRange)
    exporter!.timeRange = exportTimeRange
    print(exporter!.timeRange)
于 2016-11-18T06:30:29.617 に答える