Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why low resolution video (480x360) recording on iOS with Ionic cordovaCapture (Apache Cordova media capture plugin)?

On an Ionic project I am recording videos with cordova capture plugin which in fact is based on Apache media-capture plugin.

Android users can choose video dimensions, but on iOS there are no buttons for that. I am testing with an iPhone 5 which records in 1920x1080, but with my Ionic app videos are 480x360, notice also aspect ratio is 4:3 no 16:9. I want at least a 720p video dimensions.

I read plugin documentation and there are only three options; duration and limit. Does it means is not possible to set the dimensions of the video?

var options = { 
    limit: 1, 
    duration: 15,
    quality: 1 // Only for Android, Video quality parameter, 0 means low quality, suitable for MMS messages, and value 1 means high quality
}; 

$cordovaCapture.captureVideo(options)
    .then(function(videoData) {});

Besides I saw Configuration Data part. I don't know were should I use that. I tried adding width and height to options object but I have same result as before.

var options = { 
    limit: 1, 
    duration: 15,
    type: "video/quicktime",
    height: 720,
    width: 1280,
    quality: 1
};

It said is not supported by any platform, is not this weird? :-)

Not supported by any platform. All configuration data arrays are empty.

Any idea what can I do?

like image 723
Mikel Avatar asked Aug 12 '15 13:08

Mikel


1 Answers

I fixed this issue time ago, I did editing captureVideo plugin.

Is was not possible to set the resolution for all devices. If you choose high it means 1080p in some devices and eg 720p in old ones.

On the JS I added a new property 'ios_quality' to plugin options:

var options = { 
    limit: 1, 
    duration: 20,
    ios_quality: 'high'
};

On CDVCapture.m I added quality option inside if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {}

// iOS 4.0
if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
    pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;

    NSNumber* quality = [options objectForKey:@"ios_quality"];

    if ([quality isEqual:@("compression_none_640x480")]){ //Compression none
        pickerController.videoQuality = UIImagePickerControllerQualityType640x480;
    }
    else if ([quality isEqual:@("compression_none_960x540")]){ //Compression none
        pickerController.videoQuality = UIImagePickerControllerQualityTypeIFrame960x540;
    }
    else if ([quality isEqual:@("compression_none_1280x720")]){ //Compression none
        pickerController.videoQuality = UIImagePickerControllerQualityTypeIFrame1280x720;
    }
    else if ([quality isEqual:@("high")]){ //Compression low
        pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
    }
    else if ([quality isEqual:@("medium")]){ //Compression medium
        pickerController.videoQuality = UIImagePickerControllerQualityTypeMedium;
    }
    else if ([quality isEqual:@("low")]){ //strongest compression, resolution 192x144
        pickerController.videoQuality = UIImagePickerControllerQualityTypeLow;
    }

    // pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
    // pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    // pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
}
like image 96
Mikel Avatar answered Oct 04 '22 22:10

Mikel