96编辑器旗下产品
找图
终身
ID:0
到期时间:永久
退出登录
您的位置:首页 > 百科管理 > 详情

ios 第一帧图片素材-iphone视频提取一帧保存照片

原创:找图网 2023-06-19 23:20:09
  • iOS获取本地视频的时长和第一帧图片

  • //  本地图库按钮监听

    -( void )pictureClicked{

    UIImagePickerController *pickerController = [[UIImagePickerController alloc]init];

    = UIImagePickerControllerSourceTypePhotoLibrary;

    =@[(NSString*)kUTTypeMovie];

    = YES ;

    = self ;

    [ self .navigationController presentViewController:pickerController animated: YES completion: nil ];

    }

    -( void )imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionaryid> *)info{

    [pickerdismissViewControllerAnimated: YES completion: nil ];

    //这个是获取本地图库视频的路径

    NSURL *URL = info[UIImagePickerControllerMediaURL];

    NSString*URLStr = [NSStringstringWithFormat:@"%@",URL];

    //获取本地视频的第一帧当作封面

    AVURLAsset*asset = [[AVURLAssetalloc]initWithURL:URLoptions: nil ];

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

    = YES ;

    CMTime time = CMTimeMakeWithSeconds(0.0, 600);

    NSError*error = nil ;

    CMTimeactualTime;

    CGImageRefimage = [assetGencopyCGImageAtTime:timeactualTime:&actualTimeerror:&error];

    //这个就是第一帧的图片了

    UIImage*videoImage = [[UIImagealloc]initWithCGImage:image];

    //  获取本地视频的时长

    NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool: NO ]

    forKey:AVURLAssetPreferPreciseDurationAndTimingKey];

    AVURLAsset*urlAsset = [AVURLAssetURLAssetWithURL:URLoptions:opts];

    float second = / ;

    if (second >60){

    SHOW_ALERT(@"视频长度不能大于一分钟");

    } else {

    SHOW_ALERT(@"这里写业务逻辑");

    }

    }

  • iphone视频提取一帧保存照片

  • 我们的iphone手机上会保存着许多的视频,如果想提取一帧保存为照片的话,可以用截屏的功能实现,操作步骤如下:

    iphone视频提取一帧保存照片

    1、打开手机的照片app,点击下方的“相簿”按钮,进入到相册的页面中。

    2、点击“视频”按钮,进入视频的相册中。

    3、打开视频后点击右上角的“编辑”按钮,进入编辑页面。

    4、滑动时长框到需要的图片后进行截图保存即可。

    操作环境

    品牌型号:iPhone13

    系统版本:ios15.3.1

  • iphone视频提取一帧保存照片

  • iphone视频提取一帧保存照片,可以在视频编辑内进行截屏保存,以下是具体操作步骤:

    工具/原料:iPhone13、iOS15.1、本地设置。

    1、打开视频

    打开苹果,进入相册中的视频,打开你需要编辑的视频。

    2、视频截图

    打开视频,点击右上角的编辑,进入编辑页面,滑动时长框到你需要的图片后点击截图。

    3、调整图片

    截图后,打开图片点击编辑,将图片校正到合适大小,即可完成保存图片。

    最新文章 更多
    最新素材 更多
    公司介绍 网站地图 图片资讯
    Copyright © 2010-2022 山东找图网络科技有限公司  鲁ICP备18007836号-3  邮箱:15653358549@163.com