簡體   English   中英

如何在iOS中從開始時間到結束時間修剪或播放音頻?

[英]how to trim or play a audio from begin time to end time in iOS?

這類似於iTunes的修整功能,通過以下兩個參數來獲得我想要的修整音頻。

例如。 開始時間:00:23.12

停止時間:01:33.54

非常感謝任何幫助!

如果您在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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM