Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Record Broken on Some Devices #5

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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