Recording portrait on mobile

I’ve just updated open vidu and I’m happy to see it now records direct to mp4 which has solved a lot of headache, however a new issue has come up.

I don’t specify any resolution in js when creating the stream which seems to let open vidu determine the camera orientation and size, it’s always been ok like this. But after the vidu server update the recordings are always in landscape and the portrait from mobile phone is chopped off at the top and bottom.

I did try to test putting a portrait resolution when creating the stream from js but the recording is still chopped in landscape mode.

Just wondering what has changed in the latest version? Is there a setting I have to send to the api call when generating the stream? So use js to detect the width and height and send those to the server to create the correct dimensions?

I am using a curl api call to my vidu server to create the stream.

On the front end, i am checking if the available device height is greater than the width, and then swiching the resolution around like this:

// init landscape
let resolution = ‘1280x720’;
if(screen.availHeight > screen.availWidth){
// portrait mode
resolution = ‘720x1280’;
}

OVPublisher = OV.initPublisher("publisher-video",{
  videoSource:true,//OVFrontCamID ? OVFrontCamID : OVBackCamID,
  audioSource:true,
  publishAudio:true,
  publishVideo:true,
  resolution:resolution,
  frameRate:30
});

On the back end in php where i make the curl request i am also setting the resolution that is passed from the front end:

// create the session
$this->start(‘sessions’);
$this->setOpt(CURLOPT_POST, true)
->setOpt(CURLOPT_POSTFIELDS,json_encode([
“customSessionId”=>$streamId,
“mediaMode”=> “ROUTED”,
“recordingMode”=> !$record ? “MANUAL” : “ALWAYS”,
“defaultOutputMode”=> “INDIVIDUAL”,
“defaultRecordingProperties”=>(object)[
“resolution”=>$resolution
]
]))
->setOpt(CURLOPT_HTTPHEADER,[
"Authorization: Basic " . base64_encode(“OPENVIDUAPP:”.$this->params->get(‘viduSecret’)),
“Content-Type: application/json”
]);
$this->run()->finish();

Even with these things it doesn’t work right. On the front end my iphone is giving me a landscape video even though i’ve clearly told it to use 720x1280 as the resolution, the recording is the same it’s landscape chopped off

Hello @Glen_Elkins what OpenVidu version do you have deployed?

AFAIK individual recordings don’t use mp4, what OpenVidu version have you deployed?
OpenVidu CE/PRO/Enterprise?

What openvidu-browser?

Regards

They didn’t use mp4, they now do, it has saved a recording as mp4!

The curl i showed states INDIVIDUAL - and the latest version is definitely creating mp4 as i had to change my software which was previously convert to mp4, doesn’t need to now.

The open vidu browser i am using is 2.20.0 and the server is 2.20.0

I know what is happening there. Please take a look to breaking changes on versions updates!:

The API of the recording has changed. You are using COMPOSED recordings.

This is also in the Release Notes section: Releases - OpenVidu Docs

So composed is ok for my needs it creates an mp4 which makes life easier and there will only ever be one person recorded on it.

Is composed mode making the resolution wrong?

No, in fact, I think device orientation should be ok with composed recordings. Try to not specify any resolution and see if the orientation is ok.

Device orientation will be ok in COMPOSED recording, but take into account that the default BEST_FIT layout used in COMPOSED recording can crop the original video resolution.
If your sessions have only a single publisher, then you should be able to not lose any information by setting the exact resolution of the video to the recording. But that would require you to know that resolution of the published stream, of course. And rotating the video (for example a mobile app that suppots device orientation changes) will probably mess up the final result.

If not, you can always build your own custom layout for COMPOSED recodings, and make sure this layout do not crop any video. There, you have total control of what is being recorded.

INDIVIDUAL recording has 2 main advantages: they are much more efficient (will consume just a tiny fraction of CPU compared to COMPOSED recording) and the original video resolution of each stream is always honored. On the other hand, it will probably need some kind of post processing to make the video consumable for final users, of course. Each one has its cons and prons.

Best regards.

But when I take the screen width and height from the javascript part of the site and send that to the server , then make the curl request and include the resolution I want, so might be 200x600 just for argument sake, it totally ignores that! It just crops it in landscape instead of saving at the res I said. Or is that because it has to be rotated?

Hi again

Sorry i think things are getting confused here, if you look at my original code for the CURL request to the vidu server:

// create the session
        $this->start('sessions');
        $this->setOpt(CURLOPT_POST, true)
            ->setOpt(CURLOPT_POSTFIELDS,json_encode([
                "customSessionId"=>$streamId,
                "mediaMode"=> "ROUTED",
                "recordingMode"=> !$record ? "MANUAL" : "ALWAYS",
                "defaultOutputMode"=> "INDIVIDUAL",
            ]))
            ->setOpt(CURLOPT_HTTPHEADER,[
                "Authorization: Basic " . base64_encode("OPENVIDUAPP:".$this->params->get('viduSecret')),
                "Content-Type: application/json"
            ]);
        $this->run()->finish();

I am using INDIVIDUAL mode yet it still creates the MP4, and ignores the resolution!

Hello @glenelkins @Glen_Elkins , you still using the old API Rest, that’s why you’re not using individual recordings.

When you create a session, you can’t use “defaultOutputMode” as an attributes as a string property of the session object. Now these attributes are part of a new property called: defaultRecordingProperties. The JSON should look like this:

{
    "customSessionId": <YOUR_SESSION_ID>,
    "mediaMode": "ROUTED",
    "recordingMode": "MANUAL"/"INDIVIDUAL",
    "defaultRecordingProperties": {
        "outputMode": "INDIVIDUAL"
    }
}

Please see the example of the documentation: REST API - OpenVidu Docs

Hi

I actually figured this out earlier today, I didn’t realise the api had changed with the upgraded version.

Thanks for the help!