ios开发之AVFoundation总结

1, Using Assets [自己理解为:数据的来源] 
这个资源可以来自自己的ipod媒体库或图片也可以时文件 
creating an Asset Object 
NSRUL *url = 后跟一个网址 如电影文件等资源 
AVURLAsset *ansset = [[AVURLSset alloc] initwithURL:url  options:nil]; 
2.获得一个视频的图像 
使用AVASsetImageGenerator类来实现 
用来生成图像序列 
3.Playback 
我们在播放视频时可以使用AVPlayer和AVQueuePlayer播放AVPlayer是AVQueuePlayer的父类 
a先创建一个路径 
b可以使用AVPlayerItem加载路径 
c使用AVPlayer播放文件 
当然我们还可以控制它的播放速度 
使用rate属性它是一个介于0.0--1.0之间的数 
 
我们也可以播放多个项目 
NSArray *items  = // 设置一个播放的组合 
AVQueuePlayer *queueplayer = [[AVQueuePlayer alloc]initwithItems:items]; 
然后使用AVPlayerItem  
AVPlayerItem *anItem = // get  a player item 
使用canInsertItem:afterItem 测试 
4.Media capture 
我们可以配置预设图片的质量和分辨率 
Symbol                                                    Resolution        Comments 
AVCaptureSessionPresetHigh        High                  Highest recording quality. This varies per device. 
AVCaptureSessionPresetMedium      Medium            Suitable for WiFi sharing. The actual values may change. 
AVCaptureSessionPresetLow        Low                        Suitable for 3g sharing. The actual values may change. 
AVCaptureSessionPreset640x480    640x480      VGA 
AVCaptureSessionPreset1280x720    1280x720    720p HD 
AVCaptureSessionPresetPhoto                Photo      Full photo resolution. This is not supported for video output 
判断一个设备是否适用 
AVCaptreSessuion *session = [[AVCaptureSession alloc]init]; 
if([session canSetSessionPreset:AVCaptureSessionPrese 1280x720]){ 
session.sessionPreset = AVCaptureSessionPreset 1280x720; 
}else{ 
// Handle the failure. 

当然在 
[session beginConfigration], 
[session commitconfiguration]之间配置重新添加你想要适用的设备以及删除以前的设备等操作 
5.当我们不知道设备的一些特性时我们可以使用以下代码查找相应的设备 
NSArray *devices = [AVCaptureDevice devices]; 
fo(AVCaptureDevice *device in device){ 
NSLogO("Device name %@",[devic localizedName]); 
当然还可以判断设备的位置 
if([device hasMediaType:AVMediaTypeVideo]){ 
if([device postion] == AVCaptureDevicePostionBack){ 
nslog(@"Device postion :back"); 
}else{ 
NSLog(@"Device postion :front"); 



下面的demo说明如何找到视频输入设备 
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; 
NsMutableArray *torchDevices =  [[NSMutableArray alloc]init];  
for(AVCaptureDevice *device in devices){ 
if([device hasTorch]&&[device supportsAVCaptureSessionPreset:AVCaptureSessionPreset 640x480]){ 
[torchDevices addObject:device]; 


 
6设备间切换 
AVCaptureSession *session = //一个设备session 
[session beginConfiguration]; 
 
[session removeInput:frontFacingCameraDeviceInput]; 
[session AddInput:backFacikngCameraDeviceInput]; 
 
[session commitConfiguration]; 
 
7 配置AVCaptureDeviceInput  
AVCaptureSession *captureSession = <#Get a capture session#>;  
AVCaptureDeviceInput *captureDeviceInput = <#Get a capture device input#>;  
// 检查是否适用 
if ([captureSession canAddInput:captureDeviceInput]) { 
// 适用则添加 
[captureSession addInput:captureDeviceInput]; 
} else { 
// Handle the failure. 

8 配置AVCaptureOutput 
输出的类型: 
  a.AVCaptureMovieFileOutput 输出一个电影文件 
b.AVCaptureVideoDataOutput 输出处理视频帧被捕获 
c.AVCaptureAudioDataOutput 输出音频数据被捕获 
d.AVCaptureStillImageOutput 捕获元数据 
AVCaptureSession *captureSession = <#Get a capture session#>; 
AVCaptureMovieFileOutput *movieInput = <#Create and configure a movie output#>;  
if ([captureSession canAddOutput:movieInput]) { 
[captureSession addOutput:movieInput]; 
} else { 
// Handle the failure. 

9 保存到一个电影文件 
AVCaptureMovieFileOutput *aMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init]; 
CMTime maxDuration = <#Create a CMTime to represent the maximum duration#>; aMovieFileOutput.maxRecordedDuration = maxDuration;  
aMovieFileOutput.minFreeDiskSpaceLimit = <#An appropriate minimum given the quality of the movie format and the duration#>; 
10 录音设备 
The delegate must conform to the  
AVCaptureFileOutputRecordingDelegate  
protocol,  
and must implement the  
captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error: method. 
11 像素和编码格式 
iphone 3G      iphone 3GS                      iphone 4 
yuvs,2vuy,BGRA,jpeg    420f,420v,BGRA,jpeg        420f, 420v, BGRA, jpeg 
12  静态图像捕捉 
AVCaptureStillImageOutput *stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; 
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG,AVVideoCodecKey, nil]; [stillImageOutput setOutputSettings:outputSettings]; 
13 重力模式 
The preview layer supports three gravity modes that you set using videoGravity: 
● AVLayerVideoGravityResizeAspect: This preserves the aspect ratio, leaving black bars where the 
video does not fill the available screen area. 
● AVLayerVideoGravityResizeAspectFill: This preserves the aspect ratio, but fills the available screen area, cropping the video when necessary. 
● AVLayerVideoGravityResize: This simply stretches the video to fill the available screen area, even if doing so distorts the image. 
 
 
设备之间切换 
- (AVCaptureDevice *)cameraWithPosition:(AVCaptureDevicePosition)position 

    NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; 
    for ( AVCaptureDevice *device in devices ) 
        if ( device.position == position ) 
            return device; 
    return nil; 

 
- (void)swapFrontAndBackCameras { 
    // Assume the session is already running 
 
    NSArray *inputs = self.session.inputs; 
    for ( AVCaptureDeviceInput *input in inputs ) { 
        AVCaptureDevice *device = input.device; 
        if ( [device hasMediaType:AVMediaTypeVideo] ) { 
            AVCaptureDevicePosition position = device.position; 
            AVCaptureDevice *newCamera = nil; 
            AVCaptureDeviceInput *newInput = nil; 
 
            if (position == AVCaptureDevicePositionFront) 
                newCamera = [self cameraWithPosition:AVCaptureDevicePositionBack]; 
            else 
                newCamera = [self cameraWithPosition:AVCaptureDevicePositionFront]; 
            newInput = [AVCaptureDeviceInput deviceInputWithDevice:newCamera error:nil]; 
 
            // beginConfiguration ensures that pending changes are not applied immediately 
            [self.session beginConfiguration]; 
 
            [self.session removeInput:input]; 
            [self.session addInput:newInput]; 
 
            // Changes take effect once the outermost commitConfiguration is invoked. 
            [self.session commitConfiguration]; 
            break; 
        } 
    }  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
电影网址大全,吸取了以往各种导航网址程序的优点,最大程度的完善优化了各项功能和指标,采用谁对我站贡献大,我站也给予他宣传和展示的机会就越多的流量交换模式,只要您在本系统注册登记您的网址,然后在你网站做好我站连接或是挂上流量互换代码,每次您网站有用户访问到放置我站流量互换代码的站,那么你的网站将在最近入站以及你网站所在分类的第一位置!连接双方公正平等。 1.管理目录admin,管理员用户名19mt,密码19mtcom 2.修改数据库名19mtcom.asa修改成自己想要的名即可! 3.后台分类建议自己修改,要不大家的分类都相同影响百度收录。 ☆系统前台简介☆ 1.采用ASP+ACCESS架构,安全稳定,防注入功能; 2.新闻文章发布功能支持无限级分类,方便自由; 3.数据库经过防下载等安全处理,后台可超强命名,随意改动; 4.每来访一个IP,来访网站就会自动排到第一,当天来路不同,显示颜色也不同,鼓励点入; 5.前台统计数据调用,最新点入网站调用,未审核网站调用等; 6.申请加入电影网址大全的网站按最后点进的时间排序首页和分类显示链接; 7.分类以昨日点入时间为准,每晚十二点后生成静态; 8.每来访一个IP,就会自动排到第一,当天来路次数不同,显示颜色也不同:有1次即显示,10次即套蓝色,30次即套红色加粗; 9.首页白天3分钟,晚上5分钟自动更新一次,全站24小时手动更新一次; 10.站内搜索功能,方便用户找到自己想要的网址; 11.程序全面优化和升级,增强对搜索引擎的收录功能; 12.流量互换功能,最大程度互换流量。 ☆系统后台功能详细说明☆ ☆网站管理系统 1.网站基本信息,说明:里面设置,网站标题,LOGO,关键词,统计代码,版权信息! 2.图片广告管理,说明:网站所有图片广告修改的地方,在首页可以看到所有图片广告,其中ads09是在网址内页显示!其它的都在首页和分类页有位置显示! 3.顶部文字广告管理,说明:这里的文字,首页,特别推荐里面显,分类首页和分类页,记得,改后要在生成html管理里,生成一下首页! 4.添加商家文字广告,说明:这里的文字,首页,中间部分,广告,那里的文字,在图片广告下面,一行七个! 5.管理商家文字广告,说明:修改删除商家文字广告! 6.管理帐号设置,说明:管理员用户名,密码的修改! 9.客户留言管理,说明:留言本的回复,修改和删除! ☆网站分类管理 1.类别添加管理,说明:分类添加删除管理,这里说明一下添加时有首页显示,导航就显示在首页上面,添加时选酷站显示,就在首页下面酷站里调用! 2.类别删除管理,说明:删除不想要的分类! 3.类别修改管理,说明:分类修改里,有显示,[首][酷]就是上面说明的首页显示,和酷站显示! ☆网址管理系统 1.添加网址链接,说明:用于后台管理员手工添加网址 2.添加实用查询|管理实用查询,说明:添加后在首页实用工具里显示! 3.添加名站导航|管理名站导航,说明:添加后在首页名站导航里显示! 4.添加友情链接|管理友情链接,说明:添加后在首页下部友情链接里显示! 5.查看所有的网址,说明:包含站长加的和用户自己加的! 6.站长加入的网址,说明:站长加入的网址! 7.用户加入已审核,说明:用户提交的网址,并通过审核的,说明一下,本站有自动审核功能,开启关闭,在 网站管理系统-网站基本信息里设置! 8.用户加入未审核,说明:用户提交的网址没审的,也就是没有作上本站链接的,或是作上链接没有点击到本站的! 9.有来路入未审核,说明:一般用户认为,有来路就应当审核了,这个功能,是为了关闭自动审核而设计的,手工审核的不管有没有来路,都要站长审核的! 10.加入黑名单网站,说明:加入黑名单的网址,点击这个导航,进入后,可以删除,和取消黑名单! 11.总来路小于五次,说明:本设计用于客户作上本站链接,点入量过小,没有贡献的站,可以多选删除! 12.常用维护共三项,说明:(1)开通所有未审的,一般不用这个,如果想要提交的站就收录,可以点击这个功能!(2)删除重复的网站,有一些站长提交过了,又提交了多次或是用二级域名提交,这样可以删除重复的网站!(3)删除所有未审核的站点,(4)清空所有网址,这个点时要注意,点击了,所有网址就都没有了! 13.站内报错,说明:用户在网址详提交网址打不开的情况页点击的! 14.站内网站搜索,说明:可以按名称,按网址,按分类,按ID号进行搜索! ☆模版修改管理 首 页 模版修改 分类页模版修改 关于本站页模板 (这里建议会一些HTML知识的站长修改,如果不会不建议修改以免出错,修改时一定要备份) ☆生成html管理 生成分类页面 生成生成主页及其他页 重置统计数据 清除昨天点入数据 清除总点入数据 清除总点出数据 (

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值