How to record video on Android into Stream

前端 未结 2 1534
刺人心
刺人心 2020-12-24 09:00

Android MediaRecorder allows to save video to file (file or socket):

setOutputFile(FileDescriptor fd);
setOutputFile(String path)

How to sa

2条回答
  •  春和景丽
    2020-12-24 09:40

    Using Android-specific LocalServerSocket seems to be the only possible way to get video data as stream. In brief, you have to:

    1. create LocalServerSocket instance
    2. set it as output file to MediaRecorder instance using file descriptor (mediaRecorder.setOutputFile(FileDescriptor fd);)
    3. accept connection
    4. read bytes from it (as from InputStream) in separate thread in loop

    Another ideas?

提交回复
热议问题