---
name: android_screen_record
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "android_screen_record([--serial <S>] [--duration <s>] [--bit-rate <bps>] [--size <WxH>] output_path: string) -> void"
description: "Record screen video via adb screenrecord, pulls to local path."
tags: [android, adb, screen, record, video, pendiente-usar]
uses_functions: [adb_wsl_bash_infra]
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: "--serial <S>"
    desc: "Optional target device serial. If omitted, autodetects first connected device/emulator."
  - name: "output_path"
    desc: "WSL destination path for the recorded .mp4 file."
  - name: "--duration <s>"
    desc: "Recording duration in seconds. Default 30, max 180 (adb screenrecord built-in limit)."
  - name: "--bit-rate <bps>"
    desc: "Video bit rate in bits per second. Default 4000000 (4 Mbps)."
  - name: "--size <WxH>"
    desc: "Video dimensions e.g. 720x1280. Default: device native resolution."
output: "Stdout 'recorded: <path> (<s>s from <serial>)'. MP4 file written to output_path."
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/android_screen_record.sh"
---

## Ejemplo

```bash
source bash/functions/infra/android_screen_record.sh

# Record 15 seconds to a local file
android_screen_record --duration 15 /tmp/demo.mp4

# Specific device, custom resolution, higher bitrate
android_screen_record --serial emulator-5554 --duration 60 --bit-rate 8000000 --size 1080x2400 ~/videos/session.mp4
```

## Notas

`adb screenrecord` tiene un limite maximo de 180 segundos por grabacion. Para capturas mas largas, encadenar multiples llamadas y concatenar los MP4 resultantes (ej. con `ffmpeg -f concat`).

El archivo temporal en el dispositivo es siempre `/sdcard/__rec.mp4` y se elimina tras el pull. Si la grabacion falla a mitad, el archivo puede quedar en el dispositivo; en ese caso ejecutar `adb shell rm /sdcard/__rec.mp4` manualmente.

Exit codes: 0 exito, 2 falta output_path, 3 ningun device encontrado.
