在特定时间戳记的ALAsset缩略图 [英] ALAsset thumbnail at specific timestamp

查看:102
本文介绍了在特定时间戳记的ALAsset缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个iPhone应用程序,用于将视频文件上传到特定平台,我真正喜欢的一项功能是能够为同一视频呈现十个不同的缩略图,以供用户选择

I'm working working on an iPhone application for uploading video files to a specific platform, and one feature I would really love is to be able to present, say, ten different thumbnails for the same video for the user to pick from.

问题是,ALAsset仅提供 thumbnail 方法,该方法仅返回默认缩略图。我已经阅读了ALAssetRepresentation和ALAsset文档,但似乎找不到找到特定时间戳的缩略图的方法。

The problem is, that ALAsset only provides a thumbnail method, which just returns the default thumbnail. I have read through the ALAssetRepresentation and ALAsset documentation and I can't seem to find a way to get a thumbnail for a specific timestamp.

我猜一个选择是使用一些类似libav的东西来获取缩略图,但是对于像这样的东西来说似乎有点过顶。有人可以帮我吗?

I guess one option would be to use something along the lines of libav to get thumbnails but that seems a little "over the top" for something like this. Can anyone help me on this one?

最好的问候,

尼克

Best regards,
Nick

推荐答案

我认为这会对您有所帮助,并且
您还可以通过此提示查看
在ALAsset中缺少视频文件缩略图时间戳

i think this will help you , and you can also see through this prompt Video File thumbnail timestamp missing in ALAsset

{

  if ([theAsset valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo) {

        // Black semi-transparent background at the bottom of the item
        CGRect containerFrame = CGRectMake(0, frame.size.height - AGIPC_ITEM_HEIGHT, frame.size.width, AGIPC_ITEM_HEIGHT);
        UIView *containerForMovieInfo = [[[UIView alloc] initWithFrame:containerFrame] autorelease];
        containerForMovieInfo.backgroundColor = [UIColor blackColor];
        containerForMovieInfo.alpha = 0.7f;

        // Movie icon on left side
        CGRect movieFrame = CGRectMake(4, 60, 26, 15);
        UIImageView *movieImageView = [[[UIImageView alloc] initWithFrame:movieFrame] autorelease];
        if (IS_IPAD()) {
            movieImageView.image = [UIImage imageNamed:@"AGIPC-Movie-iPad"];
        } else {
            movieImageView.image = [UIImage imageNamed:@"AGIPC-Movie-iPhone"];
        }
        [containerForMovieInfo addSubview:movieImageView];

        // Movie duration on right side
        if ([theAsset valueForProperty:ALAssetPropertyDuration] != ALErrorInvalidProperty) {
            NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
            [formatter setDateFormat:@"mm:ss"];
            CGRect durationFrame = CGRectMake(frame.size.width - 26 - 4, 60, 26, 15);
            UILabel *durationView = [[[UILabel alloc] initWithFrame:durationFrame] autorelease];
            durationView.backgroundColor = [UIColor clearColor];
            durationView.textColor = [UIColor whiteColor];
            durationView.text = [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[theAsset valueForProperty:ALAssetPropertyDuration] doubleValue]]];
            durationView.font = [UIFont systemFontOfSize:10];
            [containerForMovieInfo addSubview:durationView];
        }

        [self addSubview:containerForMovieInfo];
    }

}

最后但并非最不重要的一点是,您必须自己创建相机的图像。

last but not least, you must creat the image of the camera on your own.

这篇关于在特定时间戳记的ALAsset缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆