The Handbook

    Theme
    • Guides
        • Check a system before installing FreeBSD
        • Orient a Linux administrator on FreeBSD
        • Supported FreeBSD releases
        • Choose a FreeBSD documentation and support channel
        • Move files safely without GNU mv -t
        • Update, upgrade, or update packages?
        • Upgrade 14.4 or 15.0 to FreeBSD 15.1
        • Choose packages, ports, or poudriere
        • Choose the quarterly or latest package branch
        • Choose a FreeBSD download or package mirror
        • Make a system setting persistent
        • Configure locale, keyboard, and time zone
        • Configure a serial console for recovery
        • Choose a custom kernel, module, or loader setting
        • Run a Linux binary with the compatibility layer
        • Check desktop and laptop hardware before installation
        • Choose and check a graphics driver
        • Choose Xorg or Wayland
        • Build a maintainable desktop baseline
        • Install and check a desktop browser
        • Check laptop Wi-Fi, power, and suspend
        • Check multimedia readiness
        • Choose and configure a printing stack
        • Run Windows applications with Wine
        • Snapshot and replicate a ZFS dataset
        • Choose a filesystem and storage layout
        • Operate ZFS without losing the recovery path
        • Restore files from a ZFS snapshot
        • Read ZFS pool health and run a scrub
        • Replace a failed device in a ZFS mirror
        • Replicate a ZFS dataset over SSH
        • Change PF safely on a remote host
        • Configure a narrow WireGuard tunnel
        • Plan a FreeBSD home server
        • Choose a mail server or an outgoing relay
        • Publish a network service safely
        • Choose a jail network model
        • Choose native jails or a jail manager
        • Choose a jail or a bhyve virtual machine
        • Establish a FreeBSD security baseline
        • Choose a MAC policy
        • Audit security-relevant activity
        • Start a DTrace performance investigation
    • Integrations
        • Create a first jail with Bastille
        • Compare jail managers and OCI tooling
        • Publish a Bastille service through PF
        • Mount a ZFS dataset in a Bastille jail
        • Update and upgrade Bastille jails
        • Back up and restore a Bastille jail
        • Prepare bhyve and vm-bhyve
        • Choose NFS or Samba for file sharing
        • Choose ZFS backup automation
        • Operate a signed poudriere repository
        • Manage FreeBSD configuration with Ansible or Salt
        • Run Motion with webcamd on FreeBSD
        • Design a reverse proxy, certificates, and monitoring
    • FAQ
      • Troubleshooting
          • Recover an interrupted freebsd-update run
          • Resolve a package repository or ABI mismatch
          • Diagnose the FreeBSD boot path
          • Recover with a ZFS boot environment
          • Diagnose DNS, routing, and firewall paths
          • Diagnose network mbuf exhaustion
          • Bind a service to a low port without running it as root
          • Diagnose audio output or input
          • Diagnose webcamd, cuse, and a webcam
          • Fix USB device permissions without opening every device
      • About this handbook
      • Synopsis
      • Establish the camera first
      • Create a working configuration
      • Start and verify Motion
      • Check control, streaming, and recording separately
      • Reach the interface without publishing it
      • Recheck after camera or package changes
      • Primary references

      Run Motion with webcamd on FreeBSD

      Last reviewed
      13 August 2026
      Applies to
      15.1-RELEASE, 15.0-RELEASE, 14.4-RELEASE

      Synopsis #

      Motion can record video when a camera image changes and can provide a local control page and MJPEG stream. On FreeBSD, a supported USB camera normally reaches Motion through webcamd, the cuse kernel module, and a /dev/video* node.

      Prove that camera path before configuring Motion. Keep Motion’s web control and stream bound to localhost; both reveal a privacy-sensitive device, and the control interface can change the running configuration. Remote access should cross an authenticated tunnel or a deliberately designed reverse proxy rather than a public listener.

      Establish the camera first #

      Install the camera utilities and Motion from the configured package repository:

      # pkg install webcamd pwcview motion
      

      Follow Diagnose webcamd, cuse, and a webcam until the intended camera produces a local image in pwcview. Record the selected device node:

      $ ls -l /dev/video*
      $ pwcview -f 30 -s vga
      

      Substitute the node established on the system. Close pwcview before starting Motion because two processes may not be able to capture from the same device simultaneously.

      Create a working configuration #

      The FreeBSD package installs a distribution example, not an active configuration. Preserve that example and create the file required by the rc service:

      # install -m 600 /usr/local/etc/motion/motion-dist.conf /usr/local/etc/motion/motion.conf
      # install -d -m 700 /var/db/motion
      

      Edit /usr/local/etc/motion/motion.conf. Begin with the following small set of current Motion 4.7 options, changing /dev/video0 only when the established camera uses another node:

      daemon on
      pid_file /var/run/motion.pid
      target_dir /var/db/motion
      
      video_device /dev/video0
      width 640
      height 480
      framerate 15
      
      movie_output on
      picture_output off
      
      webcontrol_port 8080
      webcontrol_localhost on
      webcontrol_parms 0
      
      stream_port 8081
      stream_localhost on
      

      The packaged rc script expects /usr/local/etc/motion/motion.conf and tracks /var/run/motion.pid. daemon on and the matching pid_file allow Motion to detach while preserving rc service control. Start with a modest resolution and frame rate that the camera already proved it can deliver.

      The example enables event movies and disables still pictures. Review the complete installed example and Motion configuration reference before enabling scripts, databases, notifications, or longer retention.

      Start and verify Motion #

      Enable the packaged service and start it:

      # sysrc motion_enable=YES
      # service motion start
      # service motion status
      $ pgrep -lf motion
      

      Inspect recent daemon messages if startup fails:

      # tail -n 100 /var/log/messages
      

      Common failures at this stage are an absent /dev/video* node, a device still held by a viewer, an unsupported image format or resolution, an unwritable target directory, or a configuration option copied from an older Motion release.

      Confirm that the two HTTP listeners remain local:

      # sockstat -4 -6 -l | grep motion
      

      The expected listener addresses are loopback addresses on ports 8080 and 8081. A wildcard address such as *: or a non-loopback host address means the interface is exposed beyond the intended boundary.

      Check control, streaming, and recording separately #

      Open the local control page and stream from a browser on the FreeBSD host:

      http://127.0.0.1:8080/
      http://127.0.0.1:8081/
      

      The control page proves the daemon’s HTTP interface. The stream proves ongoing capture. Neither proves that event detection writes a usable recording.

      Create motion in the camera’s field of view, wait for the configured event gap, and inspect the target directory:

      # find /var/db/motion -type f -ls
      

      Play a completed sample file and confirm its time, duration, and image content. Then review free space and ownership:

      $ df -h /var/db/motion
      # ls -ld /var/db/motion
      

      Video retention needs an explicit capacity and privacy policy. A full target filesystem can interrupt recording and other services if it shares their dataset. Place recordings in a dedicated dataset or filesystem when quotas, snapshots, or disposal policy require a separate boundary.

      Reach the interface without publishing it #

      For occasional administration from another machine, retain the localhost settings and use SSH port forwarding from the client:

      $ ssh -L 8080:127.0.0.1:8080 -L 8081:127.0.0.1:8081 administrator@camera-host
      

      While that SSH session remains open, the client can use http://127.0.0.1:8080/ and http://127.0.0.1:8081/. SSH supplies authentication and encryption without changing Motion’s listener scope.

      A permanently shared interface needs its own threat model, authentication, TLS termination, access logs, updates, and exposure test. Use Publish a network service safely before placing a reverse proxy or firewall rule in front of Motion. Do not expose an unauthenticated Motion control port directly to the Internet.

      Recheck after camera or package changes #

      Moving a USB camera, changing a dock, or attaching an identical device can alter device selection. After such a change:

      1. confirm the camera with webcamd -l;
      2. confirm the resulting /dev/video* node;
      3. test one local frame with pwcview;
      4. restart Motion;
      5. verify a new completed recording.

      After a Motion package upgrade, compare the installed distribution example and upstream release notes with the active configuration. Do not replace the active file wholesale because it also carries local device, storage, and exposure policy.

      Primary references #

      • FreeBSD Handbook: Setting up a webcam
      • FreeBSD Ports: Motion
      • FreeBSD Motion rc script
      • Motion 4.7 configuration reference
      • webcamd(8)
      • cuse(3)
      • sockstat(1)

      Independent documentation. Not affiliated with or endorsed by the FreeBSD Project or the FreeBSD Foundation.

      Report a bug
      • Synopsis
      • Establish the camera first
      • Create a working configuration
      • Start and verify Motion
      • Check control, streaming, and recording separately
      • Reach the interface without publishing it
      • Recheck after camera or package changes
      • Primary references