Search code examples
javascriptandroidcordovavideocordova-media-plugin

Cordova Video Orientation issue android


I am newbie to cordova & encountering some problem with Cordova Camera plugin in Android.

When taking video in Android, video is captured & saved in portrait mode but the url I am getting after upload is landscape mode :


Video Capture method:

Myscript.SocialVideocapture = function(){
var ramv;
var options = {
limit: 1,
duration: 100000000

};

navigator.device.capture.captureVideo(onSuccess, onError, options);

function onSuccess(mediaFiles) {

    VideoEditor.createThumbnail(
    trimSuccess, // success cb
    trimFail, // error cb
    {
    fileUri: mediaFiles[0].fullPath, // the path to the video on the device
    outputFileName: 'output-name', // the file name for the JPEG image
    atTime: 2, // optional, location in the video to create the thumbnail (in seconds)
    width: 320, // optional, width of the thumbnail
    height: 480, // optional, height of the thumbnail
    quality: 100 // optional, quality of the thumbnail (between 1 and 100)
    }
    );

    ramv=mediaFiles[0].fullPath;
    var cvid=Math.floor((Math.random() * 1000000) + 1);
    socialvideosendurl=mediaFiles[0].fullPath;

}

function onError(error) {


} 
}

File Upload method:

Myscript.Socialsendtoserver = function(event) {



if ($$("#statusbox").val() == '') {
    Appyscript.alert('Please Enter Status', 'Alert!');


} else {

    Appyscript.showIndicator();

    var sfilekey;
    var smimeType;
    var sspath;

    if (socialvideosendurl === undefined || socialvideosendurl === '') {

        sfilekey = "file";
        smimeType = "text/plain";
        sspath = localStorage.getItem("dummysocial");

    } else {

        sfilekey = "video";
        smimeType = "video/quicktime";
        sspath = socialvideosendurl;

    }


    var options = new FileUploadOptions();
    options.fileKey = sfilekey;
    options.fileName = sspath.substr(sspath.lastIndexOf('/') + 1);
    options.mimeType = smimeType;
    var params = new Object();

    options.params = params;
    params.appId = appId;
    params.userId = localStorage.getItem("userid");
    params.status = $$("#statusbox").val();
    params.tag = "myimage";
    params.image = JSON.stringify(sendsoimages);
    params.actionType = "addPost";

    options.params = params;

    options.chunkedMode = false;

    var ft = new FileTransfer();


    ft.upload(sspath, site_url + '/webservices/SocialNetworkPost.php', win, fail, options);


}

}

Original Video File Uploaded

Video File I am getting from server

  • Is it a server end Issue or problem in my code ?

Solution

  • I check my code thoroughly and found that the API which is used for file uploading is changing the orientation of video from portrait to landscape.

    So file uploading code is correct.

    Thanks for considering the question