iOS AVFoundation - Converting video into images at 60 fps

前端 未结 1 1845
挽巷
挽巷 2020-12-16 07:22

i\'m trying to convert a whole video into a sequence of images at a rate of 60fps, which means 60 images generated per second of video...

To do so, i\'m making use o

1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 07:59

    Hey @Sooriah Joel try using following code. It is working fine for me.

    - (void)generateCMTimesArrayOfAllFramesUsingAsset:(AVURLAsset *)asset
    {
        if (cmTimeArray.count>0) {
            [cmTimeArray removeAllObjects];
        }
        //Generate all frames present in video
        for(int t=0;t < asset.duration.value;t++) {
            CMTime thumbTime = CMTimeMake(t,asset.duration.timescale);
            NSValue *v=[NSValue valueWithCMTime:thumbTime];
            [cmTimeArray addObject:v];
        }
        NSLog(@"Array of time %@ count = %d",cmTimeArray, cmTimeArray.count);
        //NSLog(@"Array count = %d",cmTimeArray.count);
    }
    
    
    - (void)generateCMTimesArrayOfFrames:(int)framesInterval UsingAsset:(AVURLAsset *)asset
    {
        int videoDuration = ceilf(((float)asset.duration.value/asset.duration.timescale));
        NSLog(@"Video duration %lld seconds timescale = %d",asset.duration.value,asset.duration.timescale);
        if (cmTimeArray.count>0) {
            [cmTimeArray removeAllObjects];
        }
        //Generate limited frames present in video
        for (int i = 0; i

    0 讨论(0)
提交回复
热议问题