欢迎光临,广州澳门威尼斯人官网,澳门威尼斯城,澳门威尼斯赌场公司!                                           Tel:400-888-9999

当前位置:官网首页 > 新闻动态 > 公司新闻 > 公司新闻

iOS 录像功能的简单实现

// accessing video by url avurlasset *videoasset = [[avurlasset alloc] initwithurl:videourl options:nil]; // find compatible presets by video asset. nsarray *presets = [avassetexportsession exportpresetscompatiblewithasset:videoasset]; // begin to compress video // now we just compress to low resolution if it supports // if you need to upload to the server, but server does t support to upload by streaming, // you can compress the resolution to lower. or you can support more higher resolution. //开端紧缩视频 //现在咱们紧缩到低分辨率是否支撑 //假如需求上传服务器,但由流媒体服务器不支撑上传, //能够紧缩分辨率下降。或许你能够支撑更多的高分辨率。 if { avassetexportsession * session = [[avassetexportsession alloc]initwithasset:videoasset presetname:avassetexportpreset640x480]; //nshomedirectory 得到的是应用程序目录的途径,在该目录下有三个文件夹:documents、library、temp以及一个.app包!该目录下便是应用程序的沙盒,应用程序只能拜访该目录下的文件夹!!! nsstring * doc = [nshomedirectory stringbyappendingpathcomponent:@ documents nsstring * folder = [doc stringbyappendingpathcomponent:@ 录制视频 bool isdir = no; bool i___ist = [[nsfilemanager defaultmanager] fileexistsatpath:folder isdirectory: isdir]; if ) { nserror * error = nil; [[nsfilemanager defaultmanager]createdirectoryatpath:folder withintermediatedirectories:yes attributes:nil error: error]; if { [svprogresshud showinfowithstatus:@ 目录创立成功 } else { [svprogresshud showinfowithstatus:@ 目录创立失利 nsstring * outputpath = [folder stringbyappendingpathcomponent:savedname]; session.outputurl = [nsurl fileurlwithpath:outputpath]; // optimize for network use. session.shouldoptimizefornetworkuse = true; nsarray * supportedtypearray = session.supportedfiletypes; if { session.outputfiletype = avfiletypempeg4; } else if { [svprogresshud showinfowithstatus:@ no supported file types return; } else { session.outputfiletype = [supportedtypearray objectatindex:0]; // begin to export video to the output path asynchronously. //开端出口异步视频输出途径。 [session exportasynchronouslywithcompletionhandler:^{ if { dispatch_async, ^{ if { completion, ^{ if { completion; - didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can be recreated. #pragma mark - 相关特点参数 * 署理 delegate 几个根本特点设置 sourcetype //设置资源获取类型 allowsediting //是否答应图片修改 几个判别类办法 *是否能够获取该类型资源 + issourcetypeavailable:sourcetype; *是否能够获取该类型相机 + iscameradeviceavailable:cameradevice; *是否能够获取闪光灯 + isflashavailableforcameradevice:cameradevice; 署理办法 - imagepickercontroller:picker didfinishpickingmediawithinfo:info; - imagepickercontrollerdidcancel:picker; * 参数info中的键 nsstring *const uiimagepickercontrollermediatype ;指定用户挑选的媒体类型 nsstring *const uiimagepickercontrolleroriginalimage ;原始图片 nsstring *const uiimagepickercontrollereditedimage ;修改后的图片 nsstring *const uiimagepickercontrollercroprect ;裁剪尺度 nsstring *const uiimagepickercontrollermediaurl ;媒体的url nsstring *const uiimagepickercontrollerreferenceurl ;原件的url nsstring *const uiimagepickercontrollermediametadata;当来数据来历是照相机的时分这个值才有用 * uiimagepickercontrollermediatype uiimagepickercontrollermediatype 包括着kuttypeimage 和kuttypemovie kuttypeimage 包括: const cfstringref kuttypeimage ;笼统的图片类型 const cfstringref kuttypejpeg ; const cfstringref kuttypejpeg2000 ; const cfstringref kuttypetiff ; const cfstringref kuttypepict ; const cfstringref kuttypegif ; const cfstringref kuttypepng ; const cfstringref kuttypequicktimeimage ; const cfstringref kuttypeappleicns const cfstringref kuttypebmp; const cfstringref kuttypeico; kuttypemovie 包括: const cfstringref kuttypeaudiovisualcontent ;笼统的声响视频 const cfstringref kuttypemovie ;笼统的媒体格式 const cfstringref kuttypevideo ;只要视频没有声响 const cfstringref kuttypeaudio ;只要声响没有视频 const cfstringref kuttypequicktimemovie ; const cfstringref kuttypempeg ; const cfstringref kuttypempeg4 ; const cfstringref kuttypemp3 ; const cfstringref kuttypempeg4audio ; const cfstringref kuttypeappleprotectedmpeg4audio;