为什么iOS上使用Ionic cordovaCapture(Apache Cordova媒体捕获插件)录制低分辨率视频(480x360)?

时间:2015-08-12 13:31:05

标签: cordova ionic-framework html5-video phonegap-plugins cordova-plugins

在Ionic项目中,我正在录制cordova capture plugin的视频,而这些视频实际上基于Apache media-capture plugin

Android用户可以选择视频尺寸,但在iOS上没有按钮。我正在测试一台录制在1920x1080的iPhone 5,但是我的Ionic应用视频是480x360,注意长宽比是4:3而不是16:9。 我想要至少720p视频尺寸

我阅读了插件文档,只有三个选项;持续时间和限制。这是否意味着无法设置视频的尺寸?

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) {});

此外,我看到Configuration Data部分。我不知道我应该使用它。我尝试将widthheight添加到选项对象,但我的结果与之前相同。

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

据说任何平台都不支持,这不是很奇怪吗? : - )

  

任何平台都不支持。所有配置数据阵列都是   空。

知道我该怎么办?

1 个答案:

答案 0 :(得分:3)

我之前修复了这个问题,我编辑了captureVideo插件。

无法为所有设备设置分辨率。如果选择高,则表示某些设备为1080p,例如旧设备为720p。

在JS上我为插件选项添加了一个新属性'ios_quality':

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

在CDVCapture.m上,我在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;
}