Skip to content

Commit

Permalink
Merge pull request #5 from seamus-sloan/fixes/record-broken
Browse files Browse the repository at this point in the history
[FIX]: Record Broken on Some Devices
  • Loading branch information
seamus-sloan authored Oct 23, 2023
2 parents 63d1cd3 + b6d45c2 commit b5905ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ sadb scrcpy
- Start scrcpy on a device
sadb ip
- Get the selected device's IP address
sadb screenshot myScreenshot.png
sadb screenshot -f myScreenshot.png
- Take a screenshot of a device
sadb record myVideo.mp4
sadb record -f myVideo.mp4
- Record the screen of a device (Press CTRL-C to stop recording)
sadb wifi
- Connect to a device via WiFi
Expand Down
6 changes: 4 additions & 2 deletions sadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def split_get_devices(result):


def get_devices():
result = subprocess.run(["adb", "devices"], capture_output=True, text=True)
result = subprocess.run(["adb", "devices"], capture_output=True, text=True, check=False)
return split_get_devices(result.stdout)


Expand Down Expand Up @@ -114,7 +114,7 @@ def screenshot(device, filename):
def record(device, filename):
if not filename:
filename = "video.mp4"
remote_path = "/sdcard/screenrecord.mp4"
remote_path = "/data/local/tmp/screenrecord.mp4"

cmd = ["adb", "-s", device, "shell", f"screenrecord {remote_path}"]
proc = subprocess.Popen(cmd)
Expand All @@ -137,6 +137,7 @@ def record(device, filename):
subprocess.run(cmd)



def wifi(device):
ip_address = get_ip(device)

Expand Down Expand Up @@ -295,6 +296,7 @@ def main():
screenshot(device, args.filename)

elif args.command == "record":
print(args.filename)
device = select_device(devices)
if device is None:
return
Expand Down
4 changes: 2 additions & 2 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_screenshot_custom_name():

def test_record_custom_name():
filename = "custom.mp4"
remote_path = "/sdcard/screenrecord.mp4"
remote_path = "/data/local/tmp/screenrecord.mp4"

mock_proc = MagicMock()
with patch("subprocess.Popen", return_value=mock_proc) as mock_popen, \
Expand All @@ -109,7 +109,7 @@ def test_record_custom_name():

def test_record_default_name():
filename = "video.mp4"
remote_path = "/sdcard/screenrecord.mp4"
remote_path = "/data/local/tmp/screenrecord.mp4"

mock_proc = MagicMock()
with patch("subprocess.Popen", return_value=mock_proc) as mock_popen, \
Expand Down

0 comments on commit b5905ab

Please sign in to comment.