Tag: 压缩

解决混乱

解决混乱。 我正在提供压缩video,为iOS应用程序提供尽可能高的分辨率。 这些是最后的和最新的格式? 1920 x 1080- iPad 3 + / 1136 x 640- iPad 2,迷你型,iPhone 4,5 / 480 x 270- iPhone,非视网膜 还有什么我需要知道的?

如何减less手机上通过我的iOS应用程序录制的video的文件大小

我正在制作iOS应用程序(即将推出Android),其中涉及用户通过应用程序在手机上录制video。 但我需要的应用程序来减less这些video的默认大小,以便当他们上传到我的服务器使用较less的带宽,并上传得更快。 什么是最好的方法来做到这一点?

上传时压缩图像

我想在服务器上传图片。 但在上传之前,我想压缩该图像,然后上传到服务器。 我不想上传2 MB以上的图片。 我已经使用这个逻辑,但是如果图像尺寸很大,那么它不运行。 的循环,并且在处理过程中也占用了1GB的内存。 double compressionRatio=1; NSData *imgData=UIImagePNGRepresentation(proImage.image,compressionRatio); while ([imgData length]>50000) { compressionRatio=compressionRatio*50; imgData=UIImageJPEGRepresentation(proImage.image,compressionRatio); }

AVAssetWriter输出大文件(即使应用压缩设置)

我正在开发一个个人iOS项目,要求全屏video(15秒长)通过4G连接上传到后端。 虽然我可以拍摄video,但是文件的输出大小已经达到了30MB,这让我觉得我在压缩方面做了很大的错误。 以下是我用来设置AssetWriter的代码: -(void)captureOutput:(AVCaptureFileOutput *)captureOutput didStartRecordingToOutputFileAtURL:(NSURL *)fileURL fromConnections:(NSArray *)connections { NSLog(@"Started Recording! *******************"); self.movieWriter = [AVAssetWriter assetWriterWithURL:fileURL fileType:AVFileTypeMPEG4 error:nil]; [self.movieWriter setShouldOptimizeForNetworkUse:YES]; NSDictionary *videoCleanApertureSettings = @{ AVVideoCleanApertureWidthKey: [NSNumber numberWithFloat:self.view.frame.size.width], AVVideoCleanApertureHeightKey: [NSNumber numberWithFloat:self.view.frame.size.height], AVVideoCleanApertureHorizontalOffsetKey: [NSNumber numberWithInt:10], AVVideoCleanApertureVerticalOffsetKey: [NSNumber numberWithInt:10], }; NSDictionary *videoCompressionSettings = @{ AVVideoAverageBitRateKey: [NSNumber numberWithFloat:5000000.0], AVVideoMaxKeyFrameIntervalKey: [NSNumber numberWithInteger:1], AVVideoProfileLevelKey: AVVideoProfileLevelH264Baseline30, AVVideoCleanApertureKey: videoCleanApertureSettings, }; NSDictionary *videoSettings […]

压缩从设备或从图书馆,iOSselect的图像

在我的应用程序中,用户可以从设备拍摄照片或从图库中上传照片,将其设置为他的个人资料照片。 现在当用户完成后,我需要将该图像上传到服务器。 通常来自设备的图像大小为5-6MB。 我需要它上传到服务器之前压缩到25KB。 所以我正在使用以下方法 – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; [picker release]; profilePicImageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; NSData* pngData = UIImagePNGRepresentation(profilePicImageView.image); NSLog(@"image size of png is %d", [pngData length]); NSData *imageData = UIImageJPEGRepresentation(profilePicImageView.image, 0.00001); NSLog(@"image size is %d", [imageData length]); } 这个方法的问题是,无论我设置缩放参数有多小,压缩文件的大小都不会低于〜230KB,这比我所需要的高出近10倍。 上述方法有什么问题? 我不能将图像压缩到25KB? 任何帮助,build议将不胜感激。

AVAssetExportSession输出文件

AVAssetExportSession输出文件应该如何? 我试图从一个ALAsset项目压缩video,它不起作用。 我猜输出文件与它有关。 这里是我使用的代码: NSString *destinationPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie"]; [self convertVideoToLowQualityWithInputURL:asset.defaultRepresentation.url outputURL:[NSURL URLWithString:destinationPath]]; – (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL { if([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithContentsOfURL:outputURL encoding: 0 error:Nil]]) [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *assetAV = [AVURLAsset URLAssetWithURL:inputURL options:nil]; NSLog(@"url string from asset: %@", assetAV.URL); NSLog(@"output url: %@", [outputURL absoluteString]); [[NSFileManager defaultManager] createFileAtPath:[outputURL path] contents:nil attributes:nil]; NSLog(@"duration: %lld", assetAV.duration.value); //it […]

将图片上传到Firebase

我正尝试将图片上传到Firebase,如下所示: Firebase *ref = [[Firebase alloc] initWithUrl:@"https://<app-name>.firebaseio.com/posts"]; Firebase *newPost = [ref childByAutoId]; NSDictionary *newPostData = @{ @"image" : [self encodeToBase64String:image] }; [newPost updateChildValues:newPostData]; 我正在使用此代码来编码图像: – (NSString *)encodeToBase64String:(UIImage *)image { return [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; } 但是,这不符合string的最大尺寸: Terminating app due to uncaught exception 'InvalidFirebaseData', reason: '(updateChildValues:) String exceeds max size of 10485760 utf8 bytes: 我能做些什么来解决这个问题? 在使用Firebase时,我没有在网上find关于iOS开发和图片的任何信息。

video压缩ios:使用AVAssetWriter缩小video的大小

我成功地使用AVAssetWriter和AVAssetWriterInput将由AVFoundation Framework的AVCaptureVideoPreviewLayer捕获的一系列图像编码为video。 但是video的大小太大了,在这种情况下,你们中的任何一个人都可以给我一个教程或者是一个直接的我,或者给我正确的video输出设置来进行video压缩。 我正在使用以下VideoOutputSetting。 videoOutputSettings = @{ AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: [NSNumber numberWithInt:width], AVVideoHeightKey: [NSNumber numberWithInt:height], AVVideoCompressionPropertiesKey: @{ AVVideoAverageBitRateKey: [NSNumber numberWithInt:bitrate], AVVideoMaxKeyFrameIntervalKey: @(150), AVVideoProfileLevelKey: AVVideoProfileLevelH264BaselineAutoLevel, AVVideoAllowFrameReorderingKey: @NO, AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCAVLC, AVVideoExpectedSourceFrameRateKey: @(30), AVVideoAverageNonDroppableFrameRateKey: @(30) } }; videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings]; _videoWriterInput.expectsMediaDataInRealTime = YES;

在iPhone上将.caf转换为.mp3

我意识到这个问题之前已经被问过了,但是我还没有看到一个适合我需要的答案。 基本上我有.caf格式的全长歌曲,但我需要能够从服务器上传/下载它们。 是否可以在iPhone上进行压缩(如.mp3或.wav),然后将它们发送到服务器? 我怎么去做这个?

压缩图像以减小文件大小

我正在构build一个应用程序,让用户拍照或从iPhone上的库中select一个,并将其上传到Parse后端。 我面临的问题是关于文件的大小。 我已经读过关于像Facebook,Twitter,Instagram和Google这样的大玩家在parsing和文件大小方面做了些什么,但是我不能接近它。 我相信他们有最好的代码和工具来做到这一点,但我很乐意尽可能在iOS常规stream程中实现它。 这就是我现在正在做的事情: – (UIImage *)normalResImageForAsset:(ALAsset*)asset { // Convert ALAsset to UIImage UIImage *image = [self highResImageForAsset:asset]; // Determine output size CGFloat maxSize = 1024.0f; CGFloat width = image.size.width; CGFloat height = image.size.height; CGFloat newWidth = width; CGFloat newHeight = height; // If any side exceeds the maximun size, reduce the greater side […]