I am trying to get the duration of audio files to trim them, I use the code below,
audioAsset = [AVURLAsset assetWithURL:itemURL]; CMTime assetTime = [audioAsset duration]; Float64 duration = CMTimeGetSeconds(assetTime);
when I provide the itemURL of any audio file of a media library, I get the proper duration, and then I can trim the audio file. Then I save the trimmed audio file in the document directory. But when I try to trim an already trimmed file, the same code returns me 0 as the duration. However, I can play the cropped file and get the duration using AVAudioPlayer, but what is the problem with AVURLAsset that I cannot understand.
Can anyone help? I have already tried almost all the answers to such a question in stackoverflow.
ios audio duration avurlasset
Rameswar prasad
source share