I’m using startRecordingScreen() to record devices and I want to record more than 3 minutes.
I know that adb shell screenrecord time limit is 180, max.
However, we probably can work around this, by recording one video and after that one ends, start to record again, and again… until we no longer have the need to record.
The thing is: we don’t really know when the device has stopped recording, unless we use a thread, perhaps, to count the seconds that have past since the beginning of our recording.
So it would be great to have some kind of listener to which we could subscribe to know when the recording was stopped, so we could start it again, if we wanted.
Am I making any sense and/or is this even possible?
As another workaround I searched a bit and found out that using something like adb shell "screenrecord --time-limit 180 /sdcard/testRun1.mp4; screenrecord --time-limit 180 /sdcard/testRun2.mp4"
as mentioned on: How to increase time limit of ADB screen record of Android Kitkat, would do the trick of recording 2 times x 180 seconds, meaning, in the end, 360 seconds. And on stopRecordingScreen() the String which comes with a Base64 value, would be the junction of all the videos recorded.
So, maybe even if it’s not possible to subscribe the stopRecordingScreen() event, I think it would be possible to ask for more than 180 seconds on withTimeLimit() and if so, depending on the time desired, we could do something like concatenate strings and then run the final adb command with the total amount of desired time, which would be only a “recursive” screenrecord.
Just install appium@beta, replace the changed screenrecording.js file there inside appium-android-driver/lib/commands and execute gulp transpile command. After that you can start the server and it will contain the necessary changes to set the duration over 180 seconds.
Could you pls explain how did you managed to increase the video file size (more than 3.66MB)?
I’m getting an error "Encountered internal error running command: Error: Cannot read the recorded media '/sdcard/1533826793218.mp4' to the memory, because the file is too large (15.25 MB >= 3.66 MB). Try to provide a link to a remote writable location instead."
I need a bit more info to help you. Can you paste the code used to reproduce that behaviour?
Anyway, I’m using a simple startScreenRecording() with time limit only and had no problems. Sometimes I get files with 40MB or so aswell.
My guess is that you are doing something wrong
@mykola-mokhnach while running test cases while recording i found out 2 issues:
1 - After recording a test, “remains” of video are left., meaning that I had multiple 0:00 videos on my device
2 - Sometimes, some of the videos generated were corrupted.
I think that these 2 issues may be related, but i can’t test it right now.
Just wanted to mention it, since it could be a known issue or something of that sort.
Btw, I’m still using appium 1.8.2@beta
1 - After recording a test, “remains” of video are left., meaning that I had multiple 0:00 videos on my device
These are carefully deleted with rm-f command each time the resulting recorded video is delivered to the client. Try to catch the exact scenario where you get these leftovers and analyze the server log.
2 - Sometimes, some of the videos generated were corrupted.
The resulting video is generated by ffmpeg. You could try to provide the -report option to ffmpeg command line and check its actual output. Hovewer you’ll need to modify the source code a bit in order to achieve that.
Just read the API , and saw that the stopRecord returns String (base64 encoded stream)
Just wonder why the implementation of the “CanRecordScreen” is per each drive separately and not just for AppiumDriver which being extended by the both Android and IOS drivers ?
Relating your first reply, I think you already figured it out. You just need to get the result on stopRecording() and then construct a File object with it, something like this:
And then just create a file with those bytes, for example.
Relating your second reply, this occurs because some features that AndroidDriver allows you to do cannot be achieved by the iOSDriver. Why? Idk, that’s something for maybe @mykola-mokhnach to answer, but my guess it’s because iOS is a pain in the ass
Hi @Aleksei when i tried to raise time limit to 360 sec using: .withTimeLimit(Duration.ofSeconds(360)
The video i got has 180 sec length with last 180 sec are recorded and the first 180 sec is cropped