Skip to content

Commit

Permalink
avdevice: add android_camera indev
Browse files Browse the repository at this point in the history
This commit adds an indev for Android devices on API level 24+ which
uses the Android NDK Camera2 API to capture video from builtin cameras

Signed-off-by: Felix Matouschek <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
0xFelix authored and michaelni committed Feb 21, 2018
1 parent ecb3d6e commit 5ac3a30
Show file tree
Hide file tree
Showing 8 changed files with 922 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ version <next>:
- Removed the ffmenc and ffmdec muxer and demuxer
- VideoToolbox HEVC encoder and hwaccel
- VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters
- Add android_camera indev


version 3.4:
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ libavdevice


avfoundation.m Thilo Borgmann
android_camera.c Felix Matouschek
decklink* Marton Balint
dshow.c Roger Pack (CC [email protected])
fbdev_enc.c Lukasz Marek
Expand Down
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3081,6 +3081,8 @@ xmv_demuxer_select="riffdec"
xwma_demuxer_select="riffdec"

# indevs / outdevs
android_camera_indev_deps="android camera2ndk mediandk pthreads"
android_camera_indev_extralibs="-landroid -lcamera2ndk -lmediandk"
alsa_indev_deps="alsa"
alsa_outdev_deps="alsa"
avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
Expand Down Expand Up @@ -5756,6 +5758,10 @@ check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32
check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32
check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi

check_lib android android/native_window.h ANativeWindow_acquire -landroid
check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk
check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" ACameraManager_create -lcamera2ndk

enabled appkit && check_apple_framework AppKit
enabled audiotoolbox && check_apple_framework AudioToolbox
enabled avfoundation && check_apple_framework AVFoundation
Expand Down
40 changes: 40 additions & 0 deletions doc/indevs.texi
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,46 @@ Set the number of channels. Default is 2.

@end table

@section android_camera

Android camera input device.

This input devices uses the Android Camera2 NDK API which is
available on devices with API level 24+. The availability of
android_camera is autodetected during configuration.

This device allows capturing from all cameras on an Android device,
which are integrated into the Camera2 NDK API.

The available cameras are enumerated internally and can be selected
with the @var{camera_index} parameter. The input file string is
discarded.

Generally the back facing camera has index 0 while the front facing
camera has index 1.

@subsection Options

@table @option

@item video_size
Set the video size given as a string such as 640x480 or hd720.
Falls back to the first available configuration reported by
Android if requested video size is not available or by default.

@item framerate
Set the video framerate.
Falls back to the first available configuration reported by
Android if requested framerate is not available or by default (-1).

@item camera_index
Set the index of the camera to use. Default is 0.

@item input_queue_size
Set the maximum number of frames to buffer. Default is 5.

@end table

@section avfoundation

AVFoundation input device.
Expand Down
1 change: 1 addition & 0 deletions libavdevice/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ OBJS-$(CONFIG_SHARED) += reverse.o
# input/output devices
OBJS-$(CONFIG_ALSA_INDEV) += alsa_dec.o alsa.o timefilter.o
OBJS-$(CONFIG_ALSA_OUTDEV) += alsa_enc.o alsa.o
OBJS-$(CONFIG_ANDROID_CAMERA_INDEV) += android_camera.o
OBJS-$(CONFIG_AVFOUNDATION_INDEV) += avfoundation.o
OBJS-$(CONFIG_BKTR_INDEV) += bktr.o
OBJS-$(CONFIG_CACA_OUTDEV) += caca.o
Expand Down
1 change: 1 addition & 0 deletions libavdevice/alldevices.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/* devices */
extern AVInputFormat ff_alsa_demuxer;
extern AVOutputFormat ff_alsa_muxer;
extern AVInputFormat ff_android_camera_demuxer;
extern AVInputFormat ff_avfoundation_demuxer;
extern AVInputFormat ff_bktr_demuxer;
extern AVOutputFormat ff_caca_muxer;
Expand Down
Loading

0 comments on commit 5ac3a30

Please sign in to comment.