Background:
I am recording a video and then uploading it.
Problem:
I compressed the video using this solution (medium quality) but it doesn't:
keep the original dimensions of the video
have as good a compression ratio as camera roll's.
I need similar compression (size and dimensions) like camera roll.
If it's not possible, do we have a workaround, say, automatically select the file from the iOS video picker (for upload)?
You can use AVAssetWriter and set custom compression settings. You can even compress the video while you're recording so you don't have to re-process the video before upload. Search around, there's tons of examples.
Related
Im using uiimagepicker for the user to pick a video from photo library.
After setting video quality to low in image picker settings, a 5 minute or even a 2 min recorded video is still too big for upload. Is there anyway to compress the video size further. My guess is that i need to reduce the bitrate.
I am of course using assets to manage the file
I'm working on video processing app for the iPhone using OpenCV.
For performance reasons, I wan't to process live video at a relatively low resolution. I'm doing object-detection on each frame in the video. When the objects are found in the low-resolution video frame, I need to acquire that exact same frame at a much higher resolution.
I've been able to semi-accomplish this using a videoDataBufferOutput and a stillImageOutput from AVFoundation, but the still image is not the exact frame that I need.
Are there any good implementations of this or ideas on how to implement it myself?
In AVCaptureSessionPresetPhoto it use small video preview(about 1000x700 for iPhone6) and high resolution photo(about 3000x2000).
So I use modified 'CvPhotoCamera' class to process small preview and take photo of full-size picture. I post this code here: https://stackoverflow.com/a/31478505/1994445
I am basically using AVAssetExportSession and AVMutableVideoComposition to add my text overlay on top of the video and then compress the video. At the moment, when I compressed the video to AVAssetExportPresetMediumQuality, it also ruined the quality of the text overlay... I dont want this to happen. I just want to lower the quality on the video ONLY and keep the text overlay on top of the video sharp and not pixelated.
Thank You
Compress the video, then add the text overlay.
I'm recording video using AVCaptureSession with the session preset AVCaptureSessionPreset640x480. I'm using an AVCaptureVideoPreviewLayer in a non-standard size (300 x 300) with the gravity set to aspect fill while recording. It's setup like this:
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
_previewLayer.frame = _previewView.bounds; // 300 x 300
[_previewView.layer addSublayer:_previewLayer];
After recording the video, I want to write it to a file in quicktime format. During playback, I'm once again playing the video in a 300 x 300 non-standard size layer. Because these videos will ultimately be transferred over a network connection, it seems wasteful to keep the full 640x480 video.
What's the best way to export a video to match my 300 x 300 preview layer? I'm an AVFoundation noob, so if I'm going about this the wrong way please let me know. I just want the recorded video displayed in the preview layer during recording to match the video that is exported on disk.
Video Resolution and Video Size are two different things. Resolution stands for clarity, higher resolution means higher clarity. Whereas, Video size is the bounds in which to display the video. Depending on the video resolution and aspect ratio of the video, the video will stretch or shrink, when seen in the viewer.
Now as the facts have been explained, You can find Your answer here:
How do I use AVFoundation to crop a video
Perform the steps in this order:
Record Video to disk.
Save from Disk to asset library.
Delete from disk.
Perform the steps mentioned in the above link.
NOTE: Perform the steps after recording and writing your video to asset library, saveComposition being the saved asset.
and provide your size in this step:videoComposition.renderSize = CGSizeMake(320, 240); as videoComposition.renderSize = CGSizeMake(300, 300);
And an advice. Since writing the file to disk, then to library, then again back to disk is kind of a lengthy operation. Try doing it all asynchronously using a dispatch_queue or operationBlock
Cheers, Have Fun.
We have an issue where video generated by our application and saved to camera roll (from user action) will show as black thumbnail on the iOS Photo Gallery instead of a thumbnail of a frame. Once you select the video it will play without any issues on the iOS device or any other device (export to your mac or pc...).
The issue does not occur on the iPhone simulator, only on iOS devices..
We generate the video using AVFoundation (very similiar to this How do I export UIImage array as a movie?)
We then combine the video with an mp3 file using AVMutableVideoComposition. If I extract all frame of video, first frame is not black.
The thumbnail in the Photo Gallery will show as a black square, no time span (on iOS4) shown on the thumbnail. We save the video to camera roll using UISaveVideoAtPathToSavedPhotosAlbum ...
We have changed the video compression type and settings multiple times with no luck. The output is a H264 QuickTimeMovie.
Any ideas ?
Thank you.