2016-11-07 62 views
0

我捕获屏幕记录并将其输出到文件。而我的mac是视网膜。AVAsset视频大小(宽*高)

我通过获取文件大小:

self.asset = [AVAsset assetWithURL:_assetURL]; 

AVAssetTrack *track = [[self.asset tracksWithMediaType:AVMediaTypeVideo] firstObject]; 
self.vedioNaturalSize = CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform); 

,但是这个尺寸的像素,我想在点的大小。

当我在QuickTime中播放视频时,我发现初始窗口大小不是以像素为单位,而是我只能以像素为单位获取大小。

有没有人知道这个方法,非常感谢。

回答

0

试试这个代码转换pixelToPoints

+(CGFloat)pixelToPoints:(CGFloat)px { 
CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem 
CGFloat scale = 1; // We dont't use [[UIScreen mainScreen] scale] as we don't want the native pixel, we want pixels for UIFont - it does the retina scaling for us 
float pixelPerInch; // aka dpi 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
    pixelPerInch = 132 * scale; 
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
    pixelPerInch = 163 * scale; 
} else { 
    pixelPerInch = 160 * scale; 
} 
CGFloat result = px * pointsPerInch/pixelPerInch; 
return result; 
} 
+0

感谢您的帮助,我会尝试。但我实际上想知道它是否存在API来获取资产的重点。 – melody5417