Skip to content

Commit

Permalink
make record wait 5 seconds before pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
seamus-sloan committed Oct 23, 2023
1 parent 1b4e96e commit cb94c9a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import argparse
import sys
import os
import subprocess
import time

Expand Down Expand Up @@ -130,7 +131,7 @@ def record(device, filename):
"""Run [adb shell screenrecord video.mp4] to perform a screen record"""
if not filename:
filename = "video.mp4"
remote_path = "/data/local/tmp/screenrecord.mp4"
remote_path = f"/data/local/tmp/{filename}"

cmd = ["adb", "-s", device, "shell", f"screenrecord {remote_path}"]
proc = subprocess.Popen(cmd)
Expand All @@ -143,15 +144,19 @@ def record(device, filename):
except KeyboardInterrupt:
proc.terminate()

print("\nWaiting for recording to save to device...\n")
time.sleep(5)

cmd = ["adb", "-s", device, "pull", remote_path, filename]
result = subprocess.run(cmd)

if result.returncode == 0:
print(f"Screen recording saved to {filename}")

cmd = ["adb", "-s", device, "shell", f"rm {remote_path}"]
subprocess.run(cmd)
print(f"Success! Screen recording saved to {os.getcwd()}/{filename}")

delete = input("\nDelete video from device? (Y/n): ")
if delete.lower() == 'y':
cmd = ["adb", "-s", device, "shell", f"rm {remote_path}"]
subprocess.run(cmd)


def wifi(device):
Expand Down

0 comments on commit cb94c9a

Please sign in to comment.