Skip to content

About

Record videos on an Android device and pull them to a computer running Linux.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

88 Commits

Folders and files

Repository files navigation

recdroidvid

Monitor and record video from Android devices remotely, pulling, renaming, and optionally previewing the videos when recording stops. Has very basic integration capability with DAW software (Ardour is currently the default setting).

Currently only works over USB (via the ADB interface). Only tested with OpenCamera on Android, controlled from Linux. (Windows could work in principle, but there are various Linux-specific commands which would need to be replaced.) No attempt is made to unlock a locked phone.

When the scrcpy monitor window is closed, any new videos are pulled from the phone into the current directory, renamed, and then deleted from the phone.

Disclaimer: This is beta-level software that works for what I need it to do. It is, however, written fairly generally to be customizable.

Screenshot of the program being used to record a music performance (along with the Ardour DAW and Hydrogen drums):

[screenshot of recdroidvid in action]

Installation

The easiest way to install the basic program is to install from PyPI using pip (Python 3.8 or later is required):

pip install recdroidvid

Dependencies

The required and optional dependencies are described below.

scrcpy

The scrcpy program needs to be installed and set up to be runnable via USB. It functions as the computer-screen monitor for what is being recorded on the phone. (All the actual recording is done on the phone, however.) The program is available in many linux repos, or can be compiled from the scrcpy site at https://github.com/Genymobile/scrcpy.

On Ubuntu the repos are out of date as of 2026. The easiest way to install is to get the pre-compiled version from the scrcpy repo at https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md Download the tarball, extract it, and run the executable in the main dir:

scrcpy-linux-x86_64-v4.1/scrcpy

Use the --scrcpy-cmd option (see below) to give the full path to the executable if it is not on your PATH.

Installing via snap is also possible but the snap installs can be harder to get working and the packaged version of adb may or may not match your device. This worked at one point, but now may need more connect commands to work:

sudo snap install scrcpy
snap connect scrcpy:camera
sudo snap connect scrcpy:raw-usb # Required to use OTG mode.

adb

The adb program (Android Debug Bridge) is used to control the phone and to pull the videos. It must be on your PATH. It is included in the scrcpy release tarball, or it can be installed separately:

sudo apt install adb

Camera app

The OpenCamera app needs to be installed on the phone. It is available from F-Droid and the Google Play Store. Other camera apps might work, using the --camera-package-name and --camera-save-dir options, but they have not been tested.

Device setup for scrcpy

Setup requires that developer mode be activated on the mobile device to allow ADB commands via USB:

  • Go to Settings > About phone and tap the Build number at the bottom seven times to activate developer mode.
  • Then go to Settings > System > Advanced > Developer Options and turn on USB debugging.
  • Connect the mobile device via USB and authorize it on the Android notification.

See the scrcpy Github page for more information. Use scrcpy --help | more for information about the available options.

ffmpeg

The ffmpeg program is used to print out information about the pulled movies, as well as to optionally extract audio from the video files:

sudo apt install ffmpeg

previewing

Previewing by default assumes the mpv movie player is installed (though there is an option to set any movie player program from the command line or option file):

sudo apt install mpv

DAW transport synchronization

When the --sync-daw-transport-with-video-recording option is selected, recording in the DAW is started when video recording is detected on the phone, and the DAW transport is stopped when the video recording stops. With the --add-daw-mark-on-transport-start option a mark is also added at the start of each recording. The marks are named to match the start of the saved video names, such as rdv_03 or, with the --date-and-time-in-video-name option, rdv_03_2026-10-03. (The date in the video name is the date the video is pulled from the phone, so the two can differ by a day if a recording runs past midnight.)

By default the DAW is controlled by sending Open Sound Control (OSC) messages to Ardour with the oscsend program, which is in the liblo-tools package:

sudo apt install liblo-tools

The xdotool program is used to raise the Ardour windows when the --raise-daw-on-* options are selected:

sudo apt install xdotool

Enabling OSC in Ardour

OSC is not enabled in Ardour by default. To turn it on:

  1. Open Edit > Preferences and select the Control Surfaces page.
  2. In the lower Control Surfaces list, check the box next to Open Sound Control (OSC). In Ardour 9.7 and later the list is grouped by vendor and sorted alphabetically. The OSC entry is a top-level row with no vendor, so it appears just after the Novation group, where it can easily be mistaken for one of the Novation devices.
  3. The enabled entry then appears in the Active Surfaces list. Its Settings button shows the OSC settings, including the UDP port Ardour is listening on (3819 by default).

Ardour normally remembers this setting, but if OSC stops working check that it is still enabled.

Tip

Testing the connection is usually unnecessary, but if you need to, run these commands with a session open and a track armed for recording:

oscsend localhost 3819 /add_marker s test_mark
oscsend localhost 3819 /access_action s Transport/record-roll
oscsend localhost 3819 /transport_stop

See the Ardour manual's OSC section for more information: https://manual.ardour.org/using-control-surfaces/controlling-ardour-with-osc/

To use a different OSC port, set the commands described in the next section with the new port number.

Using another DAW

Only the default commands are specific to Ardour. Another DAW can be used by setting these options, usually in the config file, to system commands that control it:

--start-daw-recording-cmd
Start recording.
--stop-daw-transport-cmd
Stop the transport.
--add-daw-mark-cmd
Add a mark at the playhead (only needed with --add-daw-mark-on-transport-start). The string RDV_MARK_NAME in the command is replaced by the shell-quoted mark name. It can be left out if the DAW cannot name marks this way.
--is-daw-running-cmd
Exit with status zero if the DAW is running, and nonzero if not. The other DAW commands are skipped when it is not running.
--raise-daw-to-top-cmd
Raise the DAW's windows (only needed with the --raise-daw-on-* options).

Any command-line program can be used, such as oscsend for a DAW that accepts OSC messages. Run recdroidvid --help to see the Ardour defaults.

Options and Customization

To see the command-line options, run recdroidvid --help | more. The output of that command is shown below.

Any options can also be set in the config file ~/.recdroidvid_rc.py. The file will be imported and the strings on the list rdv_options will be used as the default command-line options. Options given on the command line override them. For example:

rdv_options = [
   "--date-and-time-in-video-name",
   "--sync-daw-transport-with-video-recording",
   "--add-daw-mark-on-transport-start",
   "--preview-video",
]

A fuller example is in examples/recdroidvid_rc.py.

This is the help command output:

usage: recdroidvid [-h] [--scrcpy-cmd CMD-STRING] [--numbering-start INTEGER]
                   [--loop] [--wait-loop] [--autorecord] [--preview-video]
                   [--preview-video-cmd CMD-STRING]
                   [--preview-video-cmd-jack CMD-STRING]
                   [--date-and-time-in-video-name]
                   [--sync-daw-transport-with-video-recording]
                   [--start-daw-recording-cmd CMD-STRING]
                   [--stop-daw-transport-cmd CMD-STRING]
                   [--add-daw-mark-on-transport-start]
                   [--add-daw-mark-cmd CMD-STRING]
                   [--raise-daw-on-camera-app-open]
                   [--raise-daw-on-transport-toggle]
                   [--raise-daw-to-top-cmd CMD-STRING]
                   [--is-daw-running-cmd CMD-STRING] [--audio-extract]
                   [--camera-save-dir DIRPATH]
                   [--camera-package-name PACKAGENAME]
                   [--config-conditional STRING] [--no-color]
                   [PREFIXSTRING]

Record a video on mobile via ADB and pull result. All config options can be
set in a file `.recdroidvid_rc.py`. The file is evaluated and the list
`rdv_options` in the file is used as the options list. See the example config
file `examples/recdroidvid_rc.py` in the project repository.

positional arguments:
  PREFIXSTRING          The basename or prefix of the pulled video file.
                        Whether name or prefix depends on the method used to
                        record.

options:
  -h, --help            show this help message and exit
  --scrcpy-cmd CMD-STRING, -y CMD-STRING
                        The command, including arguments, to be used to launch
                        the scrcpy program. Otherwise a default version is
                        used with some common arguments. Note that the string
                        `--window-title=RDV_SCRCPY_TITLE` can be used to
                        substitute-in a more descriptive title for the window.
  --numbering-start INTEGER, -n INTEGER
                        The number at which to start numbering pulled videos.
                        The number is currently appended to the user-defined
                        prefix and defaults to 1. Allows for restarting and
                        continuing a naming sequence across invocations of the
                        program.
  --loop, -l            Loop the recording, querying between invocations of
                        `scrcpy` as to whether or not to continue. This allows
                        for shutting down the scrcpy display to save both
                        local CPU and remote device memory (videos are
                        downloaded and deleted from the device at the end of
                        each loop), but then restarting with the same options.
                        Video numbering (as included in the filename) is
                        automatically incremented over all the videos, across
                        loops.
  --wait-loop, -w       The '--loop' option always starts the scrcpy video
                        monitor immediately on the first loop. This option
                        delays the action until the user responds to a query.
                        This avoids the CPU cost of scrcpy if you are not
                        planning to start video recording right away. This
                        option implies the '--loop' option.
  --autorecord, -a      Automatically start recording when the scrcpy monitor
                        starts up.
  --preview-video, -p   Preview each video that is downloaded. Currently uses
                        the mpv program.
  --preview-video-cmd CMD-STRING
                        The command used to invoke a movie player to view the
                        preview. The default uses the mpv movie viewer. The
                        string 'RDV_PREVIEW_FILENAME', if present in the
                        command, will be replaced with the title of the video
                        being previewed.
  --preview-video-cmd-jack CMD-STRING
                        The command used to invoke a movie player to view the
                        preview when the jack audio system is detected to be
                        running. The default uses the mpv movie viewer. The
                        string 'RDV_PREVIEW_FILENAME', if present in the
                        command, will be replaced with the title of the video
                        being previewed.
  --date-and-time-in-video-name, -t
                        Include the date and time in the video names in a
                        readable format.
  --sync-daw-transport-with-video-recording, -s
                        Start the DAW transport when video recording is
                        detected on the mobile device. May increase CPU loads
                        on the computer and the mobile device.
  --start-daw-recording-cmd CMD-STRING
                        A system command to start DAW recording. Used when the
                        `--sync-daw-transport-with-video-recording` option is
                        chosen. The default uses oscsend to send an OSC
                        message to Ardour to run its `Transport/record-roll`
                        action.
  --stop-daw-transport-cmd CMD-STRING
                        A system command to stop the DAW transport. Used when
                        the `--sync-daw-transport-with-video-recording` option
                        is chosen. The default uses oscsend to send a
                        transport-stop OSC message to Ardour.
  --add-daw-mark-on-transport-start, -m
                        Whether to add a mark in the DAW when the transport
                        starts, to help in syncing with the video.
  --add-daw-mark-cmd CMD-STRING
                        A system command to add a mark to the DAW at the
                        playhead. The default uses oscsend to send an add-
                        marker OSC message to Ardour. The string
                        'RDV_MARK_NAME', if present in the command, is
                        replaced with a shell-quoted name for the mark, such
                        as `rdv_03_2026-10-03`, which matches the start of the
                        name the corresponding video will be saved as.
  --raise-daw-on-camera-app-open, -q
                        Raise the DAW to the top of the window stack when the
                        camera app is opened on the mobile device. Works well
                        when scrcpy is also passed the `--always-on-top`
                        option.
  --raise-daw-on-transport-toggle, -r
                        Raise the DAW to the top of the window stack whenever
                        the DAW transport is started or stopped by the
                        `--sync-daw-transport-with-video-recording` option.
                        Works well when scrcpy is also passed the `--always-
                        on-top` option.
  --raise-daw-to-top-cmd CMD-STRING
                        A system command to raise the DAW windows to the top
                        of the window stack. Used when either of the `--raise-
                        daw-on-camera-app-open` or `--raise-daw-on-transport-
                        toggle` options are selected. The default uses xdotool
                        to activate any Ardour windows.
  --is-daw-running-cmd CMD-STRING
                        A system command to test if the DAW is actually
                        running. A zero return code means it is, and a nonzero
                        return code means it isn't. The default uses pgrep to
                        look for an Ardour process.
  --audio-extract, -e   Extract a separate audio file (currently always a WAV
                        file) from each video.
  --camera-save-dir DIRPATH, -d DIRPATH
                        The directory on the remote device where the camera
                        app saves videos. Record a video and look at the
                        information about the video to find the path. Defaults
                        to the OpenCamera default save directory.
  --camera-package-name PACKAGENAME, -c PACKAGENAME
                        The Android package name of the camera app. Defaults
                        to "net.sourceforge.opencamera", the OpenCamera
                        package name. Look in the URL of the app's PlayStore
                        web site to find this string.
  --config-conditional STRING
                        The `.recdroidvid_rc.py` config file contains
                        interpreted Python code, so conditionals can be set
                        for different use-cases. This option allows one to set
                        a string value from the command line which can then be
                        used to choose a case in the config file. To set such
                        a variable, pass the value to this option. The default
                        value is the string "default". To access this
                        variable, use `from recdroidvid import
                        config_conditional` at the top of the config file.
  --no-color            Do not use color highlighting on the terminal output.

About

Record videos on an Android device and pull them to a computer running Linux.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages