zoukankan      html  css  js  c++  java
  • 视频取缩略图

    ///视频 获取 缩略图

    - (UIImage*) thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time {

        AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil] ;

        NSParameterAssert(asset);

        AVAssetImageGenerator *assetImageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];

        assetImageGenerator.appliesPreferredTrackTransform = YES;

        assetImageGenerator.apertureMode = AVAssetImageGeneratorApertureModeEncodedPixels;

        //取帧

        CGImageRef thumbTemp = NULL;

        CMTime actualTime ;

        //    int32_t time = asset.duration.timescale;

        NSError *error = nil;

        thumbTemp = [assetImageGenerator copyCGImageAtTime:CMTimeMake(time, asset.duration.timescale) actualTime:&actualTime error:&error];

        NSLog(@"%lld",actualTime.value);

        UIImage *thumb = nil;

        if (!error)

        {

            thumb = [[UIImage alloc] initWithCGImage:thumbTemp];

        }

        CGImageRelease(thumbTemp);

        return thumb;

    }

  • 相关阅读:
    analysis of algorithms
    Measurement of Reflected Radiation
    lecture 5
    lecture 3
    字符串
    Emission of Radiation辐射发射
    Electromagnetic Radiation(EMR) 电磁辐射
    Linux FTP服务器-VSFTPD虚拟用户配置
    jenkins notes
    python nose使用记录
  • 原文地址:https://www.cnblogs.com/xia0huihui/p/5430806.html
Copyright © 2011-2022 走看看