Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-03 Thread Felix Matouschek

Hello,

Am 02.11.2017 um 14:40 schrieb Nicolas George:

When reading the subject of the mail, I first thought it would be about
screen capture. Furthermore, there is code for audio, but it is not
connected to anything, and it does not seem that the android API
connects audio and video together.

For all these reasons, I suggest you name this device maybe
android_camera, and keep android_mic for audio capture.

Will do so.


You are parsing the "filename" of the device into a key=value syntax.
This is not a good idea, and I really would not like another key=value
parser in the code base.

How do cameraIds look? If the string values are friendly enough, they
can be used as filenames as is.
I removed parsing of the "filename" and replaced it with a 
"camera_index" parameter.


I do not know how cameraIds are formed on different devices, seems like 
internal cameras
just use numbers but external devices may use a string. I do not have 
multiple devices to test
this. In my opionion an index for the list of all cameras should be 
sufficient.



Can the error be translated into a human-readable message?

Will try to do that, I need to add the according strings for it somehow.


Is it really the official way of getting the resolution and format of
the video? If so, were the Android people drunk?

Seem like it.


+if (format == IMAGE_FORMAT_ANDROID) {

It would be better to support as many pixel formats as possible.
For now I settled on YUV420P, as the API doc states all devices must 
support it. I do not

have the resources to test every format.


+side_data = av_packet_new_side_data(&pktl_next->pkt,
+AV_PKT_DATA_DISPLAYMATRIX, sizeof(display_matrix));

It would probably be best to avoid sending the side data repeatedly if
it does not change.
Is it sufficient to append the matrix just once? I thought every 
AVPacket could have a different matrix.



+error:
+pthread_mutex_unlock(&ctx->mutex);
+AImage_delete(image);
+
+return;

It seems error conditions are not taken into account. Is it on purpose?
You mean for example ENOMEM if allocating fails and aborting the whole 
"session"? Could do that.


Regards, 


I working on addressing all issues.

Greetings,
Felix

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-07 Thread Felix Matouschek

Hello,

I tried to address all issues.
I did not have time yet to try more image formats, so it is still only 
YUV420P.


Please review.

Greetings,
FelixFrom a235f56518fc1f11698a5028dfd4b654989993c5 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 24 Oct 2017 13:11:23 +0200
Subject: [PATCH] avdevice: add android_camera indev
To: ffmpeg-devel@ffmpeg.org

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 
---
 Changelog|   1 +
 configure|   6 +
 doc/indevs.texi  |  40 ++
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/android_camera.c | 848 +++
 libavdevice/version.h|   2 +-
 7 files changed, 898 insertions(+), 1 deletion(-)
 create mode 100644 libavdevice/android_camera.c

diff --git a/Changelog b/Changelog
index 6592d868da..f58cd810e0 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
   requires 2.1 (or later) and pkg-config.
 - VDA dropped (use VideoToolbox instead)
+- Add android_camera indev
 
 
 version 3.4:
diff --git a/configure b/configure
index 7a53bc76c7..d52b18fab3 100755
--- a/configure
+++ b/configure
@@ -3068,6 +3068,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"
@@ -5836,6 +5838,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
diff --git a/doc/indevs.texi b/doc/indevs.texi
index d308bbf7de..07056d762e 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -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.
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 8228d62147..f11a6f2a86 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -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
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index b767b6a718..2c8d9035da 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -42,6 +42,7 @@ static void register_all(void)
 {
 /* devices */
 REGISTER_INOUTDEV(ALSA, alsa);
+REGISTER_INDEV   (ANDROID_CAMERA,   android_camera);
 REGISTER_INDEV 

Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-07 Thread Felix Matouschek

Am 02.11.2017 16:20, schrieb Daniel Kučera:


some devices have cameras which are unlisted - this condition makes
them unusable.


How does one use unlisted devices? As far as I understood all supported
devices are listed. If the Camera2 API does not support the camera
it cannot be used.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-07 Thread Felix Matouschek

> Am 07.11.2017 um 16:17 schrieb Daniel Kučera :
> 
> It's used like here:
> https://github.com/danielkucera/ZidoStreamer/blob/master/app/src/main/java/eu/danman/zidostreamer/zidostreamer/StreamService.java#L62
> 
> If I open standard streaming or camera app, no camera is listed.

Note that your application uses the Camera Java API, this indev uses the 
Camera2 NDK API.

I think this cannot be compared directly. Could you test it in your specific 
case, whether the camera is somehow available through the NDK? Please note that 
the Camera2 NDK API only works on devices with API Level 24+ (Android 7.0).

As far as I have seen the camera in your device must also specifically support 
the Camera2 API. Cameras that are designed for the old API are only available 
in the Java version of the Camera2 API. 

You can check this in Java with: 
https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL

The NDK version only supports cameras that are on the hardware level LIMITED or 
above.

Greetings,
Felix

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-10 Thread Felix Matouschek
Hello,

here is a new version of the patch with further fixes.

Greetings,
Felix



0001-avdevice-add-android_camera-indev.patch
Description: Binary data


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-13 Thread Felix Matouschek

Ping
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-20 Thread Felix Matouschek

No more interest?

Am 02.11.2017 13:42, schrieb Felix Matouschek:

Hello,

I've written an indev for Android devices to allow capturing their
builtin cameras.
What needs to be done to merge this?

Greetings,
Felix
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-27 Thread Felix Matouschek

Am 22.11.2017 00:20, schrieb Michael Niedermayer:

On Tue, Nov 21, 2017 at 08:16:08AM +0100, Felix Matouschek wrote:

No more interest?


If you hear no more comments for another week, then please ping this
with CC to me and ill take a look and apply unless i spot some major
issue

also you probably want to add yourself to the MAINTAINER file if you
intend to maintain the code


Hello Michael,

as you suggested: Ping.

I added myself to the MAINTAINERS file.

One last note if you try to build it yourself:
Your NDK needs to have the patch in commit be9b8bc of this
issue https://github.com/android-ndk/ndk/issues/559 applied.

As of NDK R17 this patch will probably be included in the NDK release.

Greetings,
Felix
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-28 Thread Felix Matouschek

Am 28.11.2017 14:01, schrieb Carl Eugen Hoyos:


The patch breaks default compilation for Android?


Actually... you are right, it does.
It's a bit unfortunate as the header file in the NDK is broken.

We can't work around that in ffmpeg, the NDK needs to be fixed.
As soon as you include NdkCameraManager.h even to official examples fail 
to build.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-28 Thread Felix Matouschek

Sorry... tested it again, it does not break the default compilation.

The library check in the configure script just fails and the indev is 
not included when using the broken NDK.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek

Am 29.11.2017 04:31, schrieb Michael Niedermayer:


if the identifer and the string always match you could do this
with a macro avoiding the neede to duplcate each string
see AV_STRINGIFY


I changed it, is it ok like this?


[...]

+static int add_video_stream(AVFormatContext *avctx)
+{
+AndroidCameraCtx *ctx = avctx->priv_data;
+AVStream *st;
+AVCodecParameters *codecpar;
+
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+return AVERROR(ENOMEM);
+}
+
+st->id = VIDEO_STREAM_INDEX;



+st->avg_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
+st->r_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };


Are these values always correct ?


You mean avg_frame_rate and r_frame_rate?
The framerate can vary between the values in framerate_range[0] (min) 
and framerate_range[1] (max).
Ideally both values are the same, sometimes min can be lower but for the 
average the framerate should be what is in max.

Should I set r_frame_rate to min?

I fixed all other parts you mentioned.

Felix
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek
Sorry, my mail client swallowed the attachment, sent it again.



0001-avdevice-add-android_camera-indev.patch
Description: Binary data


> Am 30.11.2017 um 10:12 schrieb Felix Matouschek :
> 
> Am 29.11.2017 04:31, schrieb Michael Niedermayer:
> 
>> if the identifer and the string always match you could do this
>> with a macro avoiding the neede to duplcate each string
>> see AV_STRINGIFY
> 
> I changed it, is it ok like this?
> 
>> [...]
>>> +static int add_video_stream(AVFormatContext *avctx)
>>> +{
>>> +AndroidCameraCtx *ctx = avctx->priv_data;
>>> +AVStream *st;
>>> +AVCodecParameters *codecpar;
>>> +
>>> +st = avformat_new_stream(avctx, NULL);
>>> +if (!st) {
>>> +return AVERROR(ENOMEM);
>>> +}
>>> +
>>> +st->id = VIDEO_STREAM_INDEX;
>>> +st->avg_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
>>> +st->r_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
>> Are these values always correct ?
> 
> You mean avg_frame_rate and r_frame_rate?
> The framerate can vary between the values in framerate_range[0] (min) and 
> framerate_range[1] (max).
> Ideally both values are the same, sometimes min can be lower but for the 
> average the framerate should be what is in max.
> Should I set r_frame_rate to min?
> 
> I fixed all other parts you mentioned.
> 
> Felix
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek

Am 30.11.2017 14:48, schrieb Michael Niedermayer:

You mean avg_frame_rate and r_frame_rate?
The framerate can vary between the values in framerate_range[0]
(min) and framerate_range[1] (max).
Ideally both values are the same, sometimes min can be lower but for
the average the framerate should be what is in max.
Should I set r_frame_rate to min?


I think if you do not know the base or average frame rate you
should not set it.
Or does this lead to some unreasonable latency ?
or are the computed values worse ?


On some devices min and max are the same so the framerate is fixed and I 
know it.
On other devices the min framerate can be lower and so the actual 
framerate can vary between both values.


On average the framerate still should be around the maximum value.

Do you think I'm better off not setting it at all? Will it then get 
computed automatically?

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-12-08 Thread Felix Matouschek

Am 30.11.2017 17:40, schrieb Michael Niedermayer:

yes, if you dont set it, it will be computet but it would give some
latency on startup as it needs a few frames first to base the 
computation

on. This latency may or may not be a bigger problem than slightly
incorrect values. I dont know, its up to you i think what you feel
is more important


I tested it, it works way better when setting it manually so I will 
leave it like it is.


I've done some further fixes and adjustments to the patch, I attached 
the newest version.


It now works on Android 7 and 8 (tested on Nexus 9 and Pixel 2).From 80182b2ec0c2fc76584c71a7138c58b4716d5d5f Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Fri, 8 Dec 2017 10:43:51 +0100
Subject: [PATCH] avdevice: add android_camera indev
To: ffmpeg-devel@ffmpeg.org

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 
---
 Changelog|   1 +
 MAINTAINERS  |   1 +
 configure|   6 +
 doc/indevs.texi  |  40 ++
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/android_camera.c | 866 +++
 libavdevice/version.h|   2 +-
 8 files changed, 917 insertions(+), 1 deletion(-)
 create mode 100644 libavdevice/android_camera.c

diff --git a/Changelog b/Changelog
index 6592d868da..f58cd810e0 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
   requires 2.1 (or later) and pkg-config.
 - VDA dropped (use VideoToolbox instead)
+- Add android_camera indev
 
 
 version 3.4:
diff --git a/MAINTAINERS b/MAINTAINERS
index 1d2ff78b0e..d6cb135964 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -281,6 +281,7 @@ libavdevice
 
 
   avfoundation.mThilo Borgmann
+  android_camera.c  Felix Matouschek
   decklink* Marton Balint
   dshow.c   Roger Pack (CC rogerdp...@gmail.com)
   fbdev_enc.c   Lukasz Marek
diff --git a/configure b/configure
index 7a53bc76c7..d52b18fab3 100755
--- a/configure
+++ b/configure
@@ -3068,6 +3068,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"
@@ -5836,6 +5838,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
diff --git a/doc/indevs.texi b/doc/indevs.texi
index d308bbf7de..07056d762e 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -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.
diff --git a/libavdevice/Makefile b/

[FFmpeg-devel] [PATCH] configure: Fix detection of vp9 decoder/encoder

2017-12-12 Thread Felix Matouschek

This fixes the detection of the vp9 decoder/encoder.

The vp9 decoder/encoder needs libm to successfully link, -lm was missing 
in the check_lib calls for vp9 in configure.From 0b5bbd7c30f3a76b2e0ab6ceae2bfaebe944b279 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 12 Dec 2017 10:42:40 +0100
Subject: [PATCH] configure: Fix detection of vp9 decoder/encoder
To: ffmpeg-devel@ffmpeg.org

The vp9 decoder/encoder needs libm to successfully link,
-lm was missing in the check_lib calls for vp9

Signed-off-by: Felix Matouschek 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 8cf48ae1cf..4581850fe5 100755
--- a/configure
+++ b/configure
@@ -5918,11 +5918,11 @@ enabled libvpx&& {
 }
 enabled libvpx_vp9_decoder && {
 check_pkg_config libvpx_vp9_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
-check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx
+check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx -lm
 }
 enabled libvpx_vp9_encoder && {
 check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
-check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx
+check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx -lm
 }
 if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
 die "libvpx enabled but no supported decoders found"
-- 
2.14.1.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] configure: Fix detection of vp9 decoder/encoder

2017-12-12 Thread Felix Matouschek

Am 12.12.2017 15:37, schrieb James Almer:

No, this is not correct. If anything has to be added here, it would be
$libm_extralibs. -lm is not needed/available on some systems.


Ok, changed it.


Also, you should be using pkg-config. Its job is to make sure all the
cflags and ldflags are correct for your system.
This shitty fallback shouldn't be here in the first place, but some
people are too stubborn about it.


The Android NDK has no pkg-config so it is somehow useful.From b2f30f087aaf7d1284ebe08a09adc478df80ba22 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 12 Dec 2017 10:42:40 +0100
Subject: [PATCH] configure: Fix detection of vp9 decoder/encoder
To: ffmpeg-devel@ffmpeg.org

At least on Android the vp9 decoder/encoder needs $libm_extralibs
to successfully link, it was missing in the check_lib calls for vp9

Signed-off-by: Felix Matouschek 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 8cf48ae1cf..df149024d3 100755
--- a/configure
+++ b/configure
@@ -5918,11 +5918,11 @@ enabled libvpx&& {
 }
 enabled libvpx_vp9_decoder && {
 check_pkg_config libvpx_vp9_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
-check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx
+check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx $libm_extralibs
 }
 enabled libvpx_vp9_encoder && {
 check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
-check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx
+check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" -lvpx $libm_extralibs
 }
 if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
 die "libvpx enabled but no supported decoders found"
-- 
2.14.1.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-12-19 Thread Felix Matouschek
Hello Michael,

could you take a look at the patch?

Felix

> Am 30.11.2017 um 18:15 schrieb Michael Niedermayer :
> 
> On Thu, Nov 30, 2017 at 10:15:48AM +0100, Felix Matouschek wrote:
>> Sorry, my mail client swallowed the attachment, sent it again.
>> 
> 
>> Changelog|1 
>> MAINTAINERS  |1 
>> configure|6 
>> doc/indevs.texi  |   40 ++
>> libavdevice/Makefile |1 
>> libavdevice/alldevices.c |1 
>> libavdevice/android_camera.c |  816 
>> +++
>> libavdevice/version.h|2 
>> 8 files changed, 867 insertions(+), 1 deletion(-)
>> 2fea6cb3990aed83c3a3c492aa482f619a885ed7  
>> 0001-avdevice-add-android_camera-indev.patch
>> From b70da28e33e07b4565daffc94c8ffe3c8df747ff Mon Sep 17 00:00:00 2001
>> From: Felix Matouschek 
>> Date: Thu, 30 Nov 2017 10:03:54 +0100
>> Subject: [PATCH] avdevice: add android_camera indev
>> To: ffmpeg-devel@ffmpeg.org
>> 
>> 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 
>> ---
>> Changelog|   1 +
>> MAINTAINERS  |   1 +
>> configure|   6 +
>> doc/indevs.texi  |  40 +++
>> libavdevice/Makefile |   1 +
>> libavdevice/alldevices.c |   1 +
>> libavdevice/android_camera.c | 816 
>> +++
>> libavdevice/version.h|   2 +-
>> 8 files changed, 867 insertions(+), 1 deletion(-)
>> create mode 100644 libavdevice/android_camera.c
>> 
>> diff --git a/Changelog b/Changelog
>> index 6592d868da..f58cd810e0 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -6,6 +6,7 @@ version :
>> - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
>>   requires 2.1 (or later) and pkg-config.
>> - VDA dropped (use VideoToolbox instead)
>> +- Add android_camera indev
>> 
>> 
>> version 3.4:
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 1d2ff78b0e..d6cb135964 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -281,6 +281,7 @@ libavdevice
>> 
>> 
>>   avfoundation.mThilo Borgmann
>> +  android_camera.c  Felix Matouschek
>>   decklink* Marton Balint
>>   dshow.c   Roger Pack (CC rogerdp...@gmail.com)
>>   fbdev_enc.c   Lukasz Marek
>> diff --git a/configure b/configure
>> index 7a53bc76c7..d52b18fab3 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3068,6 +3068,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"
>> @@ -5836,6 +5838,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
>> diff --git a/doc/indevs.texi b/doc/indevs.texi
>> index d308bbf7de..07056d762e 100644
>> --- a/doc/indevs.texi
>> +++ b/doc/indevs.texi
>> @@ -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.
>> +
>&

Re: [FFmpeg-devel] [PATCH] configure: Fix detection of vp9 decoder/encoder

2017-12-19 Thread Felix Matouschek
Any chance this could get merged?

> Am 12.12.2017 um 15:53 schrieb Felix Matouschek :
> 
> Am 12.12.2017 15:37, schrieb James Almer:
>> No, this is not correct. If anything has to be added here, it would be
>> $libm_extralibs. -lm is not needed/available on some systems.
> 
> Ok, changed it.
> 
>> Also, you should be using pkg-config. Its job is to make sure all the
>> cflags and ldflags are correct for your system.
>> This shitty fallback shouldn't be here in the first place, but some
>> people are too stubborn about it.
> 
> The Android NDK has no pkg-config so it is somehow 
> useful.<0001-configure-Fix-detection-of-vp9-decoder-encoder.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] configure: Fix detection of vp9 decoder/encoder

2017-12-19 Thread Felix Matouschek
Am 19.12.2017 um 21:19 schrieb James Almer :
> 
> Pushed.
> 
> Wouldn't this need to be done for vp8 as well, for that matter?
> 

At least on Android using libvpx 1.6.1 it was not needed for vp8, only for vp9.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-12-22 Thread Felix Matouschek

Hello Michael,

I fixed the things you mentioned. New patch attached.

Felix
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-12-22 Thread Felix Matouschek

Am 22.12.2017 20:50, schrieb Lou Logan:


I think you forgot to attach the patch.


Sorry, flaky mail client... attached it again.From ba2ccca1200a55b0f1c0331ebd6d26324941fb2e Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Fri, 22 Dec 2017 20:10:41 +0100
Subject: [PATCH] avdevice: add android_camera indev
To: ffmpeg-devel@ffmpeg.org

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 
---
 Changelog|   1 +
 MAINTAINERS  |   1 +
 configure|   6 +
 doc/indevs.texi  |  40 ++
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/android_camera.c | 871 +++
 libavdevice/version.h|   2 +-
 8 files changed, 922 insertions(+), 1 deletion(-)
 create mode 100644 libavdevice/android_camera.c

diff --git a/Changelog b/Changelog
index ee48876128..f5e6326d32 100644
--- a/Changelog
+++ b/Changelog
@@ -27,6 +27,7 @@ version :
 - video setrange filter
 - nsp demuxer
 - support LibreSSL (via libtls)
+- Add android_camera indev
 
 
 version 3.4:
diff --git a/MAINTAINERS b/MAINTAINERS
index 6a92b5190d..bc6cbc51a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -282,6 +282,7 @@ libavdevice
 
 
   avfoundation.mThilo Borgmann
+  android_camera.c  Felix Matouschek
   decklink* Marton Balint
   dshow.c   Roger Pack (CC rogerdp...@gmail.com)
   fbdev_enc.c   Lukasz Marek
diff --git a/configure b/configure
index d09eec4155..b8a7d4bfed 100755
--- a/configure
+++ b/configure
@@ -3073,6 +3073,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"
@@ -5707,6 +5709,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
diff --git a/doc/indevs.texi b/doc/indevs.texi
index 56066bf23a..93a671dd42 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -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.
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 8228d62147..f11a6f2a86 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -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)

[FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-02 Thread Felix Matouschek

Hello,

I've written an indev for Android devices to allow capturing their 
builtin cameras.

What needs to be done to merge this?

Greetings,
FelixFrom b21fc8729ef2e1d9867dd7652f2c6173378e4910 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 24 Oct 2017 13:11:23 +0200
Subject: [PATCH] Add android_capture indev
To: ffmpeg-devel@ffmpeg.org

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 
---
 configure |   6 +
 libavdevice/Makefile  |   1 +
 libavdevice/alldevices.c  |   1 +
 libavdevice/android_capture.c | 782 ++
 libavdevice/android_capture.h |  77 +
 5 files changed, 867 insertions(+)
 create mode 100644 libavdevice/android_capture.c
 create mode 100644 libavdevice/android_capture.h

diff --git a/configure b/configure
index 7a53bc76c7..e2165f2ff9 100755
--- a/configure
+++ b/configure
@@ -3068,6 +3068,8 @@ xmv_demuxer_select="riffdec"
 xwma_demuxer_select="riffdec"
 
 # indevs / outdevs
+android_capture_indev_deps="android mediandk camera2ndk pthreads"
+android_capture_indev_extralibs="-landroid -lmediandk -lcamera2ndk"
 alsa_indev_deps="alsa"
 alsa_outdev_deps="alsa"
 avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
@@ -5836,6 +5838,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
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 8228d62147..aa01dd7e24 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -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_CAPTURE_INDEV) += android_capture.o
 OBJS-$(CONFIG_AVFOUNDATION_INDEV)+= avfoundation.o
 OBJS-$(CONFIG_BKTR_INDEV)+= bktr.o
 OBJS-$(CONFIG_CACA_OUTDEV)   += caca.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index b767b6a718..6cd57aa88a 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -42,6 +42,7 @@ static void register_all(void)
 {
 /* devices */
 REGISTER_INOUTDEV(ALSA, alsa);
+REGISTER_INDEV   (ANDROID_CAPTURE,  android_capture);
 REGISTER_INDEV   (AVFOUNDATION, avfoundation);
 REGISTER_INDEV   (BKTR, bktr);
 REGISTER_OUTDEV  (CACA, caca);
diff --git a/libavdevice/android_capture.c b/libavdevice/android_capture.c
new file mode 100644
index 00..be0dee8f81
--- /dev/null
+++ b/libavdevice/android_capture.c
@@ -0,0 +1,782 @@
+/*
+ * Android camera/microphone input source via Android NDK APIs (Audio yet to be implemented)
+ *
+ * Copyright (C) 2017 Felix Matouschek
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "libavformat/internal.h"
+#include "libavutil/avstring.h"
+#include "libavutil/display.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+
+#include "android_capture.h"
+#include "version.h"
+
+/* This image format is available on all Android devices
+ * supporting the Camera2 API */
+#define IMAGE_FORMAT_ANDROID AIMAGE_FORMAT_YUV_420_888
+#define IMAGE_FORMAT_FFMPEG AV_P

[FFmpeg-devel] [PATCH] Fix iterating of input and output devices

2018-03-14 Thread Felix Matouschek

This fixes the iterating of input and output devices

In the previous implementation the first input or output device
was skipped when device_next was called with prev = NULLFrom f90823e8dccf5751e88b8990f5789d8f67e7c496 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Wed, 14 Mar 2018 13:14:07 +0100
Subject: [PATCH] Fix iterating of input and output devices
To: ffmpeg-devel@ffmpeg.org

In the previous implementation the first input or output device
was skipped when device_next was called with prev = NULL

Signed-off-by: Felix Matouschek 
---
 libavdevice/alldevices.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 4c89649b97..271a3182a0 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -126,16 +126,13 @@ static void *device_next(void *prev, int output,
 
 ff_thread_once(&av_device_next_init, av_device_init_next);
 
-if (!prev && !(prev = (output ? (void*)outdev_list[0] : (void*)indev_list[0])))
-return NULL;
-
 do {
 if (output) {
-if (!(prev = ((AVOutputFormat *)prev)->next))
+if (!(prev = prev ? ((AVInputFormat *)prev)->next : (void*)outdev_list[0]))
 break;
 pc = ((AVOutputFormat *)prev)->priv_class;
 } else {
-if (!(prev = ((AVInputFormat *)prev)->next))
+if (!(prev = prev ? ((AVInputFormat *)prev)->next : (void*)indev_list[0]))
 break;
 pc = ((AVInputFormat *)prev)->priv_class;
 }
-- 
2.14.1.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix iterating of input and output devices

2018-03-14 Thread Felix Matouschek

My bad

Am 14.03.2018 13:25, schrieb Timo Rothenpieler:

-if (!(prev = ((AVOutputFormat *)prev)->next))
+if (!(prev = prev ? ((AVInputFormat *)prev)->next :

(void*)outdev_list[0]))

AVOutputFormat


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-develFrom cd8842ecf606d368832066fcda925c705e9e9205 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Wed, 14 Mar 2018 13:14:07 +0100
Subject: [PATCH] Fix iterating of input and output devices
To: ffmpeg-devel@ffmpeg.org

In the previous implementation the first input or output device
was skipped when device_next was called with prev = NULL

Signed-off-by: Felix Matouschek 
---
 libavdevice/alldevices.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 4c89649b97..39993354bc 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -126,16 +126,13 @@ static void *device_next(void *prev, int output,
 
 ff_thread_once(&av_device_next_init, av_device_init_next);
 
-if (!prev && !(prev = (output ? (void*)outdev_list[0] : (void*)indev_list[0])))
-return NULL;
-
 do {
 if (output) {
-if (!(prev = ((AVOutputFormat *)prev)->next))
+if (!(prev = prev ? ((AVOutputFormat *)prev)->next : (void*)outdev_list[0]))
 break;
 pc = ((AVOutputFormat *)prev)->priv_class;
 } else {
-if (!(prev = ((AVInputFormat *)prev)->next))
+if (!(prev = prev ? ((AVInputFormat *)prev)->next : (void*)indev_list[0]))
 break;
 pc = ((AVInputFormat *)prev)->priv_class;
 }
-- 
2.14.1.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-12-27 Thread Felix Matouschek
Ping

> Am 22.12.2017 um 21:36 schrieb Felix Matouschek :
> 
> Am 22.12.2017 20:50, schrieb Lou Logan:
>> I think you forgot to attach the patch.
> 
> Sorry, flaky mail client... attached it again.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2018-01-02 Thread Felix Matouschek


> Am 28.12.2017 um 19:20 schrieb Michael Niedermayer :
>> 
>> +av_image_copy_to_buffer(pkt.data, pkt_buffer_size,
>> +(const uint8_t * const *) image_plane_data,
>> +image_linestrides, ctx->image_format,
>> +ctx->width, ctx->height, 32);
> 
> Is the copy needed ?
> can the data not be put in a AVPacket without copy but by pointing to the 
> image?
> the AVPackets deallocation can be overridden to free the image 

I’m not sure but I guess it could lead to problems as the AImageReader has its 
own queue, which is currently limited to two images. In general the 
image_available callback is processed fast enough so this is not a problem and 
all AVPackets are buffered in the thread message queue (ctx->input_queue) while 
the original AImage is deleted. Every AImage is also permanently associated 
with the AImageReader and needs to be deleted for the AImageReader to accept 
new images. I think if doing so the input_queue and the AImageReader queue 
probably need the same size. 

How could I put the different pointers I get from the Android system for each 
plane into the AVPacket? I’m not even sure if all planes live in the same 
contiguous space of memory? How does one overwrite the AVPacket deallocation?

Currently I’m using AImageReader_acquireLatestImage(), this should be changed 
to AImageReader_acquireNextImage(), other than that it could work.

Felix

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2018-02-18 Thread Felix Matouschek

Hello Michael,

do you think the patch could be merged in its current state?
It is functional, maybe I can do the cosmetic changes later.
I was a bit busy the last weeks.

Would be nice if it could get into the 3.5 / 4.0 release.

Felix

Am 02.01.2018 10:23, schrieb Felix Matouschek:
Am 28.12.2017 um 19:20 schrieb Michael Niedermayer 
:


+av_image_copy_to_buffer(pkt.data, pkt_buffer_size,
+(const uint8_t * const *) 
image_plane_data,

+image_linestrides, ctx->image_format,
+ctx->width, ctx->height, 32);


Is the copy needed ?
can the data not be put in a AVPacket without copy but by pointing to 
the image?

the AVPackets deallocation can be overridden to free the image


I’m not sure but I guess it could lead to problems as the AImageReader
has its own queue, which is currently limited to two images. In
general the image_available callback is processed fast enough so this
is not a problem and all AVPackets are buffered in the thread message
queue (ctx->input_queue) while the original AImage is deleted. Every
AImage is also permanently associated with the AImageReader and needs
to be deleted for the AImageReader to accept new images. I think if
doing so the input_queue and the AImageReader queue probably need the
same size.

How could I put the different pointers I get from the Android system
for each plane into the AVPacket? I’m not even sure if all planes live
in the same contiguous space of memory? How does one overwrite the
AVPacket deallocation?

Currently I’m using AImageReader_acquireLatestImage(), this should be
changed to AImageReader_acquireNextImage(), other than that it could
work.

Felix

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2018-02-20 Thread Felix Matouschek

I rebased the patch on the current master, it does apply again.

Tested it - still works.

Felix

Am 19.02.2018 20:39, schrieb Michael Niedermayer:

On Mon, Feb 19, 2018 at 08:39:56AM +0100, Felix Matouschek wrote:

Hello Michael,

do you think the patch could be merged in its current state?
It is functional, maybe I can do the cosmetic changes later.
I was a bit busy the last weeks.

Would be nice if it could get into the 3.5 / 4.0 release.


not sure if there are issues remaining but it doesnt apply
anymore

Applying: avdevice: add android_camera indev
Using index info to reconstruct a base tree...
M   Changelog
M   MAINTAINERS
M   configure
M   doc/indevs.texi
M   libavdevice/alldevices.c
M   libavdevice/version.h
Falling back to patching base and 3-way merge...
Auto-merging libavdevice/alldevices.c
CONFLICT (content): Merge conflict in libavdevice/alldevices.c
Auto-merging doc/indevs.texi
Auto-merging configure
Auto-merging MAINTAINERS
Auto-merging Changelog
CONFLICT (content): Merge conflict in Changelog
error: Failed to merge in the changes.
Patch failed at 0001 avdevice: add android_camera indev
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


[...]
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-develFrom 3fd6cca01f175412ee3cb2c4e435694ed3cf2bb0 Mon Sep 17 00:00:00 2001
From: Felix Matouschek 
Date: Tue, 20 Feb 2018 09:41:46 +0100
Subject: [PATCH] avdevice: add android_camera indev
To: ffmpeg-devel@ffmpeg.org

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 
---
 Changelog|   1 +
 MAINTAINERS  |   1 +
 configure|   6 +
 doc/indevs.texi  |  40 ++
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/android_camera.c | 871 +++
 libavdevice/version.h|   2 +-
 8 files changed, 922 insertions(+), 1 deletion(-)
 create mode 100644 libavdevice/android_camera.c

diff --git a/Changelog b/Changelog
index 2acdbbea30..56dedd1aea 100644
--- a/Changelog
+++ b/Changelog
@@ -39,6 +39,7 @@ version :
 - 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:
diff --git a/MAINTAINERS b/MAINTAINERS
index b691bd56ec..bf1299bdbf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -281,6 +281,7 @@ libavdevice
 
 
   avfoundation.mThilo Borgmann
+  android_camera.c  Felix Matouschek
   decklink* Marton Balint
   dshow.c   Roger Pack (CC rogerdp...@gmail.com)
   fbdev_enc.c   Lukasz Marek
diff --git a/configure b/configure
index 013308cfa4..fa5c530abe 100755
--- a/configure
+++ b/configure
@@ -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"
@@ -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
diff --git a/doc/indevs.texi b/doc/indevs.texi
index 0bc8e6a9b1..6951940a93 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -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 ca