I want to develop an android aplication which allows me to continuously record a video and upload parts of the video to a server without stopping the recording. It is crucial for the application that I can record up to 60 min without stopping the video.
Initial approach
Application consits of two parts:
- MediaRecorder which records a video continuously from the camera.
- Cutter/Copy - Part: While the video is recorded I have to take out certain segments and send them to a server.
This part was implemented using http://ffmpeg4android.netcompss.com/
libffmpeg.so. I used their VideoKit Wrapper which allows me to directly run ffmpeg with any params I need.
My Problem
I tried the ffmpeg command with the params
ffmpeg -ss 00:00:03 -i <in-file> -t 00:00:05 -vcodec copy -acodec copy <out-file>
which worked great for me as long as Android's MediaRecorder finished recording.
When I execute the same command, while the MediaRecorder is recording the file, ffmpeg exits with the error message "Operation not permitted".
- I think that the error message doesn't mean that android prevents the access to the file. I think that ffmpeg needs the "moov-atoms" to find the proper position in the video.
For that reason I thought of other approaches (which don't need the moov-atom):
- Create a rtsp stream with android and access the rtsp stream later. The problem is that to my knowledge android SDK doesn't support the recording to a rtsp stream.
- Maybe it is possible to access the camera directly with ffmpeg (/dev/video0 seems to be a video device?!)
- I read about webm as an alternative for streaming, maybe android can record webm streams?!
TLDR: Too long didn't read:
I want to access a video file with ffmpeg (libffmpeg.so) while it is recording. Fffmpeg exits with the error message "Operation not permitted"
Goal:
My goal is to record a video (and audio) and take parts of the video while it is still recording and upload them to the server.
Maybe you can help me solve the probelm or you have other ideas on how to approach my problem.
Thanks a lot in advance.