Camera Support - tanersener/ffmpeg-kit GitHub Wiki

1. Android

It is possible to access built-in camera using android_camera input device. Unfortunately, android_camera requires API level 24 and is only supported by Main releases. LTS releases, which are built with API 16, do not have this device enabled.

Additionally devices with deprecated camera HAL 1.0 implementations (camera devices that have the LEGACY hardware level) are not supported by Android NDK Native API, consequently they are not supported by FFmpegKit as well.

  • List available input devices using getSupportedCameraIds API method

    FFmpegKitConfig.getSupportedCameraIds(this);
    
  • Record the video stream (audio not supported) into a file with the command below

    -f android_camera -i 0:0 -r 30 -pixel_format bgr0 -t 00:00:05 <record file path>
    
  • Refer to android_camera input device documentation for all available options of android_camera input device

2. iOS / macOS

Built-in camera and microphone can be accessed using AVFoundation input device. All Main releases are built with AVFoundation enabled.

  • Before capturing a device, first you need to define and provide the following keys in your application's Info.plist file

    Privacy - Camera Usage Description

    Privacy - Microphone Usage Description

  • List available input devices by running this

    -f avfoundation -list_devices true -i \"\"
    
    AVFoundation video devices:
    [0] Back Camera
    [1] Front Camera
    AVFoundation audio devices:
    [0] iPhone Microphone
    
  • Record video and audio streams into a file with the following command

    -f avfoundation -r 30 -video_size 1280x720 -pixel_format bgr0 -i 0:0 -vcodec h264_videotoolbox -vsync 2 -f h264 -t 00:00:05 <record file path>
    
  • Refer to AVFoundation input device documentation for all available options of AVFoundation input device