Tag: 压缩

这是gzip膨胀方法中的错误吗?

当search如何在iOS上对gzip压缩数据进行充气时,结果数量出现以下方法: – (NSData *)gzipInflate { if ([self length] == 0) return self; unsigned full_length = [self length]; unsigned half_length = [self length] / 2; NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; BOOL done = NO; int status; z_stream strm; strm.next_in = (Bytef *)[self bytes]; strm.avail_in = [self length]; strm.total_out = 0; strm.zalloc = Z_NULL; […]

AVAssetWriter如何创build没有压缩的movvideo?

我从一系列图像创buildvideo。 我的工作的目的是创build一个没有压缩的.movvideo。 我已经在开发库中看到它存在一个关键“AVVideoCompressionPropertiesKey”,但我不知道如何用这个键指定没有压缩。 请问你能帮帮我吗? 这是我的示例代码: NSDictionary *videoCleanApertureSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:320], AVVideoCleanApertureWidthKey, [NSNumber numberWithInt:480], AVVideoCleanApertureHeightKey, [NSNumber numberWithInt:10], AVVideoCleanApertureHorizontalOffsetKey, [NSNumber numberWithInt:10], AVVideoCleanApertureVerticalOffsetKey, nil]; NSDictionary *codecSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:960000], AVVideoAverageBitRateKey, [NSNumber numberWithInt:1],AVVideoMaxKeyFrameIntervalKey, videoCleanApertureSettings, AVVideoCleanApertureKey, nil]; NSDictionary *videoOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,codecSettings,AVVideoCompressionPropertiesKey, [NSNumber numberWithInt:size.width], AVVideoWidthKey, [NSNumber numberWithInt:size.height], AVVideoHeightKey, nil]; self.videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoOutputSettings];

IOSvideo压缩Swift iOS 8损坏的video文件

我试图压缩来自UIImagePickerController(不是现有的video,而是一个dynamic的)用户相机拍摄的video上传到我的服务器,需要一点时间这样做,所以更小的尺寸是理想的,而不是30- 45 mb在较新的质量相机。 这里是在iOS 8中快速执行压缩的代码,它压缩得非常好,我轻松地从35毫秒降低到2.1毫秒。 func convertVideo(inputUrl: NSURL, outputURL: NSURL) { //setup video writer var videoAsset = AVURLAsset(URL: inputUrl, options: nil) as AVAsset var videoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo)[0] as AVAssetTrack var videoSize = videoTrack.naturalSize var videoWriterCompressionSettings = Dictionary(dictionaryLiteral:(AVVideoAverageBitRateKey,NSNumber(integer:960000))) var videoWriterSettings = Dictionary(dictionaryLiteral:(AVVideoCodecKey,AVVideoCodecH264), (AVVideoCompressionPropertiesKey,videoWriterCompressionSettings), (AVVideoWidthKey,videoSize.width), (AVVideoHeightKey,videoSize.height)) var videoWriterInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: videoWriterSettings) videoWriterInput.expectsMediaDataInRealTime = true videoWriterInput.transform […]

iPhone解压缩代码

真的停留在尝试编写代码来解压缩iPhone上的文件或目录。 以下是我正在使用的一些示例代码来尝试解压简单的文本文件。 它解压缩文件,但它的腐败。 (void)loadView { NSString *DOCUMENTS_FOLDER = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *path = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"sample.zip"]; NSString *unzipeddest = [DOCUMENTS_FOLDER stringByAppendingPathComponent:@"test.txt"]; gzFile file = gzopen([path UTF8String], "rb"); FILE *dest = fopen([unzipeddest UTF8String], "w"); unsigned char buffer[CHUNK]; int uncompressedLength = gzread(file, buffer, CHUNK); if(fwrite(buffer, 1, uncompressedLength, dest) != uncompressedLength || ferror(dest)) { NSLog(@"error writing data"); } else{ […]