Skip to main content

flutter_background_video_recorder 2.1.0 copy "flutter_background_video_recorder: ^2.1.0" to clipboard
flutter_background_video_recorder: ^2.1.0 copied to clipboard

PlatformAndroid

Record video or audio on Android from a foreground service, with camera and zoom selection, plus raw camera frames and microphone audio streams for your own processing.

2.1.0 #

Raw camera frames and microphone audio for apps that want to process the data themselves, a choice between the cameras of the device, and zoom. Nothing changes for apps that do not use them.

Added #

  • Raw frame stream. openFrameSession opens a camera and delivers its frames to any number of listeners of RawFrameSession.frames until close(). Choose the pixel format with RawFrameSettings: YUV 4:2:0 (the default and cheapest), JPEG or RGBA. Each RawFrame carries its planes, a timestamp and the rotation that makes it upright. It runs from its own foreground service, so it continues in the background, and no recording is involved.
  • Frames are delivered through shared native memory (dart:ffi), not copied over a platform channel: one native copy per frame, no serialization and no per-frame allocation in Dart. A frame is valid while the listeners run; use RawFrame.retain() / release() or toOwned() to keep one. RawFrame.droppedFrames reports frames dropped because the app was too slow. This adds a small native library (C++, NDK) to the Android build.
  • Raw audio stream. openAudioStream delivers the microphone as 16-bit or float PCM chunks to any number of listeners of RawAudioSession.chunks. Sample rate, channels, source and chunk length are settings. If the app falls behind, sound is dropped and RecorderWarningCode.audioOverrun is reported.
  • Both streams do no work while nobody listens. They are exclusive with recording where they share hardware: while a frame session is open, recording a video or showing a preview fails with RecorderErrorCode.cameraBusy; while an audio stream is open, recording fails with RecorderErrorCode.microphoneBusy. They can run together.
  • Camera selection. listCameras() returns the cameras of the device as CameraInfo (position, focal length, zoom range, a lensType guess). An optional cameraId on getVideoCapabilities, startVideoRecording, openFrameSession and RecorderPreview picks one; cameraFacing still works as before.
  • Zoom. setZoom(ratio) zooms the open camera, also while a recording is running, and an initialZoom on VideoSettings, RawFrameSettings and RecorderPreview sets where a session starts. CameraInfo.zoomRange tells what the camera supports.
  • New error codes cameraBusy, microphoneBusy, cameraNotActive and permissionPermanentlyDenied. While developing, a raw session survives a hot restart, so opening it again reports cameraBusy / microphoneBusy; stop the app and run it again (the error message and the README say so).
  • The example app has a lens picker, a zoom selector with a fine-control wheel, and a Streams mode that shows the raw streams with several listeners.

Changed #

  • A back or front camera is now oriented and mirrored according to the camera that is really used, not the requested facing.

2.0.0 #

Modernized for Android 15 and 16. Breaking changes, see "Migrating from 1.x" in the README.

Breaking #

  • Requires Android 12 (minSdk 31) and Flutter 3.29+. Older Android versions are no longer supported.
  • Requires Dart 3.7+. The previous constraint (<3.0.0) prevented the package from resolving on any current Flutter.
  • The recording service is now declared by the plugin and lives at com.lightsoftware.flutter_background_video_recorder.plugin.VideoRecorderService. Remove the services.VideoRecorderService entry from your app manifest.
  • startVideoRecording returns StartRecordingResult, and resolves after the permission dialogs are answered.
  • stopRecording (and its alias stopVideoRecording) returns RecordedMedia (uri, optional path, kind, hasLocation) instead of a file path.
  • States are the RecorderStatus enum instead of integers. Errors are RecorderExceptions. getVideoRecordingStatus is now getRecordingStatus.
  • Removed the showToast parameter and all native toasts.
  • New barrel library package:flutter_background_video_recorder/flutter_background_video_recorder.dart.

Fixed #

  • Audio was recorded at 8 kHz and about 12 kbps (the platform default when nothing is set). It is now 48 kHz, 128 kbps AAC.
  • A MediaRecorder error (full disk, encoder failure) used to leave the recorder stuck in "recording". Errors now end the recording cleanly and keep what was recorded; running out of storage and overheating are reported as such.
  • The recorder refuses to start with almost no free storage and caps the file size so the disk is not filled completely.
  • The foreground service now declares both camera and microphone types. Before, only the microphone type was used, so the camera was cut off in the background on Android 14+.
  • POST_NOTIFICATIONS is declared and requested (Android 13+).
  • Videos are saved through MediaStore (scoped storage) instead of raw paths in public storage.
  • The permission flow no longer races, crashes on partial results or swallows other plugins' permission results.
  • Recorder state no longer travels over exported broadcasts that other apps could spoof or read.
  • MediaRecorder starts only once the capture session is configured, uses TEMPLATE_RECORD, is stopped and released correctly, and a failed or empty recording is discarded.
  • The service no longer crashes when restarted by the system with a null intent, and recording no longer depends on the Activity being bound.
  • Video resolution selection (operator precedence bug, arbitrary fallback) and orientation for rear/front cameras.
  • Removed unused SYSTEM_ALERT_WINDOW and READ_EXTERNAL_STORAGE permissions and a duplicate CAMERA declaration.

Added #

  • Video settings: getVideoCapabilities() lists the sizes (grouped by aspect ratio), frame rates and codecs a camera supports. VideoSettings chooses resolution, frame rate, codec (h264, hevc, auto) and bitrate. The default is 1080p at 60 fps with fallbacks; an unsupported choice is refused with unsupportedConfiguration.
  • Audio-only recordings with startAudioRecording(): microphone permission and foreground type only, saved to Recordings/<folder>.
  • Location in the video's metadata with VideoSettings(embedLocation: true). The plugin declares no location permission; the app does.
  • Preview: the RecorderPreview widget shows a viewfinder before recording and the live picture during a recording started with VideoSettings(preview: true). Hiding it is removing the widget. Front camera preview is mirrored like a mirror.
  • VideoCapabilities.defaultResolution / defaultFrameRate (what a recording uses when nothing is set) and VideoResolution.portraitAspectRatioLabel (9:16 for 16:9).
  • The example app is now a camera-style viewfinder: full-screen preview, record button with a live timer, Video / Audio modes, a settings sheet with aspect ratio (with its vertical equivalent), resolution, frame rate and codec, and a landscape layout.
  • recorderWarnings stream (thermalWarning, previewUnavailable).
  • openAppSettings() to send the user to the system settings when permissions are permanently denied, and a dialog in the example that does so.
  • When the camera is lost mid-recording, the video recorded so far is saved, a "Recording stopped" notification is shown, and RecorderException.savedMedia points to the saved video.
  • A Stop action, content intent, own icon and channel description on the notification.
  • recorderErrors stream for failures while recording (for example the camera was lost).
  • Tests for the Dart API and the native size, orientation and folder name logic.

Build #

  • Videos are written through MediaStore only; the Android 9 file-path code and WRITE_EXTERNAL_STORAGE are gone with the minSdk 31 change.
  • Kotlin, AGP 8.9, Gradle 8.12, Java 17, compileSdk 36. The plugin namespace was corrected.

1.0.0+2 #

  • Added support for Android 14

0.0.9+1 #

  • Fixed an issue that caused the plugin to not start recording when permissions are granted

0.0.9 #

  • Updated documentation and example
  • Updated dart code to implement showToast property

0.0.8 #

  • You can now hide the toasts by setting the showToast property to false when calling startVideoRecording()

0.0.7 #

  • Added support for front camera

0.0.6 #

  • Updated documentation and README

0.0.5 #

  • Fixed an issue which caused the plugin to crash when app is closed causing the recording to continue until force stopped.

0.0.4 #

  • Fixed an issue that caused start recording to fail for the first time

0.0.3 #

  • Removed permission to draw over other apps
  • Added more documentation to code

0.0.2 #

  • Updated README.md

0.0.1 #

  • Initial release
26
likes
160
points
118
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Record video or audio on Android from a foreground service, with camera and zoom selection, plus raw camera frames and microphone audio streams for your own processing.

Repository (GitHub)
View/report issues

Topics

#camera #video #audio #android #background

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_background_video_recorder

Packages that implement flutter_background_video_recorder