Video is not capturing in Landscape mode while running appium script in iPad

Appium script is running in LANDSCAPE mode in iPad but Video is capturing in PORTRAIT mode. Can you please let me know how to capture video in Landscape mode ? Please find the below code.

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(“automationName”, “XCUITest”);
desiredCapabilities.setCapability(“platformName”, “iOS”);
desiredCapabilities.setCapability(“platformVersion”, version);
desiredCapabilities.setCapability(“deviceName”, deviceName);
desiredCapabilities.setCapability(“udid”, deviceName);
desiredCapabilities.setCapability(“orientation”, “LANDSCAPE”);

Video Recording Code:

((CanRecordScreen) driver.getAppiumDriver()).startRecordingScreen();

try
{
String video = ((CanRecordScreen) driver.getAppiumDriver()).stopRecordingScreen();
byte[] decodedVideo = Base64.getMimeDecoder().decode(video);

            Path testVideoDir = Paths.get(properties.getProperty("VideoRecordPath").trim());
            try {
				Files.createDirectories(testVideoDir);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            
            Path testVideoFile = Paths.get(testVideoDir.toString(), String.format("%s-%d.%s", "test", System.currentTimeMillis(), "mp4"));
            try {
				Files.write(testVideoFile, decodedVideo);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
           
           }catch(Exception e)
		{
			
		}
1 Like

Hi @poovaraj
I have the same problem. Did you find a fix for it?

It is not fixed but I am rotating video in VLC player after capturing.

Note: Video is also not playing properly.

Rotating it afterwards is also my current solution.

How is it not playing properly? I slowed it down a bit by increasing the frames per second to 20 and changing the videotype to mpeg4.

It is playing video after changing video type and frames per seconds. Is it possible to record directly MPEG4 format ?

This is what I’ve done:

final BaseStartScreenRecordingOptions options = new IOSStartScreenRecordingOptions()
                .withVideoType("mpeg4").withFps(20)
                .withTimeLimit(Duration.ofMinutes(30));
((CanRecordScreen) driver).startRecordingScreen(options);

I am using appium client 6.1.0 version and real iPad device. It is not showing mpeg4 file format in videoType and withFps method.

Reference link :-

https://appium.github.io/java-client/io/appium/java_client/ios/IOSStartScreenRecordingOptions.html

The format of the screen capture to be recorded. Available formats: “h264”, “mp4” or “fmp4”. Default is “mp4”. Only works for Simulator.

Which version of appium client are you using ?

Currently the video options don’t have possibility to set video rotation parameter, but ffmpeg itself allows to do it. I’m going to add filter option, so it will be possible to provide transpose option like it is described in https://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg

@mykola-mokhnach Thank you !