我在我的Mac上有一个10位的视频,我想在完整的10位/频道的数据中提取帧。我加载我的资产,并验证它是10位:
CMFormatDescriptionRef formatDescriptions = (__bridge CMFormatDescriptionRef)(track.formatDescriptions[0]);
float frameRate = track.nominalFrameRate;
int bitDepth = ((NSNumber*)CMFormatDescriptionGetExtension(formatDescriptions, (__bridge CFStringRef)@"BitsPerComponent")).intValue;对于许多视频,bitDepth是8,但对于这个视频(我知道我记录了10位),所以AVFoundation正确地识别了频道位深度。
但是,我想使用AVAssetImageGenerator的copyCGImageAtTime:actualTime:error:方法从视频中生成单个帧:
NSError *err;
NSImage *img = [[NSImage alloc] initWithCGImage:[imageGenerator copyCGImageAtTime:time actualTime:NULL error:&err] size:dimensions];图像生成成功,没有任何错误,但是当我检查它时,我发现它是8位/通道:
(lldb) po img
<NSImage 0x600001793f80 Size={3840, 2160} Reps=(
"<NSCGImageSnapshotRep:0x6000017a5a40 cgImage=<CGImage 0x100520800>
(DP)\n\t<<CGColorSpace 0x60000261ae80> (kCGColorSpaceICCBased;
kCGColorSpaceModelRGB; Composite NTSC)>\n\t\twidth = 3840, height = 2160,
bpc = 8, bpp = 32, row bytes = 15360
\n\t\tkCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Big |
kCGImagePixelFormatPacked \n\t\tis mask? No, has masking color? No,
has soft mask? No, has matte? No, should interpolate? Yes>"
)>如何从10位视频生成完整的、无损的10位(或者,为了兼容,16位或32位)帧?
我在macOS 10.14。
发布于 2018-10-26 12:57:04
由于缺乏有关这方面的任何信息,我放弃了AVAssetImageGenerator,开始在我的应用程序中嵌入ffmpeg并调用它来提取10位帧。
https://stackoverflow.com/questions/52979497
复制相似问题