Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streaming and recording video on android at the same time

I am searching for a library which offer ability for streaming video from android device (5.1+) and recording it at the same time.

I tried MediaRecorder - the usual way to record videos on android - but with it I am not able to stream it over webrtc or rtsp because camera is busy.

Currently I am using libstreaming. With little modification done app can record and stream over rtsp concurrently. But this lib lacks support for hardware codec in MTK and SPRG chipsets.

I am wonder if you can recommend a solution or another lib which. By the moment lib works only on nexus 4 with qcom chipset.

like image 507
balbelias Avatar asked Oct 29 '22 17:10

balbelias


1 Answers

After several days of research, I came to the decision to use a combination of FFMpeg and MediaCodec.

It seems that the only way to get frames from camera at high rate is to use Android MediaCodec API. But MediaCodec supports only mp4 file formats, which is not an option for me (I need ts), while FFMpeg can process\create any kind of human known video formats.

Currently I am trying to make it work together (read ByteBuffer from MediaCodec and feed FFMpeg recorder with it).

Useful links:

  • Grafika project: https://github.com/google/grafika

ContinuousCapture and Show + record are the most interesting parts to check

  • javacpp (specifically FFMpeg wrapper): https://github.com/bytedeco/javacpp

Has example with recording and streaming.

  • kickflip sdk: https://github.com/Kickflip/kickflip-android-sdk

The library which makes two mentioned above tools works together and also is open sourced. Sadly it doesn't solve my problem fully. The feature I need is requested but not already implemented: https://github.com/bytedeco/javacv/issues/95

like image 88
balbelias Avatar answered Nov 15 '22 07:11

balbelias