Android - Stream camera as RTMP stream [closed]

笑着哭i 提交于 2019-12-02 19:44:22
aergistal

In the accepted answer of the question you linked someone suggests using JavaCV.

It requires API 8 or newer and features a FFmpegFrameRecorder class.

Link to github:

https://github.com/bytedeco/javacv

They even have a full sample of capturing flv (it's rather large so I won't paste it here): https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java

In your case you probably need to replace:

private String ffmpeg_link = "/mnt/sdcard/stream.flv";

with

private String ffmpeg_link = "rtmp://<server>:<port>/stream";

You should take a look at spydroid; it does exactly what you are looking for. Their website may be found here: https://code.google.com/p/spydroid-ipcamera/

They provide a library that you can use, along with an explanation of the various streaming options and some code examples. Said information may be found here: https://github.com/fyhertz/libstreaming

If you can publish from your android device using a protocol supported by ffmpeg (see the list of protocols supported) you could use the following command to transmit the video to your server :

ffmpeg -re -i <input link> -vcodec h264 -ar 44100 -f flv "rtmp://<host>/<publication>"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!