19

所以看起来真正起作用的唯一值是 0.0、0.5、1.0 和 2.0...

我尝试将其设置为 0.25,因为我希望它以自然速度的 1/4 播放,但它以自然速度的 1/2 播放。谁能证实这一点?

4

6 回答 6

28

播放速率限制似乎是由于音高校正,现在可以在 iOS 7 或更高版本中进行配置。

// This prevents the play rate from going below 1/2.
playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmLowQualityZeroLatency;

这似乎是默认设置:

低质量和非常低的计算密集型音高算法。适用于短暂的快进和倒带效果以及低质量的声音。比率被捕捉到 {0.5, 0.666667, 0.8, 1.0, 1.25, 1.5, 2.0}。

其他三个算法设置可让您将播放速率降低到 1/32。例如,AVAudioTimePitchAlgorithmVarispeed关闭音高校正。

// Enable play rates down to 1/32.
playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmVarispeed;
于 2014-10-10T19:55:40.147 回答
24

确认的。实际上,我为此问题打开了 Apple DTS 的票,并提交了一个错误。唯一支持的值是 0.50、0.67、0.80、1.0、1.25、1.50 和 2.0。所有其他设置都四舍五入到最接近的值。

于 2012-03-30T02:48:44.020 回答
8

我发现确实支持较小的值,但是 AVPlayerItem 中的所有轨道都必须支持速度。但是,Apple 没有在单个轨道上提供一个属性来指示支持的速率,只有 AVPlayerItem 上的属性 canPlaySlowForward。

我发现,带有音轨的 AVPlayerItems 不能以低于 0.5 的速率播放。但是,如果只有一个视频轨道,则速率可以具有任意小的值,例如 0.01。我将尝试编写一个类别来即时检查支持哪些值并在需要时禁用不受支持的轨道。

兄弟丹尼斯

更新

我写了一个函数,只要你想将视频的速率设置为低于 0.5,你就可以调用它。它启用/禁用所有音轨。

- (void)enableAudioTracks:(BOOL)enable inPlayerItem:(AVPlayerItem*)playerItem
{
    for (AVPlayerItemTrack *track in playerItem.tracks)
    {
        if ([track.assetTrack.mediaType isEqual:AVMediaTypeAudio])
        {
            track.enabled = enable;
        }
    }
}
于 2014-01-14T10:55:24.970 回答
4

我同意@otto,嗨的回答解决了我的问题。

/*
AVAudioProcessingSettings.h


@abstract       Values for time pitch algorithm

@constant      AVAudioTimePitchAlgorithmLowQualityZeroLatency
            Low quality, very inexpensive. Suitable for brief fast-forward/rewind effects, low quality voice.
            Rate snapped to {0.5, 0.666667, 0.8, 1.0, 1.25, 1.5, 2.0}.

@constant      AVAudioTimePitchAlgorithmTimeDomain
            Modest quality, less expensive. Suitable for voice.
            Variable rate from 1/32 to 32.

@constant      AVAudioTimePitchAlgorithmSpectral
            Highest quality, most computationally expensive. Suitable for music.
            Variable rate from 1/32 to 32.

@constant      AVAudioTimePitchAlgorithmVarispeed
            High quality, no pitch correction. Pitch varies with rate.
            Variable rate from 1/32 to 32.
*/

AVF_EXPORT NSString *const AVAudioTimePitchAlgorithmLowQualityZeroLatency NS_AVAILABLE_IOS(7_0);
AVF_EXPORT NSString *const AVAudioTimePitchAlgorithmTimeDomain NS_AVAILABLE(10_9, 7_0);
AVF_EXPORT NSString *const AVAudioTimePitchAlgorithmSpectral NS_AVAILABLE(10_9, 7_0);
AVF_EXPORT NSString *const AVAudioTimePitchAlgorithmVarispeed NS_AVAILABLE(10_9, 7_0);
于 2015-11-17T08:02:03.070 回答
2

(Xcode 11.6、iOS 13.6、Swift 5)

它不适用于

player.rate = 2.0

它适用于

player.playImmediately(atRate: 3.0)
于 2020-07-28T15:32:07.267 回答
0

不,它在 ipad 2 ios 5 上对我来说工作正常(xcode 4.2)。我使用了开发资源中的 AVPlayerDemo 并使用滑块修改了 rate 属性,它非常流畅,绝对没有跳跃。低于 0.2 的行为很奇怪。也许速率在极值附近不是线性的,但绝对是平滑的。从 0.2 一直到 2。我正在使用我用设备拍摄的视频,这可能会有所作为。

于 2011-11-02T12:31:07.683 回答